diff --git a/.storybook/StoryWrapper.vue b/.storybook/StoryWrapper.vue new file mode 100644 index 0000000..a4cd441 --- /dev/null +++ b/.storybook/StoryWrapper.vue @@ -0,0 +1,22 @@ + + + + + + diff --git a/.storybook/preview.ts b/.storybook/preview.ts index f4b46e7..8c13fb0 100644 --- a/.storybook/preview.ts +++ b/.storybook/preview.ts @@ -1,4 +1,34 @@ import type { Preview } from "@storybook/vue3"; +import vuetify from '../renderer/vuetify' +import { withVuetifyTheme } from './withVuetifyTheme.decorator'; +// .storybook/preview.js + +import { setup } from '@storybook/vue3'; + +setup((app) => { + // Registers your app's plugins into Storybook + app.use(vuetify); +}); + +export const decorators = [withVuetifyTheme]; + +export const globalTypes = { + theme: { + name: 'Theme', + description: 'Global theme for components', + defaultValue: 'light', + toolbar: { + icon: 'paintbrush', + // Array of plain string values or MenuItem shape + items: [ + { value: 'light', title: 'Light', left: '🌞' }, + { value: 'dark', title: 'Dark', left: '🌛' }, + ], + // Change title based on selected value + dynamicTitle: true, + }, + }, +}; const preview: Preview = { parameters: { diff --git a/.storybook/withVuetifyTheme.decorator.ts b/.storybook/withVuetifyTheme.decorator.ts new file mode 100644 index 0000000..5da21cc --- /dev/null +++ b/.storybook/withVuetifyTheme.decorator.ts @@ -0,0 +1,22 @@ +// .storybook/withVeutifyTheme.decorator.js +import { h } from 'vue'; +import StoryWrapper from './StoryWrapper.vue'; + +export const DEFAULT_THEME = 'light'; + +export const withVuetifyTheme = (storyFn, context) => { + // Pull our global theme variable, fallback to DEFAULT_THEME + const themeName = context.globals.theme || DEFAULT_THEME; + const story = storyFn(); + + return () => { + return h( + StoryWrapper, + { themeName }, // Props for StoryWrapper + { + // Puts your story into StoryWrapper's "story" slot with your story args + story: () => h(story, { ...context.args }), + } + ); + }; +}; \ No newline at end of file