Skip to content

Commit

Permalink
chore: migrate stories
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelhel committed Jul 7, 2023
1 parent f9d3586 commit 255a7eb
Show file tree
Hide file tree
Showing 13 changed files with 937 additions and 868 deletions.
3 changes: 3 additions & 0 deletions docs/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
69 changes: 36 additions & 33 deletions docs/stories/styles/Grid.stories.ts
Original file line number Diff line number Diff line change
@@ -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 = `<div class="puik-grid">
<puik-card>1 col</puik-card>
<puik-card>1 col</puik-card>
<puik-card>1 col</puik-card>
<puik-card>1 col</puik-card>
<puik-card>1 col</puik-card>
<puik-card>1 col</puik-card>
<puik-card class="col-span-2">2 col</puik-card>
<puik-card class="col-span-2">2 col</puik-card>
<puik-card class="col-span-2">2 col</puik-card>
<puik-card class="col-span-3">3 col</puik-card>
<puik-card class="col-span-3">3 col</puik-card>
<puik-card class="col-span-3">3 col</puik-card>
<puik-card class="col-span-3">3 col</puik-card>
<puik-card class="col-span-4">4 col</puik-card>
<puik-card class="col-span-4">4 col</puik-card>
<puik-card class="col-span-4">4 col</puik-card>
</div>`
const htmlTemplate = `<div class="puik-grid">
<puik-card>1 col</puik-card>
<puik-card>1 col</puik-card>
<puik-card>1 col</puik-card>
<puik-card>1 col</puik-card>
<puik-card>1 col</puik-card>
<puik-card>1 col</puik-card>
<puik-card class="col-span-2">2 col</puik-card>
<puik-card class="col-span-2">2 col</puik-card>
<puik-card class="col-span-2">2 col</puik-card>
<puik-card class="col-span-3">3 col</puik-card>
<puik-card class="col-span-3">3 col</puik-card>
<puik-card class="col-span-3">3 col</puik-card>
<puik-card class="col-span-3">3 col</puik-card>
<puik-card class="col-span-4">4 col</puik-card>
<puik-card class="col-span-4">4 col</puik-card>
<puik-card class="col-span-4">4 col</puik-card>
</div>`

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')
25 changes: 12 additions & 13 deletions docs/stories/styles/Typography.stories.ts
Original file line number Diff line number Diff line change
@@ -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(`
Expand Down
6 changes: 4 additions & 2 deletions packages/components/menu/stories/menu.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ export default {
},
parameters: {
docs: {
inlineStories: false,
iframeHeight: 500,
story: {
inline: false,
iframeHeight: 500,
},
},
},
} as Meta
Expand Down
6 changes: 4 additions & 2 deletions packages/components/modal/stories/modal.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ export enum PuikModalSize {
parameters: {
chromatic: { delay: 3000 },
docs: {
inlineStories: false,
iframeHeight: 500,
story: {
inline: false,
iframeHeight: 500,
},
},
},
} as Meta
Expand Down
26 changes: 15 additions & 11 deletions packages/components/sidebar/stories/sidebar-group-item.stories.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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,
Expand All @@ -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: `
<!--VueJS Snippet-->
<puik-sidebar>
<puik-sidebar-item title="Dashboard" icon="trending_up" />
Expand All @@ -112,7 +115,8 @@ Default.parameters = {
</puik-sidebar-group-item>
</puik-sidebar>
`,
language: 'html',
language: 'html',
},
},
},
}
56 changes: 30 additions & 26 deletions packages/components/sidebar/stories/sidebar-item.stories.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -111,29 +113,31 @@ const Template: Story = (args: Args) => ({
`,
})

export const Default = Template.bind({})
Default.args = {}
Default.parameters = {
docs: {
source: {
code: `
<!--VueJS Snippet-->
<puik-sidebar>
<puik-sidebar-item :title="title" :icon="icon" :active="active" />
<puik-sidebar-item title="Dashboard" icon="trending_up" />
<puik-sidebar-title>Section title</puik-sidebar-title>
<puik-sidebar-group-item
title="Orders"
icon="shopping_basket"
name="group-1"
:active="active"
>
export const Default: StoryObj = {
render: Template,
args: {},
parameters: {
docs: {
source: {
code: `
<!--VueJS Snippet-->
<puik-sidebar>
<puik-sidebar-item :title="title" :icon="icon" :active="active" />
<puik-sidebar-item title="Title 2" />
</puik-sidebar-group-item>
</puik-sidebar>
`,
language: 'html',
<puik-sidebar-item title="Dashboard" icon="trending_up" />
<puik-sidebar-title>Section title</puik-sidebar-title>
<puik-sidebar-group-item
title="Orders"
icon="shopping_basket"
name="group-1"
:active="active"
>
<puik-sidebar-item :title="title" :icon="icon" :active="active" />
<puik-sidebar-item title="Title 2" />
</puik-sidebar-group-item>
</puik-sidebar>
`,
language: 'html',
},
},
},
}
25 changes: 15 additions & 10 deletions packages/components/sidebar/stories/sidebar-title.stories.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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,
Expand All @@ -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: `
<!--VueJS Snippet-->
<puik-sidebar-title :tag="tag">Title</puik-sidebar-title>
`,
language: 'html',
language: 'html',
},
},
},
}
Loading

0 comments on commit 255a7eb

Please sign in to comment.