@@ -2,51 +2,52 @@ import * as React from 'react';
22
33import { Meta , StoryFn } from '@storybook/react' ;
44
5- import { Col , Row } from '../../../grid' ;
6- import { LinkProps } from '../../../models' ;
5+ import { Col , GridAlignItems , Row } from '../../../grid' ;
76import Link , { LinkFullProps } from '../Link' ;
87
98import data from './data.json' ;
109
11- const getSizesTitle = ( size : string ) => data . themesSizes . title . replace ( '{{size}}' , size ) ;
12-
1310export default {
1411 component : Link ,
1512 title : 'Components/Links and buttons/Link' ,
1613} as Meta ;
1714
15+ const THEMES_SIZES = [ 'normal' , 'underline' , 'back' , 'file-link' ] . map ( ( theme ) =>
16+ [ 's' , 'm' , 'l' ] . map ( ( textSize ) => ( {
17+ theme,
18+ textSize,
19+ ...data . themesSizes ,
20+ } ) ) ,
21+ ) ;
22+
1823const DefaultTemplate : StoryFn < LinkFullProps > = ( args ) => < Link { ...args } /> ;
1924const DarkTemplate : StoryFn < LinkFullProps > = ( args ) => (
2025 < section style = { { backgroundColor : '#7ccea0' , display : 'inline-block' , padding : '0 16px 16px' } } >
2126 < Link { ...args } />
2227 </ section >
2328) ;
24- const SizesTemplate : StoryFn < LinkFullProps > = ( args ) => (
25- < Row >
26- < Col > { args . theme } </ Col >
27- < Col >
28- < Link text = { getSizesTitle ( 's' ) } { ...args } textSize = "s" />
29- </ Col >
30- < Col >
31- < Link text = { getSizesTitle ( 'm' ) } { ...args } textSize = "m" />
32- </ Col >
33- < Col >
34- < Link text = { getSizesTitle ( 'l' ) } { ...args } textSize = "l" />
35- </ Col >
29+ const SizesTemplate : StoryFn < Record < number , LinkFullProps > > = ( args ) => (
30+ < Row alignItems = { GridAlignItems . End } >
31+ < Col > { args [ 0 ] . theme } </ Col >
32+ { Object . values ( args ) . map ( ( itemArgs , index ) => (
33+ < Col key = { index } >
34+ < Link { ...itemArgs } />
35+ </ Col >
36+ ) ) }
3637 </ Row >
3738) ;
38- const ThemesSizesTemplate : StoryFn < LinkFullProps > = ( args ) => (
39+ const ThemesSizesTemplate : StoryFn < Record < number , Record < number , LinkFullProps > > > = ( args ) => (
3940 < React . Fragment >
4041 < Row >
4142 < Col />
42- < Col > s </ Col >
43- < Col > m </ Col >
44- < Col > l </ Col >
43+ < Col > { args [ 0 ] [ 0 ] . textSize } </ Col >
44+ < Col > { args [ 0 ] [ 1 ] . textSize } </ Col >
45+ < Col > { args [ 0 ] [ 2 ] . textSize } </ Col >
4546 </ Row >
46- < SizesTemplate { ...args } theme = "normal" />
47- < SizesTemplate { ...args } theme = "underline" />
48- < SizesTemplate { ...args } theme = "back" />
49- < SizesTemplate { ...args } theme = "file-link" />
47+ < SizesTemplate { ...args [ 0 ] } />
48+ < SizesTemplate { ...args [ 1 ] } />
49+ < SizesTemplate { ...args [ 2 ] } />
50+ < SizesTemplate { ...args [ 3 ] } />
5051 </ React . Fragment >
5152) ;
5253
@@ -72,17 +73,28 @@ const WithChildrenTemplate: StoryFn<LinkFullProps> = (args) => (
7273) ;
7374
7475export const Default = DefaultTemplate . bind ( { } ) ;
75- export const ThemesSizes = ThemesSizesTemplate . bind ( { } ) ;
76+ export const ThemesSizes = ThemesSizesTemplate . bind ( [ [ ] ] ) ;
77+ ThemesSizes . parameters = {
78+ controls : {
79+ include : Object . keys ( THEMES_SIZES ) ,
80+ } ,
81+ } ;
7682export const NormalWithChildren = WithChildrenTemplate . bind ( { } ) ;
77- export const NormalArrow = SizesTemplate . bind ( { } ) ;
83+ export const NormalArrow = SizesTemplate . bind ( [ ] ) ;
84+ NormalArrow . parameters = {
85+ controls : {
86+ include : Object . keys ( data . normalArrows ) ,
87+ } ,
88+ } ;
89+
7890export const NormalForDarkTheme = DarkTemplate . bind ( { } ) ;
7991export const UnderlineWithChildren = WithChildrenTemplate . bind ( { } ) ;
8092export const BackWithChildren = WithChildrenTemplate . bind ( { } ) ;
8193
8294Default . args = data . default . content ;
83- ThemesSizes . args = data . themesSizes . content ;
84- NormalWithChildren . args = data . normalWithChildren . content as LinkProps ;
85- NormalArrow . args = data . normalArrow . content as LinkProps ;
86- NormalForDarkTheme . args = data . normalForDarkTheme . content as LinkProps ;
87- UnderlineWithChildren . args = data . underlineWithChildren . content as LinkProps ;
88- BackWithChildren . args = data . backWithChildren . content as LinkProps ;
95+ ThemesSizes . args = THEMES_SIZES as LinkFullProps [ ] [ ] ;
96+ NormalWithChildren . args = data . normalWithChildren . content as LinkFullProps ;
97+ NormalArrow . args = data . normalArrows as LinkFullProps [ ] ;
98+ NormalForDarkTheme . args = data . normalForDarkTheme . content as LinkFullProps ;
99+ UnderlineWithChildren . args = data . underlineWithChildren . content as LinkFullProps ;
100+ BackWithChildren . args = data . backWithChildren . content as LinkFullProps ;
0 commit comments