11import { Meta , StoryFn } from '@storybook/react' ;
22
3- import { transformOptionalTitle , yfmTransform } from '../../../../.storybook/utils' ;
4- import { PageConstructor } from '../../../containers/PageConstructor/PageConstructor' ;
3+ import { blockTransform } from '../../../../.storybook/utils' ;
54import {
65 ExtendedFeaturesBlockModel ,
76 ExtendedFeaturesItem ,
87 ExtendedFeaturesProps ,
98} from '../../../models' ;
10- import ExtendedFeatures from '../ExtendedFeatures' ;
9+ import ExtendedFeatures , { ExtendedFeaturesBlock } from '../ExtendedFeatures' ;
1110
1211import data from './data.json' ;
1312
@@ -23,72 +22,39 @@ export default {
2322 } ,
2423} as Meta ;
2524
26- const DefaultTemplate : StoryFn < ExtendedFeaturesBlockModel > = ( args ) => (
27- < PageConstructor content = { { blocks : [ args ] } } />
28- ) ;
29-
30- const extendedFeaturesItems = ( items : ExtendedFeaturesItem [ ] ) => {
31- return items . map ( ( item ) => ( {
32- ...item ,
33- title : transformOptionalTitle ( item . title ) ,
34- list : item . list ?. map ( ( listItem ) => ( {
35- ...listItem ,
36- title : transformOptionalTitle ( listItem . title ) ,
37- text : listItem ?. text && yfmTransform ( listItem . text ) ,
38- } ) ) ,
39- text : item . text && yfmTransform ( item . text ) ,
40- additionalInfo : item . additionalInfo && yfmTransform ( item . additionalInfo ) ,
41- } ) ) ;
25+ const DefaultTemplate : StoryFn < ExtendedFeaturesBlockModel > = ( args ) => {
26+ const transformedArgs = blockTransform ( args ) as ExtendedFeaturesProps ;
27+ return (
28+ < div style = { { padding : '64px' } } >
29+ < ExtendedFeaturesBlock { ...transformedArgs } />
30+ </ div >
31+ ) ;
4232} ;
4333
44- const ColSizesTemplate : StoryFn < ExtendedFeaturesBlockModel > = ( args ) => (
45- < PageConstructor
46- content = { {
47- blocks : [
48- {
49- ...args ,
50- ...data . colSizes . four ,
51- title : transformOptionalTitle ( data . colSizes . four . title ) ,
52- description : yfmTransform ( data . colSizes . four . description ) ,
53- items : extendedFeaturesItems (
54- data . colSizes . four . items as ExtendedFeaturesItem [ ] ,
55- ) ,
56- } ,
57- {
58- ...args ,
59- ...data . colSizes . three ,
60- title : transformOptionalTitle ( data . colSizes . three . title ) ,
61- description : yfmTransform ( data . colSizes . three . description ) ,
62- } ,
63- {
64- ...args ,
65- ...data . colSizes . two ,
66- title : transformOptionalTitle ( data . colSizes . two . title ) ,
67- description : yfmTransform ( data . colSizes . two . description ) ,
68- items : extendedFeaturesItems ( data . colSizes . two . items as ExtendedFeaturesItem [ ] ) ,
69- } ,
70- ] ,
71- } }
72- />
73- ) ;
34+ const ColSizesTemplate : StoryFn < ExtendedFeaturesBlockModel > = ( args ) => {
35+ const transformedArgs = blockTransform ( args ) as ExtendedFeaturesProps ;
36+ return (
37+ < div style = { { padding : '64px' } } >
38+ < ExtendedFeaturesBlock { ...transformedArgs } />
39+ </ div >
40+ ) ;
41+ } ;
7442
7543export const Default = DefaultTemplate . bind ( { } ) ;
7644export const WithLabel = DefaultTemplate . bind ( { } ) ;
7745export const ColSizes = ColSizesTemplate . bind ( { } ) ;
7846
7947const DefaultArgs = {
8048 ...data . default . content ,
81- title : transformOptionalTitle ( data . default . content . title ) ,
82- description : yfmTransform ( data . default . content . description ) ,
83- items : extendedFeaturesItems ( data . default . content . items as ExtendedFeaturesItem [ ] ) ,
49+ items : data . default . content . items ,
8450} ;
8551
8652Default . args = { ...DefaultArgs } as ExtendedFeaturesProps ;
8753WithLabel . args = {
8854 ...DefaultArgs ,
89- items : extendedFeaturesItems ( data . withLabel . content . items as ExtendedFeaturesItem [ ] ) ,
55+ items : data . withLabel . content . items as ExtendedFeaturesItem [ ] ,
9056} as ExtendedFeaturesProps ;
9157ColSizes . args = {
9258 ...data . default . content ,
93- items : extendedFeaturesItems ( data . default . content . items as ExtendedFeaturesItem [ ] ) ,
59+ items : data . default . content . items as ExtendedFeaturesItem [ ] ,
9460} as ExtendedFeaturesProps ;
0 commit comments