Skip to content

Commit

Permalink
docs: refactor Icon stories
Browse files Browse the repository at this point in the history
  • Loading branch information
amje committed Oct 16, 2023
1 parent 4a849f9 commit a857f37
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/components/Icon/__stories__/Docs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {Meta, Markdown} from '@storybook/addon-docs';
import * as Stories from './Icon.stories';
import Readme from '../README.md?raw';

<Meta of={Stories} />

<Markdown>{Readme}</Markdown>
36 changes: 29 additions & 7 deletions src/components/Icon/__stories__/Icon.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
import React from 'react';

import {Gear} from '@gravity-ui/icons';
import type {Meta, StoryFn} from '@storybook/react';
import {Envelope, Gear, Rocket} from '@gravity-ui/icons';
import type {Meta, StoryObj} from '@storybook/react';

import {Showcase} from '../../../demo/Showcase';
import {Icon} from '../Icon';
import type {IconProps} from '../Icon';

const icons = [Gear, Envelope, Rocket].reduce((acc, fn) => {
acc[fn.name] = fn;

Check warning on line 10 in src/components/Icon/__stories__/Icon.stories.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

Assignment to property of function parameter 'acc'
return acc;
}, {} as {[key: string]: React.FunctionComponent});

export default {
title: 'Components/Data Display/Icon',
component: Icon,
argTypes: {
data: {
options: Object.keys(icons),
mapping: icons,
},
},
args: {
data: 'Gear',
},
} as Meta;

const DefaultTemplate: StoryFn<IconProps> = (args) => <Icon {...args} />;
export const Default = DefaultTemplate.bind({});
Default.args = {
data: Gear,
type Story = StoryObj<typeof Icon>;

export const Default: Story = {};

export const Size: Story = {
render: (args) => (
<Showcase>
<Icon {...args} size={16} />
<Icon {...args} size={24} />
<Icon {...args} size={36} />
</Showcase>
),
};

0 comments on commit a857f37

Please sign in to comment.