Skip to content

Commit d77f5cb

Browse files
authored
chore(FilterBlock): update storybook (#1329)
1 parent c911111 commit d77f5cb

14 files changed

+196
-82
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

src/blocks/FilterBlock/__stories__/FilterBlock.mdx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,26 @@ import * as FilterBlockStories from './FilterBlock.stories.tsx';
99

1010
`type: "filter-block"`
1111

12-
`title?: Title | string` — Title.
13-
14-
`description?: string` — Text.
15-
1612
`tags: []` - Tags by which content can be filtered.
1713

18-
`tagButtonSize: 's' | 'm' | 'l' | 'xl'` - Size of filter tags.
19-
20-
`allTag: boolean | string` - Specifies whether to show the 'All' tag. If the value is a non-falsy string, the block uses the value as label for the `All` tag.
21-
2214
`items:` — Items, the block displays.
2315

2416
- `tags: string[]` - tags assigned to the card.
2517

2618
- `card: [SubBlock]` - card to show. More about SubBlocks [here](?path=/docs/documentation-sub-blocks--docs)
2719

20+
`title?: TitleItemProps | string` — Title.
21+
22+
`description?: string` — Text.
23+
24+
`tagButtonSize?: 's' | 'm' | 'l' | 'xl'` - Size of filter tags.
25+
26+
`allTag?: boolean | string` - Specifies whether to show the 'All' tag. If the value is a non-falsy string, the block uses the value as label for the `All` tag.
27+
2828
`centered?: boolean` - Specifies whether the header and the tab panel are centered.
2929

3030
`animated?: boolean` — Enables/disables animation for the block (enabled by default).
3131

32-
`colSizes?: Object` — more info [here](?path=/docs/documentation-types--docs#colsizes).
32+
`colSizes?: GridColumnSizesType` — Grid column sizes configuration, more info [here](?path=/docs/documentation-types--docs#colsizes).
33+
3334
</StoryTemplate>
Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,64 @@
11
import {Meta, StoryFn} from '@storybook/react';
22

3-
import {yfmTransform} from '../../../../.storybook/utils';
3+
import {blockTransform} from '../../../../.storybook/utils';
44
import {PageConstructor} from '../../../containers/PageConstructor';
5-
import {
6-
FilterBlockModel,
7-
FilterBlockProps,
8-
FilterItem,
9-
FilterTag,
10-
LayoutItemModel,
11-
LayoutItemProps,
12-
} from '../../../models';
5+
import {FilterBlockModel} from '../../../models';
136
import FilterBlock from '../FilterBlock';
147

158
import data from './data.json';
169

1710
export default {
18-
title: 'Blocks/Filter Block',
11+
title: 'Blocks/FilterBlock',
1912
component: FilterBlock,
20-
} as Meta;
21-
22-
const createItemList: (
23-
count: number,
24-
shared: LayoutItemProps,
25-
tagList: FilterTag[],
26-
) => FilterItem[] = (count, shared, tagList) =>
27-
Array.from({length: count}, (_, index) => ({
28-
tags: [tagList[index % tagList.length].id],
29-
card: {
30-
...shared,
31-
content: {
32-
title: shared.content.title
33-
? `${shared.content.title}&nbsp;${index + 1}`
34-
: `${index + 1}`,
13+
argTypes: {
14+
allTag: {
15+
table: {
16+
defaultValue: {
17+
summary: 'false',
18+
},
3519
},
36-
} as LayoutItemModel,
37-
}));
38-
39-
const createArgs = (overrides: Partial<FilterBlockProps>) =>
40-
({
41-
type: 'filter-block',
42-
title: data.default.content.title,
43-
description: yfmTransform(data.default.content.description),
44-
tags: data.default.filters,
45-
items: createItemList(6, data.default.card, data.default.filters),
46-
...overrides,
47-
}) as FilterBlockProps;
20+
},
21+
tagButtonSize: {
22+
table: {
23+
defaultValue: {
24+
summary: '"l"',
25+
},
26+
},
27+
},
28+
centered: {
29+
table: {
30+
defaultValue: {
31+
summary: 'false',
32+
},
33+
},
34+
},
35+
animated: {
36+
table: {
37+
defaultValue: {
38+
summary: 'true',
39+
},
40+
},
41+
},
42+
colSizes: {
43+
table: {
44+
defaultValue: {
45+
summary: '{all: 12, sm: 6, md: 4};',
46+
},
47+
},
48+
},
49+
},
50+
} as Meta;
4851

4952
const DefaultTemplate: StoryFn<FilterBlockModel> = (args) => (
50-
<PageConstructor content={{blocks: [args]}} />
53+
<PageConstructor content={{blocks: [blockTransform(args)]}} />
5154
);
5255

5356
export const Default = DefaultTemplate.bind({});
54-
Default.args = createArgs({allTag: false});
55-
56-
export const WithDefaultAllTag = DefaultTemplate.bind({});
57-
WithDefaultAllTag.args = createArgs({allTag: true});
58-
57+
export const WithAllTag = DefaultTemplate.bind({});
5958
export const WithCustomAllTag = DefaultTemplate.bind({});
60-
WithCustomAllTag.args = createArgs({allTag: 'Custom All Tag Label'});
59+
export const Centered = DefaultTemplate.bind({});
60+
61+
Default.args = data.default as FilterBlockModel;
62+
WithAllTag.args = {...data.default, allTag: true} as FilterBlockModel;
63+
WithCustomAllTag.args = {...data.default, allTag: 'Custom All Tag Name'} as FilterBlockModel;
64+
Centered.args = {...data.default, centered: true} as FilterBlockModel;

0 commit comments

Comments
 (0)