mirror of
https://github.com/snowball-tools/snowballtools-base.git
synced 2024-12-22 16:37:44 +00:00
[16/n][Storybook] Steps argTypes and typed variants
This commit is contained in:
parent
d3cf0453e7
commit
702cef24b3
@ -2,7 +2,7 @@ import { Fragment, ComponentPropsWithoutRef } from 'react';
|
|||||||
import { stepsTheme, StepsTheme } from './Steps.theme';
|
import { stepsTheme, StepsTheme } from './Steps.theme';
|
||||||
import { Step, StepProps, StepTheme } from './Step';
|
import { Step, StepProps, StepTheme } from './Step';
|
||||||
|
|
||||||
interface StepsProps
|
export interface StepsProps
|
||||||
extends ComponentPropsWithoutRef<'ul'>,
|
extends ComponentPropsWithoutRef<'ul'>,
|
||||||
StepsTheme,
|
StepsTheme,
|
||||||
Pick<StepTheme, 'orientation'> {
|
Pick<StepTheme, 'orientation'> {
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export * from './Steps';
|
export * from './Steps';
|
||||||
export * from './Steps.theme';
|
export * from './Steps.theme';
|
||||||
|
export * from './Step';
|
||||||
|
@ -1,6 +1,22 @@
|
|||||||
import { StoryObj, Meta } from '@storybook/react';
|
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> = {
|
const meta: Meta<typeof Steps> = {
|
||||||
title: 'Components/Steps',
|
title: 'Components/Steps',
|
||||||
@ -9,7 +25,7 @@ const meta: Meta<typeof Steps> = {
|
|||||||
argTypes: {
|
argTypes: {
|
||||||
orientation: {
|
orientation: {
|
||||||
control: 'radio',
|
control: 'radio',
|
||||||
options: ['horizontal', 'vertical'],
|
options: stepsOrientations,
|
||||||
},
|
},
|
||||||
currentIndex: {
|
currentIndex: {
|
||||||
control: 'number',
|
control: 'number',
|
||||||
@ -25,50 +41,23 @@ export default meta;
|
|||||||
type Story = StoryObj<typeof Steps>;
|
type Story = StoryObj<typeof Steps>;
|
||||||
|
|
||||||
export const Default: Story = {
|
export const Default: Story = {
|
||||||
render: ({ orientation, currentIndex, steps }) => (
|
|
||||||
<Steps
|
|
||||||
currentIndex={currentIndex}
|
|
||||||
steps={steps}
|
|
||||||
orientation={orientation}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
args: {
|
args: {
|
||||||
currentIndex: 0,
|
orientation: 'vertical',
|
||||||
steps: [
|
currentIndex: 1,
|
||||||
{
|
steps: stepsOptions,
|
||||||
label: 'Create repository',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Deploy',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: `What's next?`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Horizontal: Story = {
|
export const Horizontal: Story = {
|
||||||
render: ({ orientation, currentIndex, steps }) => (
|
|
||||||
<Steps
|
|
||||||
currentIndex={currentIndex}
|
|
||||||
steps={steps}
|
|
||||||
orientation={orientation}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
args: {
|
args: {
|
||||||
currentIndex: 0,
|
...Default.args,
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
label: 'Create repository',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Deploy',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: `What's next?`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
orientation: 'horizontal',
|
orientation: 'horizontal',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const Past: Story = {
|
||||||
|
args: {
|
||||||
|
...Default.args,
|
||||||
|
currentIndex: 2,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user