@@ -2,8 +2,8 @@ import * as React from 'react';
22
33import { Meta , StoryFn } from '@storybook/react' ;
44
5- import { yfmTransform } from '../../../../.storybook/utils ' ;
6- import { PageConstructor } from '../../../containers/PageConstructor/PageConstructor ' ;
5+ import { IconsBlock } from '../..' ;
6+ import { blockTransform } from '../../../../.storybook/utils ' ;
77import { IconsBlockModel , IconsBlockProps } from '../../../models' ;
88import Icons from '../Icons' ;
99
@@ -15,60 +15,91 @@ export default {
1515} as Meta ;
1616
1717const DefaultTemplate : StoryFn < IconsBlockModel > = ( args ) => (
18- < PageConstructor content = { { blocks : [ args ] } } />
18+ < div style = { { padding : '64px' } } >
19+ < IconsBlock { ...( blockTransform ( args ) as IconsBlockProps ) } />
20+ </ div >
1921) ;
2022
21- const WithDescriptionTemplate : StoryFn < IconsBlockModel > = ( args ) => (
22- < PageConstructor content = { { blocks : [ args ] } } />
23- ) ;
24-
25- const SizeTemplate : StoryFn < IconsBlockModel > = ( args ) => (
23+ const SizeTemplate : StoryFn < Record < string , IconsBlockModel > > = ( args ) => (
2624 < React . Fragment >
27- < DefaultTemplate title = "Size S" { ...args } size = "s" />
28- < DefaultTemplate title = "Size M" { ...args } size = "m" />
29- < DefaultTemplate title = "Size L" { ...args } size = "l" />
25+ { Object . entries ( args )
26+ . map ( ( [ key , item ] ) => {
27+ const transformed = blockTransform ( item ) as IconsBlockProps ;
28+ return (
29+ < div key = { key } style = { { padding : '64px' } } >
30+ < IconsBlock { ...transformed } />
31+ </ div >
32+ ) ;
33+ } )
34+ . filter ( Boolean ) }
3035 </ React . Fragment >
3136) ;
3237
33- const ColSizeTemplate : StoryFn < IconsBlockModel > = ( args ) => (
34- < React . Fragment >
35- < PageConstructor
36- content = { {
37- blocks : [
38- {
39- ...args ,
40- title : 'ColSize 12' ,
41- } ,
42- {
43- ...args ,
44- title : 'ColSize 8' ,
45- colSizes : { all : 8 } ,
46- } ,
47- {
48- ...args ,
49- title : 'ColSize 4' ,
50- colSizes : { all : 4 } ,
51- } ,
52- ] ,
53- } }
54- />
55- </ React . Fragment >
38+ const ColSizeTemplate : StoryFn < Record < string , IconsBlockModel > > = ( args ) => (
39+ < div style = { { padding : '64px' } } >
40+ { Object . entries ( args )
41+ . map ( ( [ key , item ] ) => {
42+ const transformed = blockTransform ( item ) as IconsBlockProps ;
43+ return < IconsBlock key = { key } { ...transformed } /> ;
44+ } )
45+ . filter ( Boolean ) }
46+ </ div >
5647) ;
5748
58- export const Default = DefaultTemplate . bind ( [ ] ) ;
59- export const Size = SizeTemplate . bind ( [ ] ) ;
60- export const WithText = WithDescriptionTemplate . bind ( { } ) ;
49+ export const Default = DefaultTemplate . bind ( { } ) ;
50+ export const Size = SizeTemplate . bind ( { } ) ;
51+ export const WithText = DefaultTemplate . bind ( { } ) ;
6152export const HeaderColSize = ColSizeTemplate . bind ( { } ) ;
6253
63- const transformedText = yfmTransform ( data . withDescription . content . description ) ;
54+ Default . args = data . default . content as IconsBlockModel ;
55+
56+ WithText . args = data . withDescription . content as IconsBlockModel ;
57+
58+ const SIZES : Record < string , IconsBlockModel > = {
59+ size_s : {
60+ ...data . size . content ,
61+ title : 'Size S' ,
62+ size : 's' ,
63+ } as IconsBlockModel ,
64+ size_m : {
65+ ...data . size . content ,
66+ title : 'Size M' ,
67+ size : 'm' ,
68+ } as IconsBlockModel ,
69+ size_l : {
70+ ...data . size . content ,
71+ title : 'Size L' ,
72+ size : 'l' ,
73+ } as IconsBlockModel ,
74+ } ;
75+
76+ Size . args = SIZES ;
77+ Size . parameters = {
78+ controls : {
79+ include : Object . keys ( SIZES ) ,
80+ } ,
81+ } ;
82+
83+ const COL_SIZES : Record < string , IconsBlockModel > = {
84+ col_12 : {
85+ ...data . withDescription . content ,
86+ title : 'ColSize 12' ,
87+ } as IconsBlockModel ,
88+ col_8 : {
89+ ...data . withDescription . content ,
90+ title : 'ColSize 8' ,
91+ colSizes : { all : 8 } ,
92+ } as IconsBlockModel ,
93+ col_4 : {
94+ ...data . withDescription . content ,
95+ title : 'ColSize 4' ,
96+ colSizes : { all : 4 } ,
97+ } as IconsBlockModel ,
98+ } ;
6499
65- Default . args = data . default . content as IconsBlockProps ;
66- Size . args = data . size . content as Omit < IconsBlockProps , 'size' > ;
67- WithText . args = {
68- ...data . withDescription . content ,
69- description : transformedText ,
70- } as IconsBlockProps ;
71- HeaderColSize . args = {
72- ...data . withDescription . content ,
73- description : transformedText ,
74- } as IconsBlockProps ;
100+ HeaderColSize . args = COL_SIZES ;
101+ HeaderColSize . parameters = {
102+ controls : {
103+ include : Object . keys ( COL_SIZES ) ,
104+ } ,
105+ } ;
0 commit comments