Skip to content

Commit 29702e0

Browse files
authored
chore(Divider): update story (#1235)
1 parent e89596f commit 29702e0

File tree

7 files changed

+62
-41
lines changed

7 files changed

+62
-41
lines changed
-32.8 KB
Loading
-69.3 KB
Loading
-283 KB
Loading
-595 KB
Loading
Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,47 @@
11
import {Meta, StoryFn} from '@storybook/react';
22

3-
import {yfmTransform} from '../../../../.storybook/utils';
4-
import {Title} from '../../../components';
5-
import {BasicCardProps, DividerSize} from '../../../models';
6-
import BasicCard from '../../BasicCard/BasicCard';
3+
import {DividerProps} from '../../../models';
74
import Divider from '../Divider';
85

96
import data from './data.json';
7+
import './styles.scss';
108

119
export default {
12-
component: BasicCard,
10+
component: Divider,
1311
title: 'Components/Divider',
1412
} as Meta;
1513

16-
const getSizeTitle = (size: string) => data.sizes.title.replace('{{size}}', size);
17-
const DefaultTemplate: StoryFn<BasicCardProps> = (args) => (
14+
const DefaultTemplate: StoryFn<DividerProps> = (args) => (
1815
<div>
19-
<Title title={data.default.title} />
20-
<div style={{maxWidth: '400px', marginTop: '10px'}}>
21-
<BasicCard {...args} />
22-
<Divider />
23-
<BasicCard {...args} />
16+
<div className="divider-story_indent">
17+
<Divider {...args} />
2418
</div>
2519
</div>
2620
);
2721

28-
const SizesTemplate: StoryFn<BasicCardProps> = (args) => (
22+
const SizesTemplate: StoryFn<Record<number, DividerProps>> = (args) => (
2923
<div>
30-
{data.sizes.items.map((item) => (
31-
<div key={item}>
32-
<Title title={getSizeTitle(item.toUpperCase())} />
33-
<div style={{maxWidth: '400px', marginTop: '10px', marginBottom: '24px'}}>
34-
<BasicCard {...args} />
35-
<Divider size={item as DividerSize} />
36-
<BasicCard {...args} />
24+
{Object.values(args).map((arg, index) => (
25+
<div
26+
key={index}
27+
style={{display: 'flex', marginBottom: '50px', alignItems: 'flex-start'}}
28+
>
29+
<div className="divider-story_indent" style={{width: '90%'}}>
30+
<Divider {...arg} />
3731
</div>
32+
<div style={{alignSelf: 'center', marginLeft: '10px'}}>{arg.size}</div>
3833
</div>
3934
))}
4035
</div>
4136
);
4237

4338
export const Default = DefaultTemplate.bind({});
44-
export const Sizes = SizesTemplate.bind({});
45-
46-
const DefaultArgs = {
47-
...data.default.content,
48-
text: yfmTransform(data.default.content.text),
39+
export const Sizes = SizesTemplate.bind([]);
40+
41+
Default.args = data.default as DividerProps;
42+
Sizes.args = data.sizes as DividerProps[];
43+
Sizes.parameters = {
44+
controls: {
45+
include: Object.keys(data.sizes),
46+
},
4947
};
50-
51-
Default.args = {
52-
...data.default.content,
53-
...DefaultArgs,
54-
} as BasicCardProps;
55-
Sizes.args = DefaultArgs as BasicCardProps;
Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
11
{
22
"default": {
3-
"title": "Default divider between cards, size M",
4-
"content": {
5-
"url": "https://example.com",
6-
"title": "Lorem ipsum",
7-
"text": "**Ut enim ad minim veniam** [quis nostrud](https://example.com) exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
8-
}
3+
"size": "s"
94
},
10-
"sizes": {
11-
"title": "Divider between cards, size {{size}}",
12-
"items": ["0", "xxs", "xs", "s", "m", "l", "xl", "xxl", "xxxl"]
13-
}
5+
"sizes": [
6+
{
7+
"size": "0"
8+
},
9+
{
10+
"size": "xxs"
11+
},
12+
{
13+
"size": "xs"
14+
},
15+
{
16+
"size": "s"
17+
},
18+
{
19+
"size": "m"
20+
},
21+
{
22+
"size": "l"
23+
},
24+
{
25+
"size": "xl"
26+
},
27+
{
28+
"size": "xxl"
29+
},
30+
{
31+
"size": "xxxl"
32+
}
33+
]
1434
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.divider-story_indent {
2+
background: repeating-linear-gradient(
3+
135deg,
4+
rgba(255, 0, 61, 0.05),
5+
rgba(255, 0, 61, 0.05) 10px,
6+
rgba(255, 0, 61, 0.1) 10px,
7+
rgba(255, 0, 61, 0.1) 20px
8+
);
9+
}

0 commit comments

Comments
 (0)