@@ -19,20 +19,55 @@ const meta = {
19
19
} ,
20
20
tags : [ 'autodocs' ] ,
21
21
argTypes : argtypes ( variantsObject , themeSelected ) ,
22
+ render : ( { ...args } ) => < StoryWithHooks { ...args } /> ,
22
23
} satisfies Meta < typeof Story > ;
23
24
24
25
export default meta ;
25
26
26
27
type Story = StoryObj < typeof meta > & { args : { themeArgs ?: object } } ;
27
28
29
+ const StoryWithHooks = args => {
30
+ const [ height , setHeight ] = React . useState ( 0 ) ;
31
+ const refFirstContent = React . useRef < HTMLElement | null > ( null ) ;
32
+ // Check if mainContent is an empty fragment
33
+ const isEmptyFragment =
34
+ args . mainContent ?. type === React . Fragment && ! args . mainContent . props . children ;
35
+
36
+ // catch the reference when the component appears
37
+ const callbackRef = React . useCallback ( node => {
38
+ if ( node ) {
39
+ refFirstContent . current = node ;
40
+ const element = refFirstContent . current as HTMLElement ;
41
+ setHeight ( element . clientHeight || 0 ) ;
42
+ }
43
+ } , [ ] ) ;
44
+
45
+ const mainContent = isEmptyFragment ? (
46
+ < >
47
+ < ReplaceContent ref = { callbackRef } height = { '50%' } >
48
+ Main content
49
+ </ ReplaceContent >
50
+ < ReplaceContent height = { '50%' } > Main content</ ReplaceContent >
51
+ </ >
52
+ ) : (
53
+ args . mainContent
54
+ ) ;
55
+
56
+ const asideContent = args . asideContent ? (
57
+ args . asideContent
58
+ ) : (
59
+ < ReplaceContent height = { '50%' } margin = { `${ height } px 0 0 0 ` } >
60
+ Aside content
61
+ </ ReplaceContent >
62
+ ) ;
63
+
64
+ return < Story { ...args } asideContent = { asideContent } mainContent = { mainContent } /> ;
65
+ } ;
66
+
28
67
export const Layout : Story = {
29
68
args : {
30
69
variant : Object . values ( variantsObject [ themeSelected ] . LayoutVariantType || { } ) [ 0 ] as string ,
31
- mainContent : (
32
- < >
33
- < ReplaceContent height = { '100%' } > Main content</ ReplaceContent >
34
- </ >
35
- ) ,
70
+ mainContent : < ReplaceContent height = { '100%' } > Main content</ ReplaceContent > ,
36
71
headerContent : < ReplaceContent > Header content</ ReplaceContent > ,
37
72
asideContent : < ReplaceContent height = { '100%' } > Aside content</ ReplaceContent > ,
38
73
footerContent : < ReplaceContent > Footer content</ ReplaceContent > ,
@@ -64,10 +99,57 @@ export const Layout: Story = {
64
99
[ DeviceBreakpointsType . MOBILE ] : 4 ,
65
100
} ,
66
101
} ,
102
+
67
103
themeArgs : themesObject [ themeSelected ] [ STYLES_NAME . LAYOUT ] ,
68
104
} ,
69
105
} ;
70
106
107
+ export const LayoutAlignAside : Story = {
108
+ args : {
109
+ variant : Object . values ( variantsObject [ themeSelected ] . LayoutVariantType || { } ) [ 0 ] as string ,
110
+ mainContent : < > </ > ,
111
+ headerContent : < ReplaceContent > Header content</ ReplaceContent > ,
112
+ footerContent : < ReplaceContent > Footer content</ ReplaceContent > ,
113
+ backgroundColor : '#f5f5f5' ,
114
+ columnsConfig : {
115
+ header : {
116
+ [ DeviceBreakpointsType . LARGE_DESKTOP ] : 12 ,
117
+ [ DeviceBreakpointsType . DESKTOP ] : 12 ,
118
+ [ DeviceBreakpointsType . TABLET ] : 8 ,
119
+ [ DeviceBreakpointsType . MOBILE ] : 4 ,
120
+ } ,
121
+ footer : {
122
+ [ DeviceBreakpointsType . LARGE_DESKTOP ] : 12 ,
123
+ [ DeviceBreakpointsType . DESKTOP ] : 12 ,
124
+ [ DeviceBreakpointsType . TABLET ] : 8 ,
125
+ [ DeviceBreakpointsType . MOBILE ] : 4 ,
126
+ } ,
127
+ main : {
128
+ [ DeviceBreakpointsType . LARGE_DESKTOP ] : 9 ,
129
+ [ DeviceBreakpointsType . DESKTOP ] : 9 ,
130
+ DESKTOP_FULL : 12 ,
131
+ [ DeviceBreakpointsType . TABLET ] : 8 ,
132
+ [ DeviceBreakpointsType . MOBILE ] : 4 ,
133
+ } ,
134
+ aside : {
135
+ [ DeviceBreakpointsType . LARGE_DESKTOP ] : 3 ,
136
+ [ DeviceBreakpointsType . DESKTOP ] : 3 ,
137
+ [ DeviceBreakpointsType . TABLET ] : 8 ,
138
+ [ DeviceBreakpointsType . MOBILE ] : 4 ,
139
+ } ,
140
+ } ,
141
+ ctv : {
142
+ gridConfig : {
143
+ DESKTOP : {
144
+ // mainStyles: {
145
+ // height: 'fit-content',
146
+ // },
147
+ } ,
148
+ } ,
149
+ } ,
150
+ } ,
151
+ } ;
152
+
71
153
export const LayoutWithCtv : Story = {
72
154
args : {
73
155
variant : Object . values ( variantsObject [ themeSelected ] . LayoutVariantType || { } ) [ 0 ] as string ,
0 commit comments