From 255a7ebef365866689a3f53fd7892736971cff57 Mon Sep 17 00:00:00 2001 From: Aubin Mottier Date: Fri, 7 Jul 2023 15:55:12 +0200 Subject: [PATCH] chore: migrate stories --- docs/.storybook/main.js | 3 + docs/stories/styles/Grid.stories.ts | 69 +- docs/stories/styles/Typography.stories.ts | 25 +- .../components/menu/stories/menu.stories.ts | 6 +- .../components/modal/stories/modal.stories.ts | 6 +- .../stories/sidebar-group-item.stories.ts | 26 +- .../sidebar/stories/sidebar-item.stories.ts | 56 +- .../sidebar/stories/sidebar-title.stories.ts | 25 +- .../sidebar/stories/sidebar.stories.ts | 58 +- .../stories/skeleton-loader.stories.ts | 58 +- .../snackbar/stories/snackbar.stories.ts | 143 +-- .../components/table/stories/table.stories.ts | 964 +++++++++--------- .../textarea/stories/textarea.stories.ts | 366 +++---- 13 files changed, 937 insertions(+), 868 deletions(-) diff --git a/docs/.storybook/main.js b/docs/.storybook/main.js index 8925f2be..e81bdf9a 100644 --- a/docs/.storybook/main.js +++ b/docs/.storybook/main.js @@ -4,6 +4,9 @@ module.exports = { '../stories/*/**.@(js|jsx|ts|tsx|mdx)', '../../packages/components/**/*.stories.@(js|jsx|ts|tsx|mdx)', ], + core: { + disableTelemetry: true, + }, addons: [ '@storybook/addon-links', '@storybook/addon-essentials', diff --git a/docs/stories/styles/Grid.stories.ts b/docs/stories/styles/Grid.stories.ts index 54ca0c43..e40b5606 100644 --- a/docs/stories/styles/Grid.stories.ts +++ b/docs/stories/styles/Grid.stories.ts @@ -1,51 +1,54 @@ import { PuikCard } from '@puik/components' -import type { Story, Meta } from '@storybook/vue3' +import type { StoryFn, StoryObj, Meta } from '@storybook/vue3' export default { title: 'Styles/Grid', } as Meta -function generateStory(defaultViewport?: string) { - const htmlTemplate = `
- 1 col - 1 col - 1 col - 1 col - 1 col - 1 col - 2 col - 2 col - 2 col - 3 col - 3 col - 3 col - 3 col - 4 col - 4 col - 4 col -
` +const htmlTemplate = `
+ 1 col + 1 col + 1 col + 1 col + 1 col + 1 col + 2 col + 2 col + 2 col + 3 col + 3 col + 3 col + 3 col + 4 col + 4 col + 4 col +
` - const Template: Story = () => ({ - components: { PuikCard }, - template: htmlTemplate, - }) +const Template: StoryFn = () => ({ + components: { PuikCard }, + template: htmlTemplate, +}) - const Story: Story = Template.bind({}) - Story.parameters = { - controls: { hideNoControlsWarning: true }, - docs: { - source: { - code: htmlTemplate, - language: 'html', +function generateStory(defaultViewport?: string): StoryObj { + const Story: StoryObj = { + render: Template, + parameters: { + controls: { hideNoControlsWarning: true }, + docs: { + source: { + code: htmlTemplate, + language: 'html', + }, }, }, } - if (defaultViewport) Story.parameters.viewport = { defaultViewport } + if (defaultViewport && Story.parameters) + Story.parameters.viewport = { defaultViewport } return Story } -export const Lg = generateStory() +export const Lg = generateStory('lg') export const Md = generateStory('md') export const Sm = generateStory('sm') diff --git a/docs/stories/styles/Typography.stories.ts b/docs/stories/styles/Typography.stories.ts index cab44c09..a4be7b21 100644 --- a/docs/stories/styles/Typography.stories.ts +++ b/docs/stories/styles/Typography.stories.ts @@ -1,27 +1,26 @@ -import type { Meta, Story } from '@storybook/vue3' +import type { Meta, StoryFn, StoryObj } from '@storybook/vue3' export default { title: 'Styles/Typography', } as Meta -function generateStory(htmlTemplate: string) { - const Template: Story = () => ({ +function generateStory(htmlTemplate: string): StoryObj { + const Template: StoryFn = () => ({ template: htmlTemplate, }) - const Story = Template.bind({}) - - Story.parameters = { - controls: { hideNoControlsWarning: true }, - docs: { - source: { - code: htmlTemplate, - language: 'html', + return { + render: Template, + parameters: { + controls: { hideNoControlsWarning: true }, + docs: { + source: { + code: htmlTemplate, + language: 'html', + }, }, }, } - - return Story } export const Title = generateStory(` diff --git a/packages/components/menu/stories/menu.stories.ts b/packages/components/menu/stories/menu.stories.ts index f4eae827..0d278c34 100644 --- a/packages/components/menu/stories/menu.stories.ts +++ b/packages/components/menu/stories/menu.stories.ts @@ -72,8 +72,10 @@ export default { }, parameters: { docs: { - inlineStories: false, - iframeHeight: 500, + story: { + inline: false, + iframeHeight: 500, + }, }, }, } as Meta diff --git a/packages/components/modal/stories/modal.stories.ts b/packages/components/modal/stories/modal.stories.ts index 9d07ab83..daae8f34 100644 --- a/packages/components/modal/stories/modal.stories.ts +++ b/packages/components/modal/stories/modal.stories.ts @@ -204,8 +204,10 @@ export enum PuikModalSize { parameters: { chromatic: { delay: 3000 }, docs: { - inlineStories: false, - iframeHeight: 500, + story: { + inline: false, + iframeHeight: 500, + }, }, }, } as Meta diff --git a/packages/components/sidebar/stories/sidebar-group-item.stories.ts b/packages/components/sidebar/stories/sidebar-group-item.stories.ts index c2f77b87..65e9c308 100644 --- a/packages/components/sidebar/stories/sidebar-group-item.stories.ts +++ b/packages/components/sidebar/stories/sidebar-group-item.stories.ts @@ -1,6 +1,6 @@ import { PuikSidebarGroupItem, PuikSidebarItem, PuikSidebarTitle } from '..' import PuikSidebar from './../src/sidebar.vue' -import type { Meta, Story, Args } from '@storybook/vue3' +import type { Meta, StoryObj, StoryFn, Args } from '@storybook/vue3' export default { title: 'Components/Sidebar/SidebarGroupItem', @@ -61,13 +61,15 @@ export default { }, parameters: { docs: { - inlineStories: false, - iframeHeight: 500, + story: { + inline: false, + iframeHeight: 500, + }, }, }, } as Meta -const Template: Story = (args: Args) => ({ +const Template: StoryFn = (args: Args) => ({ components: { PuikSidebar, PuikSidebarGroupItem, @@ -91,12 +93,13 @@ const Template: Story = (args: Args) => ({ `, }) -export const Default = Template.bind({}) -Default.args = {} -Default.parameters = { - docs: { - source: { - code: ` +export const Default: StoryObj = { + render: Template, + args: {}, + parameters: { + docs: { + source: { + code: ` @@ -112,7 +115,8 @@ Default.parameters = { `, - language: 'html', + language: 'html', + }, }, }, } diff --git a/packages/components/sidebar/stories/sidebar-item.stories.ts b/packages/components/sidebar/stories/sidebar-item.stories.ts index 47a2f6ae..4010960c 100644 --- a/packages/components/sidebar/stories/sidebar-item.stories.ts +++ b/packages/components/sidebar/stories/sidebar-item.stories.ts @@ -1,6 +1,6 @@ import { PuikSidebarGroupItem, PuikSidebarItem, PuikSidebarTitle } from '..' import PuikSidebar from './../src/sidebar.vue' -import type { Meta, Story, Args } from '@storybook/vue3' +import type { Meta, StoryObj, StoryFn, Args } from '@storybook/vue3' export default { title: 'Components/Sidebar/SidebarItem', @@ -77,13 +77,15 @@ export default { }, parameters: { docs: { - inlineStories: false, - iframeHeight: 500, + story: { + inline: false, + iframeHeight: 500, + }, }, }, } as Meta -const Template: Story = (args: Args) => ({ +const Template: StoryFn = (args: Args) => ({ components: { PuikSidebar, PuikSidebarGroupItem, @@ -111,29 +113,31 @@ const Template: Story = (args: Args) => ({ `, }) -export const Default = Template.bind({}) -Default.args = {} -Default.parameters = { - docs: { - source: { - code: ` - - - - - Section title - +export const Default: StoryObj = { + render: Template, + args: {}, + parameters: { + docs: { + source: { + code: ` + + - - - -`, - language: 'html', + + Section title + + + + + + `, + language: 'html', + }, }, }, } diff --git a/packages/components/sidebar/stories/sidebar-title.stories.ts b/packages/components/sidebar/stories/sidebar-title.stories.ts index 7e8c7c77..b0cd3c3b 100644 --- a/packages/components/sidebar/stories/sidebar-title.stories.ts +++ b/packages/components/sidebar/stories/sidebar-title.stories.ts @@ -1,6 +1,6 @@ import { PuikSidebarItem, PuikSidebarTitle } from '..' import PuikSidebar from './../src/sidebar.vue' -import type { Meta, Story, Args } from '@storybook/vue3' +import type { Meta, StoryObj, StoryFn, Args } from '@storybook/vue3' export default { title: 'Components/Sidebar/SidebarTitle', @@ -37,13 +37,15 @@ export default { }, parameters: { docs: { - inlineStories: false, - iframeHeight: 500, + story: { + inline: false, + iframeHeight: 500, + }, }, }, } as Meta -const Template: Story = (args: Args) => ({ +const Template: StoryFn = (args: Args) => ({ components: { PuikSidebar, PuikSidebarItem, @@ -61,15 +63,18 @@ const Template: Story = (args: Args) => ({ `, }) -export const Default = Template.bind({}) -Default.parameters = { - docs: { - source: { - code: ` +export const Default: StoryObj = { + render: Template, + args: {}, + parameters: { + docs: { + source: { + code: ` Title `, - language: 'html', + language: 'html', + }, }, }, } diff --git a/packages/components/sidebar/stories/sidebar.stories.ts b/packages/components/sidebar/stories/sidebar.stories.ts index e27e7474..ae2f43dd 100644 --- a/packages/components/sidebar/stories/sidebar.stories.ts +++ b/packages/components/sidebar/stories/sidebar.stories.ts @@ -1,7 +1,7 @@ import { PuikSidebarGroupItem, PuikSidebarItem, PuikSidebarTitle } from '..' import { PuikButton } from '../..' import PuikSidebar from './../src/sidebar.vue' -import type { Meta, Story, Args } from '@storybook/vue3' +import type { Meta, StoryObj, StoryFn, Args } from '@storybook/vue3' export default { title: 'Components/Sidebar', @@ -47,13 +47,15 @@ export default { }, parameters: { docs: { - inlineStories: false, - iframeHeight: 500, + story: { + inline: false, + iframeHeight: 500, + }, }, }, } as Meta -const Template: Story = (args: Args) => ({ +const Template: StoryFn = (args: Args) => ({ components: { PuikSidebar, PuikSidebarGroupItem, @@ -97,15 +99,16 @@ const Template: Story = (args: Args) => ({ `, }) -export const Default = Template.bind({}) -Default.args = { - expanded: false, - mobile: false, -} -Default.parameters = { - docs: { - source: { - code: ` +export const Default: StoryObj = { + render: Template, + args: { + expanded: false, + mobile: false, + }, + parameters: { + docs: { + source: { + code: ` @@ -162,7 +165,7 @@ Default.parameters = { @@ -316,12 +319,13 @@ Default.parameters = { `, - language: 'html', + language: 'html', + }, }, }, } -const MobileTemplate = (args: Args) => ({ +const MobileTemplate: StoryFn = (args: Args) => ({ components: { PuikSidebar, PuikSidebarGroupItem, @@ -374,15 +378,16 @@ const MobileTemplate = (args: Args) => ({ `, }) -export const Mobile: Story = MobileTemplate.bind({}) -Mobile.args = { - expanded: false, - mobile: true, -} -Mobile.parameters = { - docs: { - source: { - code: ` +export const Mobile: StoryObj = { + render: MobileTemplate, + args: { + expanded: false, + mobile: true, + }, + parameters: { + docs: { + source: { + code: ` @@ -543,7 +548,8 @@ Mobile.parameters = { Open/Close `, - language: 'html', + language: 'html', + }, }, }, } diff --git a/packages/components/skeleton-loader/stories/skeleton-loader.stories.ts b/packages/components/skeleton-loader/stories/skeleton-loader.stories.ts index e6406141..c0ab3275 100644 --- a/packages/components/skeleton-loader/stories/skeleton-loader.stories.ts +++ b/packages/components/skeleton-loader/stories/skeleton-loader.stories.ts @@ -1,7 +1,7 @@ import { skeletonLoaderVariants } from '../src/skeleton-loader' import PuikSkeletonLoader from './../src/skeleton-loader.vue' import PuikSkeletonLoaderGroup from './../src/skeleton-loader-group.vue' -import type { Meta, StoryFn, Args } from '@storybook/vue3' +import type { Meta, StoryFn, StoryObj, Args } from '@storybook/vue3' const skeletonLoaderVariantsSummary = skeletonLoaderVariants.join('|') @@ -101,15 +101,16 @@ export const Default = { }, } -function generateStory(variant: string) { - const story = Template.bind({}) - story.args = { - variant, - } - story.parameters = { - docs: { - source: { - code: ` +function generateStory(variant: string): StoryObj { + return { + render: Template, + args: { + variant, + }, + parameters: { + docs: { + source: { + code: ` @@ -120,27 +121,26 @@ function generateStory(variant: string) {
`, - language: 'html', + language: 'html', + }, }, }, } - - return story } -export const h1 = generateStory('h1') -export const h2 = generateStory('h2') -export const h3 = generateStory('h3') -export const h4 = generateStory('h4') -export const h5 = generateStory('h5') -export const h6 = generateStory('h6') -export const Jumbotron = generateStory('jumbotron') -export const MegaJumbotron = generateStory('mega-jumbotron') -export const TextSmall = generateStory('text-small') -export const TextMedium = generateStory('text-medium') -export const TextLarge = generateStory('text-large') -export const Badge = generateStory('badge') -export const Tag = generateStory('tag') -export const Image = generateStory('image') -export const Graph = generateStory('graph') -export const Video = generateStory('video') +export const h1: StoryObj = generateStory('h1') +export const h2: StoryObj = generateStory('h2') +export const h3: StoryObj = generateStory('h3') +export const h4: StoryObj = generateStory('h4') +export const h5: StoryObj = generateStory('h5') +export const h6: StoryObj = generateStory('h6') +export const Jumbotron: StoryObj = generateStory('jumbotron') +export const MegaJumbotron: StoryObj = generateStory('mega-jumbotron') +export const TextSmall: StoryObj = generateStory('text-small') +export const TextMedium: StoryObj = generateStory('text-medium') +export const TextLarge: StoryObj = generateStory('text-large') +export const Badge: StoryObj = generateStory('badge') +export const Tag: StoryObj = generateStory('tag') +export const Image: StoryObj = generateStory('image') +export const Graph: StoryObj = generateStory('graph') +export const Video: StoryObj = generateStory('video') diff --git a/packages/components/snackbar/stories/snackbar.stories.ts b/packages/components/snackbar/stories/snackbar.stories.ts index 2598b857..b46ccf49 100644 --- a/packages/components/snackbar/stories/snackbar.stories.ts +++ b/packages/components/snackbar/stories/snackbar.stories.ts @@ -2,7 +2,7 @@ import { action } from '@storybook/addon-actions' import { PuikSnackbar } from '..' import { snackbarVariants, type PuikSnackbarOptions } from '../src/snackbar' import { PuikButton } from '../../button/index' -import type { Meta, Story, Args } from '@storybook/vue3' +import type { Meta, StoryFn, StoryObj, Args } from '@storybook/vue3' const snackbarVariantSummary = snackbarVariants.join('|') @@ -87,7 +87,7 @@ export default { args: {}, } as Meta -const Template: Story = (args: Args) => ({ +const Template: StoryFn = (args: Args) => ({ components: { PuikButton, }, @@ -98,13 +98,14 @@ const Template: Story = (args: Args) => ({ template: `Display Snackbar`, }) -export const Default = Template.bind({}) - -Default.args = { - text: 'New category added.', +export const Default = { + render: Template, + args: { + text: 'New category added.', + }, } -export const WithoutAction: Story = () => ({ +const WithoutActionTemplate: StoryFn = () => ({ components: { PuikButton, }, @@ -128,10 +129,12 @@ export const WithoutAction: Story = () => ({ `, }) -WithoutAction.parameters = { - docs: { - source: { - code: ` +export const WithoutAction: StoryObj = { + render: WithoutActionTemplate, + parameters: { + docs: { + source: { + code: `