Add a type on CatalogDecorator (#1742)
* Add a type on CatalogDecorator Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> * Type more catalogs Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> --------- Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com>
This commit is contained in:
@ -3,6 +3,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { IconSearch } from '@/ui/icon';
|
import { IconSearch } from '@/ui/icon';
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@ -37,7 +38,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof Button> = {
|
||||||
args: { title: 'Filter', Icon: IconSearch },
|
args: { title: 'Filter', Icon: IconSearch },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
size: { control: false },
|
size: { control: false },
|
||||||
@ -109,7 +110,7 @@ export const Catalog: Story = {
|
|||||||
decorators: [CatalogDecorator],
|
decorators: [CatalogDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SoonCatalog: Story = {
|
export const SoonCatalog: CatalogStory<Story, typeof Button> = {
|
||||||
args: { title: 'Filter', Icon: IconSearch, soon: true },
|
args: { title: 'Filter', Icon: IconSearch, soon: true },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
size: { control: false },
|
size: { control: false },
|
||||||
@ -181,7 +182,7 @@ export const SoonCatalog: Story = {
|
|||||||
decorators: [CatalogDecorator],
|
decorators: [CatalogDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PositionCatalog: Story = {
|
export const PositionCatalog: CatalogStory<Story, typeof Button> = {
|
||||||
args: { title: 'Filter', Icon: IconSearch },
|
args: { title: 'Filter', Icon: IconSearch },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
size: { control: false },
|
size: { control: false },
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { IconCheckbox, IconNotes, IconTimelineEvent } from '@/ui/icon';
|
import { IconCheckbox, IconNotes, IconTimelineEvent } from '@/ui/icon';
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { Button, ButtonAccent, ButtonSize, ButtonVariant } from '../Button';
|
import { Button, ButtonAccent, ButtonSize, ButtonVariant } from '../Button';
|
||||||
import { ButtonGroup } from '../ButtonGroup';
|
import { ButtonGroup } from '../ButtonGroup';
|
||||||
@ -32,7 +33,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof ButtonGroup> = {
|
||||||
args: {
|
args: {
|
||||||
children: [
|
children: [
|
||||||
<Button Icon={IconNotes} title="Note" />,
|
<Button Icon={IconNotes} title="Note" />,
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { IconSearch } from '@/ui/icon';
|
import { IconSearch } from '@/ui/icon';
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { FloatingButton, FloatingButtonSize } from '../FloatingButton';
|
import { FloatingButton, FloatingButtonSize } from '../FloatingButton';
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof FloatingButton> = {
|
||||||
args: { title: 'Filter', Icon: IconSearch },
|
args: { title: 'Filter', Icon: IconSearch },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
size: { control: false },
|
size: { control: false },
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { IconCheckbox, IconNotes, IconTimelineEvent } from '@/ui/icon';
|
import { IconCheckbox, IconNotes, IconTimelineEvent } from '@/ui/icon';
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { FloatingButton, FloatingButtonSize } from '../FloatingButton';
|
import { FloatingButton, FloatingButtonSize } from '../FloatingButton';
|
||||||
import { FloatingButtonGroup } from '../FloatingButtonGroup';
|
import { FloatingButtonGroup } from '../FloatingButtonGroup';
|
||||||
@ -30,7 +31,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof FloatingButtonGroup> = {
|
||||||
args: {
|
args: {
|
||||||
children: [
|
children: [
|
||||||
<FloatingButton Icon={IconNotes} />,
|
<FloatingButton Icon={IconNotes} />,
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { IconSearch } from '@/ui/icon';
|
import { IconSearch } from '@/ui/icon';
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
FloatingIconButton,
|
FloatingIconButton,
|
||||||
@ -33,7 +34,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof FloatingIconButton> = {
|
||||||
args: { Icon: IconSearch },
|
args: { Icon: IconSearch },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
size: { control: false },
|
size: { control: false },
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { IconCheckbox, IconNotes, IconTimelineEvent } from '@/ui/icon';
|
import { IconCheckbox, IconNotes, IconTimelineEvent } from '@/ui/icon';
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { FloatingIconButtonSize } from '../FloatingIconButton';
|
import { FloatingIconButtonSize } from '../FloatingIconButton';
|
||||||
import { FloatingIconButtonGroup } from '../FloatingIconButtonGroup';
|
import { FloatingIconButtonGroup } from '../FloatingIconButtonGroup';
|
||||||
@ -32,7 +33,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof FloatingIconButtonGroup> = {
|
||||||
argTypes: {
|
argTypes: {
|
||||||
size: { control: false },
|
size: { control: false },
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { IconSearch } from '@/ui/icon';
|
import { IconSearch } from '@/ui/icon';
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IconButton,
|
IconButton,
|
||||||
@ -33,7 +34,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof IconButton> = {
|
||||||
args: { Icon: IconSearch },
|
args: { Icon: IconSearch },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
size: { control: false },
|
size: { control: false },
|
||||||
@ -103,7 +104,7 @@ export const Catalog: Story = {
|
|||||||
decorators: [CatalogDecorator],
|
decorators: [CatalogDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PositionCatalog: Story = {
|
export const PositionCatalog: CatalogStory<Story, typeof IconButton> = {
|
||||||
args: { Icon: IconSearch },
|
args: { Icon: IconSearch },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
size: { control: false },
|
size: { control: false },
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { IconCheckbox, IconNotes, IconTimelineEvent } from '@/ui/icon';
|
import { IconCheckbox, IconNotes, IconTimelineEvent } from '@/ui/icon';
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IconButtonAccent,
|
IconButtonAccent,
|
||||||
@ -38,7 +39,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof IconButtonGroup> = {
|
||||||
argTypes: {
|
argTypes: {
|
||||||
size: { control: false },
|
size: { control: false },
|
||||||
variant: { control: false },
|
variant: { control: false },
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { IconSearch } from '@/ui/icon';
|
import { IconSearch } from '@/ui/icon';
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { LightButton, LightButtonAccent } from '../LightButton';
|
import { LightButton, LightButtonAccent } from '../LightButton';
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof LightButton> = {
|
||||||
args: { title: 'Filter', icon: <IconSearch /> },
|
args: { title: 'Filter', icon: <IconSearch /> },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
accent: { control: false },
|
accent: { control: false },
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { IconSearch } from '@/ui/icon';
|
import { IconSearch } from '@/ui/icon';
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
LightIconButton,
|
LightIconButton,
|
||||||
@ -33,7 +34,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof LightIconButton> = {
|
||||||
args: { title: 'Filter', Icon: IconSearch },
|
args: { title: 'Filter', Icon: IconSearch },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
accent: { control: false },
|
accent: { control: false },
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
|
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { Chip, ChipAccent, ChipSize, ChipVariant } from '../Chip';
|
import { Chip, ChipAccent, ChipSize, ChipVariant } from '../Chip';
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof Chip> = {
|
||||||
args: { clickable: true, label: 'Hello' },
|
args: { clickable: true, label: 'Hello' },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
size: { control: false },
|
size: { control: false },
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
|
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AutosizeTextInput,
|
AutosizeTextInput,
|
||||||
@ -23,7 +24,7 @@ export const ButtonVariant: Story = {
|
|||||||
args: { variant: AutosizeTextInputVariant.Button },
|
args: { variant: AutosizeTextInputVariant.Button },
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof AutosizeTextInput> = {
|
||||||
parameters: {
|
parameters: {
|
||||||
catalog: {
|
catalog: {
|
||||||
dimensions: [
|
dimensions: [
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
|
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Checkbox,
|
Checkbox,
|
||||||
@ -29,7 +30,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof Checkbox> = {
|
||||||
args: {},
|
args: {},
|
||||||
argTypes: {
|
argTypes: {
|
||||||
variant: { control: false },
|
variant: { control: false },
|
||||||
@ -52,6 +53,7 @@ export const Catalog: Story = {
|
|||||||
if (state === 'indeterminate') {
|
if (state === 'indeterminate') {
|
||||||
return { indeterminate: true };
|
return { indeterminate: true };
|
||||||
}
|
}
|
||||||
|
return {};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
|
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { LabelPosition, Radio, RadioSize } from '../Radio';
|
import { LabelPosition, Radio, RadioSize } from '../Radio';
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof Radio> = {
|
||||||
args: {
|
args: {
|
||||||
value: 'Radio',
|
value: 'Radio',
|
||||||
},
|
},
|
||||||
@ -52,7 +53,7 @@ export const Catalog: Story = {
|
|||||||
{
|
{
|
||||||
name: 'labelPosition',
|
name: 'labelPosition',
|
||||||
values: Object.values(LabelPosition),
|
values: Object.values(LabelPosition),
|
||||||
props: (labelPosition: string) => ({
|
props: (labelPosition: LabelPosition) => ({
|
||||||
labelPosition,
|
labelPosition,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,12 +1,9 @@
|
|||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
|
|
||||||
import { IconBell } from '@/ui/icon';
|
import { IconBell } from '@/ui/icon';
|
||||||
import {
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
CatalogDecorator,
|
|
||||||
CatalogDimension,
|
|
||||||
CatalogOptions,
|
|
||||||
} from '~/testing/decorators/CatalogDecorator';
|
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { MenuItemAccent } from '../../types/MenuItemAccent';
|
import { MenuItemAccent } from '../../types/MenuItemAccent';
|
||||||
import { MenuItem } from '../MenuItem';
|
import { MenuItem } from '../MenuItem';
|
||||||
@ -33,7 +30,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof MenuItem> = {
|
||||||
args: { ...Default.args },
|
args: { ...Default.args },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
accent: { control: false },
|
accent: { control: false },
|
||||||
@ -98,15 +95,17 @@ export const Catalog: Story = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
] as CatalogDimension[],
|
],
|
||||||
options: {
|
options: {
|
||||||
elementContainer: {
|
elementContainer: {
|
||||||
width: 200,
|
width: 200,
|
||||||
},
|
},
|
||||||
} as CatalogOptions,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
decorators: [CatalogDecorator],
|
decorators: [CatalogDecorator],
|
||||||
|
|||||||
@ -2,12 +2,9 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { Command } from 'cmdk';
|
import { Command } from 'cmdk';
|
||||||
|
|
||||||
import { IconBell } from '@/ui/icon';
|
import { IconBell } from '@/ui/icon';
|
||||||
import {
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
CatalogDecorator,
|
|
||||||
CatalogDimension,
|
|
||||||
CatalogOptions,
|
|
||||||
} from '~/testing/decorators/CatalogDecorator';
|
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { MenuItemCommand } from '../MenuItemCommand';
|
import { MenuItemCommand } from '../MenuItemCommand';
|
||||||
|
|
||||||
@ -39,7 +36,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof MenuItemCommand> = {
|
||||||
args: { LeftIcon: IconBell, text: 'Menu item', command: '⌘1' },
|
args: { LeftIcon: IconBell, text: 'Menu item', command: '⌘1' },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
className: { control: false },
|
className: { control: false },
|
||||||
@ -60,7 +57,7 @@ export const Catalog: Story = {
|
|||||||
{
|
{
|
||||||
name: 'selected',
|
name: 'selected',
|
||||||
values: [true, false],
|
values: [true, false],
|
||||||
props: (selected: boolean) => ({ selected }),
|
props: () => ({}),
|
||||||
labels: (selected: boolean) =>
|
labels: (selected: boolean) =>
|
||||||
selected ? 'Selected' : 'Not selected',
|
selected ? 'Selected' : 'Not selected',
|
||||||
},
|
},
|
||||||
@ -78,12 +75,12 @@ export const Catalog: Story = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
] as CatalogDimension[],
|
],
|
||||||
options: {
|
options: {
|
||||||
elementContainer: {
|
elementContainer: {
|
||||||
width: 200,
|
width: 200,
|
||||||
},
|
},
|
||||||
} as CatalogOptions,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
render: (props) => (
|
render: (props) => (
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {
|
|||||||
CatalogOptions,
|
CatalogOptions,
|
||||||
} from '~/testing/decorators/CatalogDecorator';
|
} from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { MenuItemMultiSelect } from '../MenuItemMultiSelect';
|
import { MenuItemMultiSelect } from '../MenuItemMultiSelect';
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof MenuItemMultiSelect> = {
|
||||||
args: { LeftIcon: IconBell, text: 'Menu item' },
|
args: { LeftIcon: IconBell, text: 'Menu item' },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
className: { control: false },
|
className: { control: false },
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {
|
|||||||
CatalogOptions,
|
CatalogOptions,
|
||||||
} from '~/testing/decorators/CatalogDecorator';
|
} from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { MenuItemNavigate } from '../MenuItemNavigate';
|
import { MenuItemNavigate } from '../MenuItemNavigate';
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof MenuItemNavigate> = {
|
||||||
args: { LeftIcon: IconBell, text: 'Menu item' },
|
args: { LeftIcon: IconBell, text: 'Menu item' },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
className: { control: false },
|
className: { control: false },
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {
|
|||||||
CatalogOptions,
|
CatalogOptions,
|
||||||
} from '~/testing/decorators/CatalogDecorator';
|
} from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { MenuItemSelect } from '../MenuItemSelect';
|
import { MenuItemSelect } from '../MenuItemSelect';
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof MenuItemSelect> = {
|
||||||
args: { LeftIcon: IconBell, text: 'Menu item' },
|
args: { LeftIcon: IconBell, text: 'Menu item' },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
className: { control: false },
|
className: { control: false },
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {
|
|||||||
CatalogOptions,
|
CatalogOptions,
|
||||||
} from '~/testing/decorators/CatalogDecorator';
|
} from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { MenuItemToggle } from '../MenuItemToggle';
|
import { MenuItemToggle } from '../MenuItemToggle';
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof MenuItemToggle> = {
|
||||||
args: { LeftIcon: IconBell, text: 'Menu item' },
|
args: { LeftIcon: IconBell, text: 'Menu item' },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
className: { control: false },
|
className: { control: false },
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { Decorator, Meta, StoryObj } from '@storybook/react';
|
|||||||
import { IconSearch, IconSettings } from '@/ui/icon';
|
import { IconSearch, IconSettings } from '@/ui/icon';
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
|
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import NavItem from '../components/NavItem';
|
import NavItem from '../components/NavItem';
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator, ComponentWithRouterDecorator],
|
decorators: [ComponentDecorator, ComponentWithRouterDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof NavItem> = {
|
||||||
args: Default.args,
|
args: Default.args,
|
||||||
decorators: [
|
decorators: [
|
||||||
ComponentDecorator,
|
ComponentDecorator,
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
|
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { CircularProgressBar } from '../CircularProgressBar';
|
import { CircularProgressBar } from '../CircularProgressBar';
|
||||||
|
|
||||||
@ -24,11 +25,8 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog = {
|
export const Catalog: CatalogStory<Story, typeof CircularProgressBar> = {
|
||||||
argTypes: {
|
argTypes: {},
|
||||||
strokeWidth: { control: false },
|
|
||||||
segmentColor: { control: false },
|
|
||||||
},
|
|
||||||
parameters: {
|
parameters: {
|
||||||
catalog: {
|
catalog: {
|
||||||
dimensions: [
|
dimensions: [
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
|
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { ProgressBar } from '../ProgressBar';
|
import { ProgressBar } from '../ProgressBar';
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog = {
|
export const Catalog: CatalogStory<Story, typeof ProgressBar> = {
|
||||||
args: {
|
args: {
|
||||||
...args,
|
...args,
|
||||||
},
|
},
|
||||||
@ -40,7 +41,7 @@ export const Catalog = {
|
|||||||
{
|
{
|
||||||
name: 'animation',
|
name: 'animation',
|
||||||
values: [true, false],
|
values: [true, false],
|
||||||
props: (autoStart: string) => ({ autoStart }),
|
props: (autoStart: string) => ({ autoStart: Boolean(autoStart) }),
|
||||||
labels: (autoStart: string) => `AutoStart: ${autoStart}`,
|
labels: (autoStart: string) => `AutoStart: ${autoStart}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
import { IconCheckbox } from '@/ui/icon';
|
import { IconCheckbox } from '@/ui/icon';
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { Tab } from '../Tab';
|
import { Tab } from '../Tab';
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof Tab> = {
|
||||||
args: { title: 'Tab title', Icon: IconCheckbox },
|
args: { title: 'Tab title', Icon: IconCheckbox },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
active: { control: false },
|
active: { control: false },
|
||||||
|
|||||||
@ -2,8 +2,10 @@ import { expect } from '@storybook/jest';
|
|||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import { userEvent } from '@storybook/testing-library';
|
import { userEvent } from '@storybook/testing-library';
|
||||||
|
|
||||||
|
import { ThemeColor } from '@/ui/theme/constants/colors';
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { Tag, TagColor } from '../Tag';
|
import { Tag, TagColor } from '../Tag';
|
||||||
|
|
||||||
@ -32,7 +34,7 @@ export const Default: Story = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof Tag> = {
|
||||||
args: { text: 'Urgent' },
|
args: { text: 'Urgent' },
|
||||||
argTypes: {
|
argTypes: {
|
||||||
color: { control: false },
|
color: { control: false },
|
||||||
@ -54,7 +56,7 @@ export const Catalog: Story = {
|
|||||||
'yellow',
|
'yellow',
|
||||||
'gray',
|
'gray',
|
||||||
] satisfies TagColor[],
|
] satisfies TagColor[],
|
||||||
props: (color: TagColor) => ({ color }),
|
props: (color: ThemeColor) => ({ color }),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
|
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { AppTooltip as Tooltip, TooltipPosition } from '../AppTooltip';
|
import { AppTooltip as Tooltip, TooltipPosition } from '../AppTooltip';
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ export const Default: Story = {
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof Tooltip> = {
|
||||||
args: { isOpen: true, content: 'Tooltip Test' },
|
args: { isOpen: true, content: 'Tooltip Test' },
|
||||||
play: async ({ canvasElement }) => {
|
play: async ({ canvasElement }) => {
|
||||||
Object.values(TooltipPosition).forEach((position) => {
|
Object.values(TooltipPosition).forEach((position) => {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
|
|
||||||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { CatalogStory } from '~/testing/types';
|
||||||
|
|
||||||
import { H1Title, H1TitleFontColor } from '../H1Title';
|
import { H1Title, H1TitleFontColor } from '../H1Title';
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ export const Default: Story = {
|
|||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Catalog: Story = {
|
export const Catalog: CatalogStory<Story, typeof H1Title> = {
|
||||||
args,
|
args,
|
||||||
decorators: [CatalogDecorator],
|
decorators: [CatalogDecorator],
|
||||||
parameters: {
|
parameters: {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { ComponentProps, JSX } from 'react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { Decorator } from '@storybook/react';
|
import { Decorator } from '@storybook/react';
|
||||||
|
|
||||||
@ -74,10 +75,12 @@ const emptyDimension = {
|
|||||||
props: () => ({}),
|
props: () => ({}),
|
||||||
} as CatalogDimension;
|
} as CatalogDimension;
|
||||||
|
|
||||||
export type CatalogDimension = {
|
export type CatalogDimension<
|
||||||
|
ComponentType extends React.ElementType = () => JSX.Element,
|
||||||
|
> = {
|
||||||
name: string;
|
name: string;
|
||||||
values: any[];
|
values: any[];
|
||||||
props: (value: any) => Record<string, any>;
|
props: (value: any) => Partial<ComponentProps<ComponentType>>;
|
||||||
labels?: (value: any) => string;
|
labels?: (value: any) => string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
24
front/src/testing/types.ts
Normal file
24
front/src/testing/types.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { ElementType } from 'react';
|
||||||
|
import { StoryObj } from '@storybook/react';
|
||||||
|
|
||||||
|
import type {
|
||||||
|
CatalogDimension,
|
||||||
|
CatalogOptions,
|
||||||
|
} from './decorators/CatalogDecorator';
|
||||||
|
|
||||||
|
export type CatalogStory<
|
||||||
|
StoryType extends StoryObj<ComponentType>,
|
||||||
|
ComponentType extends ElementType,
|
||||||
|
> = {
|
||||||
|
args?: StoryType['args'];
|
||||||
|
argTypes?: StoryType['argTypes'];
|
||||||
|
play?: StoryType['play'];
|
||||||
|
render?: StoryType['render'];
|
||||||
|
parameters: StoryType['parameters'] & {
|
||||||
|
catalog: {
|
||||||
|
dimensions: CatalogDimension<ComponentType>[];
|
||||||
|
options?: CatalogOptions;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
decorators: StoryType['decorators'];
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user