From 3e78e3a418c1252bbf9fa996220c48b817ec4ed0 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 23 Aug 2023 11:13:02 -0700 Subject: [PATCH] fix: Update D- Components to Storybook CSF3 --- .../DayPicker/DayPicker.stories.tsx | 168 +++++++++--------- src/components/Divider/Divider.stories.tsx | 49 ++--- .../DotLoader/DotLoader.stories.tsx | 35 +++- 3 files changed, 139 insertions(+), 113 deletions(-) diff --git a/src/components/DayPicker/DayPicker.stories.tsx b/src/components/DayPicker/DayPicker.stories.tsx index 61c797e2..9a435b35 100644 --- a/src/components/DayPicker/DayPicker.stories.tsx +++ b/src/components/DayPicker/DayPicker.stories.tsx @@ -1,120 +1,120 @@ import React from 'react'; -import { ComponentStory, ComponentMeta } from '@storybook/react'; +import { StoryObj, Meta } from '@storybook/react'; import { DayPicker } from './DayPicker'; -export default { +const meta: Meta = { title: 'Form Components/DayPicker', component: DayPicker, - argTypes: {}, -} as ComponentMeta; - -const Template: ComponentStory = (args) => ( - -); - -export const Default = Template.bind({}); -Default.args = { - label: 'Day Picker', + args: { + label: 'Day Picker', + }, + decorators: [ + (story) =>
{story()}
, + ], }; +export default meta; +type Story = StoryObj; -export const ValueAndOnDayChange = Template.bind({}); -ValueAndOnDayChange.parameters = { - docs: { - description: { - story: `\`DayPicker\` is a controlled component, and uses the \`value\` and \`onDayChange\` props -to facilitate input. +export const Default: Story = {}; -If \`value\` is set to \`undefined\`, the provided \`placeholder\` message will be shown. +export const ValueAndOnDayChange: Story = { + parameters: { + docs: { + description: { + story: `\`DayPicker\` is a controlled component, and uses the \`value\` and \`onDayChange\` props + to facilitate input. -\`onDayChange\` is called in two scenarios: + If \`value\` is set to \`undefined\`, the provided \`placeholder\` message will be shown. -- a date was selected in the calendar UI -- if manual input is enabled (via \`parseDate\`), and the input is updated to a valid date string.`, + \`onDayChange\` is called in two scenarios: + + - a date was selected in the calendar UI + - if manual input is enabled (via \`parseDate\`), and the input is updated to a valid date string.`, + }, }, }, -}; -ValueAndOnDayChange.args = { - label: 'Day Picker', - value: new Date(), + args: { + value: new Date(), + }, }; -export const FormatDate = Template.bind({}); -FormatDate.parameters = { - docs: { - description: { - story: `Custom text formats can be supported via the \`formatDate\` prop`, +export const FormatDate: Story = { + parameters: { + docs: { + description: { + story: `Custom text formats can be supported via the \`formatDate\` prop`, + }, }, }, -}; -FormatDate.args = { - label: 'Day Picker', - value: new Date(), - formatDate: (date: Date) => date.toISOString().slice(0, 10), + args: { + value: new Date(), + formatDate: (date: Date) => date.toISOString().slice(0, 10), + }, }; -export const ManualInput = Template.bind({}); -ManualInput.parameters = { - docs: { - description: { - story: `By default, \`DayPicker\` does not allow for manual input into the text field. +export const ManualInput: Story = { + parameters: { + docs: { + description: { + story: `By default, \`DayPicker\` does not allow for manual input into the text field. -Providing the \`parseDate\` prop will enable this behavior. + Providing the \`parseDate\` prop will enable this behavior. -You can use the \`onTextChange\` prop to visually handle malformed strings, e.g. via an error message.`, + You can use the \`onTextChange\` prop to visually handle malformed strings, e.g. via an error message.`, + }, }, }, -}; -ManualInput.args = { - label: 'Day Picker', - value: new Date(), - formatDate: (date: Date) => date.toISOString().slice(0, 10), - parseDate: (_text: string) => new Date(), - onTextChange: (_text: string) => {}, + args: { + value: new Date(), + formatDate: (date: Date) => date.toISOString().slice(0, 10), + parseDate: (_text: string) => new Date(), + onTextChange: (_text: string) => {}, + }, }; -export const MinDate = Template.bind({}); -MinDate.args = { - label: 'Day Picker', - value: new Date(), - minDate: new Date(), +export const MinDate: Story = { + args: { + value: new Date(), + minDate: new Date(), + }, }; -export const MaxDate = Template.bind({}); -MaxDate.args = { - label: 'Day Picker', - value: new Date(), - maxDate: new Date(), +export const MaxDate: Story = { + args: { + value: new Date(), + maxDate: new Date(), + }, }; -export const DisableDay = Template.bind({}); -DisableDay.args = { - label: 'Day Picker', - value: new Date(), - disableDay: (date: Date) => date.getDate() % 2 === 0, +export const DisableDay: Story = { + args: { + value: new Date(), + disableDay: (date: Date) => date.getDate() % 2 === 0, + }, }; -export const AnchorPosition = Template.bind({}); -AnchorPosition.args = { - label: 'Day Picker', - value: new Date(), - anchorPosition: 'top-right', +export const AnchorPosition: Story = { + args: { + value: new Date(), + anchorPosition: 'bottom-right', + }, }; -export const InverseDark = Template.bind({}); -InverseDark.parameters = { - backgrounds: { default: 'dark' }, -}; -InverseDark.args = { - label: 'Day Picker', - color: 'inverse', +export const InverseDark: Story = { + parameters: { + backgrounds: { default: 'dark' }, + }, + args: { + color: 'inverse', + }, }; -export const InverseBlue = Template.bind({}); -InverseBlue.parameters = { - backgrounds: { default: 'blue' }, -}; -InverseBlue.args = { - label: 'Day Picker', - color: 'inverse', +export const InverseBlue: Story = { + parameters: { + backgrounds: { default: 'blue' }, + }, + args: { + color: 'inverse', + }, }; diff --git a/src/components/Divider/Divider.stories.tsx b/src/components/Divider/Divider.stories.tsx index e8b274f4..888204a7 100644 --- a/src/components/Divider/Divider.stories.tsx +++ b/src/components/Divider/Divider.stories.tsx @@ -1,33 +1,40 @@ import React from 'react'; -import { ComponentStory, ComponentMeta } from '@storybook/react'; +import { StoryObj, Meta } from '@storybook/react'; import { Divider } from './Divider'; -export default { +const meta: Meta = { title: 'Layout/Divider', component: Divider, - argTypes: {}, -} as ComponentMeta; - -const Template: ComponentStory = (args) => ( - -); +}; +export default meta; +type Story = StoryObj; -export const Default = Template.bind({}); -Default.args = {}; +export const Default: Story = {}; -export const InverseDark = Template.bind({}); -InverseDark.parameters = { - backgrounds: { default: 'dark' }, -}; -InverseDark.args = { - color: 'inverse', +export const InverseDark: Story = { + parameters: { + backgrounds: { default: 'dark' }, + }, + args: { + color: 'inverse', + }, }; -export const InverseBlue = Template.bind({}); -InverseBlue.parameters = { - backgrounds: { default: 'blue' }, +export const InverseBlue: Story = { + parameters: { + backgrounds: { default: 'blue' }, + }, + args: { + color: 'inverse', + }, }; -InverseBlue.args = { - color: 'inverse', + +export const Direction: Story = { + args: { + direction: 'row', + }, + decorators: [ + (story: Function) =>
{story()}
, + ], }; diff --git a/src/components/DotLoader/DotLoader.stories.tsx b/src/components/DotLoader/DotLoader.stories.tsx index 572933da..721f7df2 100644 --- a/src/components/DotLoader/DotLoader.stories.tsx +++ b/src/components/DotLoader/DotLoader.stories.tsx @@ -1,17 +1,36 @@ import React from 'react'; -import { ComponentStory, ComponentMeta } from '@storybook/react'; +import { StoryObj, StoryFn, Meta } from '@storybook/react'; +import { makeStyles } from '../../styles'; import { DotLoader } from './DotLoader'; -export default { +const useStyles = makeStyles(() => ({ + styledLoader: { + fill: 'black', + }, +})); + +const meta: Meta = { title: 'Components/DotLoader', component: DotLoader, argTypes: {}, -} as ComponentMeta; +} as Meta; +export default meta; +type Story = StoryObj; + +const Template: StoryFn = (args) => { + const classes = useStyles({}); + return ; +}; + +export const Default: Story = {}; -const Template: ComponentStory = (args) => ( - -); +export const Small: Story = { + args: { + size: 1, + }, +}; -export const Default = Template.bind({}); -Default.args = {}; +export const Styled: Story = { + render: Template, +};