|
1 | 1 | import {Meta, StoryFn} from '@storybook/react'; |
2 | 2 |
|
3 | | -import {yfmTransform} from '../../../../.storybook/utils'; |
| 3 | +import {blockTransform} from '../../../../.storybook/utils'; |
4 | 4 | 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'; |
13 | 6 | import FilterBlock from '../FilterBlock'; |
14 | 7 |
|
15 | 8 | import data from './data.json'; |
16 | 9 |
|
17 | 10 | export default { |
18 | | - title: 'Blocks/Filter Block', |
| 11 | + title: 'Blocks/FilterBlock', |
19 | 12 | 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} ${index + 1}` |
34 | | - : `${index + 1}`, |
| 13 | + argTypes: { |
| 14 | + allTag: { |
| 15 | + table: { |
| 16 | + defaultValue: { |
| 17 | + summary: 'false', |
| 18 | + }, |
35 | 19 | }, |
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; |
48 | 51 |
|
49 | 52 | const DefaultTemplate: StoryFn<FilterBlockModel> = (args) => ( |
50 | | - <PageConstructor content={{blocks: [args]}} /> |
| 53 | + <PageConstructor content={{blocks: [blockTransform(args)]}} /> |
51 | 54 | ); |
52 | 55 |
|
53 | 56 | 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({}); |
59 | 58 | 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