|
1 | | -import { storiesOf } from '@storybook/react' |
| 1 | +import { Story, Meta } from '@storybook/react/types-6-0' |
2 | 2 | import React from 'react' |
3 | 3 |
|
4 | | -import { Breadcrumb, BreadcrumbItem } from '../src' |
| 4 | +import { Breadcrumb, BreadcrumbItem, BreadcrumbProps } from '../src' |
5 | 5 |
|
6 | | -storiesOf('Breadcrumbs', module) |
7 | | - .addParameters({ |
8 | | - info: { |
9 | | - inline: true, |
| 6 | +export default { |
| 7 | + title: 'Breadcrumb', |
| 8 | + component: Breadcrumb, |
| 9 | + argTypes: { |
| 10 | + children: { |
| 11 | + control: 'text', |
10 | 12 | }, |
11 | | - }) |
12 | | - .addDecorator((storyFn) => <div style={{ textAlign: 'center' }}>{storyFn()}</div>) |
13 | | - .add('Breadcrumb', () => ( |
14 | | - <Breadcrumb> |
15 | | - <BreadcrumbItem active>Item 1</BreadcrumbItem> |
16 | | - <BreadcrumbItem>Item 2</BreadcrumbItem> |
17 | | - </Breadcrumb> |
18 | | - )) |
19 | | - .add('Breadcrumb Items with active prop.', () => ( |
20 | | - <Breadcrumb> |
21 | | - <BreadcrumbItem active>Span Item</BreadcrumbItem> |
22 | | - </Breadcrumb> |
23 | | - )) |
24 | | - .add('Breadcrumb item can have custom link in child', () => ( |
25 | | - <Breadcrumb> |
26 | | - <BreadcrumbItem active> |
27 | | - <a href="https://example.com">Custom link item</a> |
28 | | - </BreadcrumbItem> |
29 | | - </Breadcrumb> |
30 | | - )) |
31 | | - .add('Breadcrumb can use custom style', () => ( |
32 | | - <Breadcrumb style={{ padding: 10, background: 'cyan' }}> |
33 | | - <BreadcrumbItem active style={{ color: 'blue', fontStyle: 'italic' }}> |
34 | | - Item 1 |
35 | | - </BreadcrumbItem> |
36 | | - <BreadcrumbItem style={{ background: 'yellow' }}>Item 2</BreadcrumbItem> |
37 | | - </Breadcrumb> |
38 | | - )) |
39 | | - .add('Breadcrumb can use custom class', () => ( |
40 | | - <Breadcrumb className="customClass"> |
41 | | - <BreadcrumbItem active className="customClass2"> |
42 | | - Custom Class |
43 | | - </BreadcrumbItem> |
44 | | - </Breadcrumb> |
45 | | - )) |
| 13 | + }, |
| 14 | + decorators: [], |
| 15 | +} as Meta |
| 16 | +// your templates and stories |
| 17 | + |
| 18 | +/** |
| 19 | + * it displays a simple breadcrum component |
| 20 | + * with two items and the first one is active |
| 21 | + */ |
| 22 | +const MultiItem: Story<BreadcrumbProps> = (args) => ( |
| 23 | + <Breadcrumb {...args}> |
| 24 | + <BreadcrumbItem active>Item 1</BreadcrumbItem> |
| 25 | + <BreadcrumbItem>Item 2</BreadcrumbItem> |
| 26 | + </Breadcrumb> |
| 27 | +) |
| 28 | +export const Main = MultiItem.bind({}) |
| 29 | + |
| 30 | +/** |
| 31 | + * simple breadcrumb story with a single item active |
| 32 | + */ |
| 33 | +const SingleActive: Story<BreadcrumbProps> = (args) => ( |
| 34 | + <Breadcrumb {...args}> |
| 35 | + <BreadcrumbItem active>Item 1</BreadcrumbItem> |
| 36 | + </Breadcrumb> |
| 37 | +) |
| 38 | +export const SingleActiveStory = SingleActive.bind({}) |
| 39 | + |
| 40 | +/** |
| 41 | + * story with the custom link on the single active item |
| 42 | + */ |
| 43 | +const SingleActiveCustomLink: Story<BreadcrumbProps> = (args) => ( |
| 44 | + <Breadcrumb {...args}> |
| 45 | + <BreadcrumbItem active> |
| 46 | + <a href="https://example.com">Custom link item</a> |
| 47 | + </BreadcrumbItem> |
| 48 | + </Breadcrumb> |
| 49 | +) |
| 50 | +export const SingleActiveCustomLinkSrory = SingleActiveCustomLink.bind({}) |
| 51 | + |
| 52 | +/** |
| 53 | + * story with the custom style on both the items and the parent |
| 54 | + */ |
| 55 | +const SingleActiveCustomStyle: Story<BreadcrumbProps> = (args) => ( |
| 56 | + <Breadcrumb {...args}> |
| 57 | + <BreadcrumbItem active style={{ color: 'blue', fontStyle: 'italic' }}> |
| 58 | + Item 1 |
| 59 | + </BreadcrumbItem> |
| 60 | + <BreadcrumbItem style={{ background: 'yellow' }}>Item 2</BreadcrumbItem> |
| 61 | + </Breadcrumb> |
| 62 | +) |
| 63 | +export const SingleActiveCustomStyleStory = SingleActiveCustomStyle.bind({}) |
| 64 | +SingleActiveCustomStyleStory.args = { |
| 65 | + style: { padding: 10, background: 'cyan' }, |
| 66 | +} |
| 67 | + |
| 68 | +/** |
| 69 | + * story with the custom style on the single item and the parent |
| 70 | + */ |
| 71 | +const SingleActiveCustomClass: Story<BreadcrumbProps> = (args) => ( |
| 72 | + <Breadcrumb {...args}> |
| 73 | + <BreadcrumbItem active className="customClass2"> |
| 74 | + Custom Class |
| 75 | + </BreadcrumbItem> |
| 76 | + </Breadcrumb> |
| 77 | +) |
| 78 | +export const SingleActiveCustomClassStory = SingleActiveCustomClass.bind({}) |
| 79 | +SingleActiveCustomClassStory.args = { |
| 80 | + className: 'customClass', |
| 81 | +} |
0 commit comments