Skip to content

Commit

Permalink
story foo
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Jan 26, 2024
1 parent 8511ea6 commit 494a6f9
Show file tree
Hide file tree
Showing 37 changed files with 11,026 additions and 13,149 deletions.
16 changes: 16 additions & 0 deletions .storybook/StoryWrapper.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<v-app :theme="themeName" :full-height="false">
<v-main>
<slot name="story"></slot>
</v-main>
</v-app>
</template>


<script>
export default {
props: {
themeName: String,
},
};
</script>
2 changes: 1 addition & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { StorybookConfig } from '@storybook/vue3-vite'

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
stories: ['../src/**/*.mdx', '../src/components/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
Expand Down
29 changes: 27 additions & 2 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type { Preview } from '@storybook/vue3'
import { setup, type Preview } from '@storybook/vue3'
import { registerPlugins } from '../src/plugins'
import { withVuetifyTheme } from './withVuetifyTheme.decorator';

// import type { StoryIdentifier } from "@storybook/types"

Expand All @@ -14,7 +16,6 @@ const preview: Preview = {
options: {
// The `a` and `b` arguments in this function have a type of `import('@storybook/types').IndexEntry`. Remember that the function is executed in a JavaScript environment, so use JSDoc for IntelliSense to introspect it.
storySort: (a /*: StoryIdentifier*/, b /*: StoryIdentifier*/) => {
console.log('a', a, 'b', b)
if (a.id === b.id) {
return 0
} else {
Expand All @@ -25,4 +26,28 @@ const preview: Preview = {
}
}

setup((app) => {
// Registers your app's plugins into Storybook
registerPlugins(app);
});

export default preview

export const decorators = [withVuetifyTheme];

export const globalTypes = {
theme: {
name: 'Theme',
description: 'Global theme for components',
toolbar: {
icon: 'paintbrush',
// Array of plain string values or MenuItem shape
items: [
{ value: 'customLightTheme', title: 'Light', left: '🌞' },
{ value: 'dark', title: 'Dark', left: '🌛' },
],
// Change title based on selected value
dynamicTitle: true,
},
},
};
20 changes: 20 additions & 0 deletions .storybook/withVuetifyTheme.decorator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { h } from 'vue';
import StoryWrapper from './StoryWrapper.vue';

export const DEFAULT_THEME = 'customLightTheme';

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 },
{
story: () => h(story, { ...context.args }),
}
);
};
};
Loading

0 comments on commit 494a6f9

Please sign in to comment.