[16/n][Storybook] Steps argTypes and typed variants (#53)

This commit is contained in:
Vivian Phung 2024-05-14 17:48:38 -04:00 committed by GitHub
commit 6fdbcf6f46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 41 deletions

View File

@ -2,7 +2,7 @@ import { Fragment, ComponentPropsWithoutRef } from 'react';
import { stepsTheme, StepsTheme } from './Steps.theme';
import { Step, StepProps, StepTheme } from './Step';
interface StepsProps
export interface StepsProps
extends ComponentPropsWithoutRef<'ul'>,
StepsTheme,
Pick<StepTheme, 'orientation'> {

View File

@ -1,2 +1,3 @@
export * from './Steps';
export * from './Steps.theme';
export * from './Step';

View File

@ -1,6 +1,22 @@
import { StoryObj, Meta } from '@storybook/react';
import { Steps } from 'components/shared/Steps';
import { Steps, StepsTheme, StepProps } from 'components/shared/Steps';
const stepsOrientations: StepsTheme['orientation'][] = [
'horizontal',
'vertical',
];
const stepsOptions: Pick<StepProps, 'label'>[] = [
{
label: 'Create repository',
},
{
label: 'Deploy',
},
{
label: `What's next?`,
},
];
const meta: Meta<typeof Steps> = {
title: 'Components/Steps',
@ -9,7 +25,7 @@ const meta: Meta<typeof Steps> = {
argTypes: {
orientation: {
control: 'radio',
options: ['horizontal', 'vertical'],
options: stepsOrientations,
},
currentIndex: {
control: 'number',
@ -25,50 +41,23 @@ export default meta;
type Story = StoryObj<typeof Steps>;
export const Default: Story = {
render: ({ orientation, currentIndex, steps }) => (
<Steps
currentIndex={currentIndex}
steps={steps}
orientation={orientation}
/>
),
args: {
currentIndex: 0,
steps: [
{
label: 'Create repository',
},
{
label: 'Deploy',
},
{
label: `What's next?`,
},
],
orientation: 'vertical',
currentIndex: 1,
steps: stepsOptions,
},
};
export const Horizontal: Story = {
render: ({ orientation, currentIndex, steps }) => (
<Steps
currentIndex={currentIndex}
steps={steps}
orientation={orientation}
/>
),
args: {
currentIndex: 0,
steps: [
{
label: 'Create repository',
},
{
label: 'Deploy',
},
{
label: `What's next?`,
},
],
...Default.args,
orientation: 'horizontal',
},
};
export const Past: Story = {
args: {
...Default.args,
currentIndex: 2,
},
};