@@ -5,6 +5,15 @@ import { DualScrollSync } from '../DualScrollSync';
55import { MockContentSection } from './mocks' ;
66import { FILTER_GROUPS } from './mocks/MockFilterGroups' ;
77
8+ interface ExtendedArgs {
9+ borderRadius ?: number ;
10+ borderColor ?: string ;
11+ highlightBackgroundColor ?: string ;
12+ highlightForegroundColor ?: string ;
13+ inactiveBackgroundColor ?: string ;
14+ maxWidthNav ?: number ;
15+ }
16+
817const meta : Meta < typeof DualScrollSync > = {
918 title : 'Components/DualScrollSync' ,
1019 component : DualScrollSync ,
@@ -37,16 +46,23 @@ export const Default: Story = {
3746 maxVisibleItems : 6 ,
3847 onItemClick : action ( 'onItemClick' )
3948 } ,
49+ decorators : [
50+ ( Story ) => (
51+ < section
52+ style = { { height : '50dvh' , maxWidth : '360px' , maxHeight : '480px' , minHeight : '320px' } }
53+ >
54+ < Story />
55+ </ section >
56+ )
57+ ] ,
4058 render : ( { items, ...args } ) => (
41- < section style = { { height : '50dvh' , maxWidth : '360px' , maxHeight : '480px' , minHeight : '320px' } } >
42- < DualScrollSync
43- { ...args }
44- items = { items ?. map ( ( item ) => ( {
45- ...item ,
46- children : < MockContentSection />
47- } ) ) }
48- />
49- </ section >
59+ < DualScrollSync
60+ { ...args }
61+ items = { items ?. map ( ( item ) => ( {
62+ ...item ,
63+ children : < MockContentSection />
64+ } ) ) }
65+ />
5066 )
5167} ;
5268
@@ -58,16 +74,89 @@ export const FewSectionsExample: Story = {
5874 { sectionKey : 'section3' , label : 'Section 3' , children : '<Component />' }
5975 ]
6076 } ,
77+ decorators : [
78+ ( Story ) => (
79+ < section
80+ style = { { height : '50dvh' , maxWidth : '360px' , maxHeight : '480px' , minHeight : '320px' } }
81+ >
82+ < Story />
83+ </ section >
84+ )
85+ ] ,
86+ render : ( { items, ...args } ) => (
87+ < DualScrollSync
88+ items = { items . map ( ( item ) => ( {
89+ ...item ,
90+ children : < MockContentSection minHeight = "480px" />
91+ } ) ) }
92+ { ...args }
93+ />
94+ )
95+ } ;
96+
97+ export const ThemingExample : Story & { args : ExtendedArgs ; argTypes ?: Record < string , unknown > } = {
98+ name : 'Theming with CSS Variables' ,
99+ argTypes : {
100+ borderColor : { control : { type : 'color' } } ,
101+ borderRadius : { control : { type : 'number' , min : 0 , max : 32 , step : 2 } } ,
102+ highlightBackgroundColor : { control : { type : 'color' } } ,
103+ highlightForegroundColor : { control : { type : 'color' } } ,
104+ inactiveBackgroundColor : { control : { type : 'color' } } ,
105+ maxWidthNav : { control : { type : 'number' , min : 60 , max : 240 , step : 10 } }
106+ } ,
107+ args : {
108+ items : [
109+ { sectionKey : 's1' , label : 'Label 1' , children : '<Component />' } ,
110+ { sectionKey : 's2' , label : 'Label 2' , children : '<Component />' } ,
111+ { sectionKey : 's3' , label : 'Label 3' , children : '<Component />' } ,
112+ { sectionKey : 's4' , label : 'Label 4' , children : '<Component />' } ,
113+ { sectionKey : 's5' , label : 'Label 5' , children : '<Component />' } ,
114+ { sectionKey : 's6' , label : 'Label 6' , children : '<Component />' } ,
115+ { sectionKey : 's7' , label : 'Label 7' , children : '<Component />' } ,
116+ { sectionKey : 's8' , label : 'Label 8' , children : '<Component />' } ,
117+ { sectionKey : 's9' , label : 'Label 9' , children : '<Component />' } ,
118+ { sectionKey : 's10' , label : 'Label 10' , children : '<Component />' }
119+ ] ,
120+ id : 'theming-example' ,
121+ maxVisibleItems : 10 ,
122+ borderColor : '#FFEDFA' ,
123+ borderRadius : 0 ,
124+ highlightBackgroundColor : '#FFB8E0' ,
125+ highlightForegroundColor : '#BE5985' ,
126+ inactiveBackgroundColor : '#FFEDFA' ,
127+ maxWidthNav : 160
128+ } ,
129+ decorators : [
130+ ( Story ) => (
131+ < section
132+ style = { { height : '50dvh' , maxWidth : '360px' , maxHeight : '480px' , minHeight : '320px' } }
133+ >
134+ < Story />
135+ </ section >
136+ )
137+ ] ,
61138 render : ( { items, ...args } ) => (
62- < section style = { { height : '50dvh' , maxWidth : '360px' , maxHeight : '480px' , minHeight : '320px' } } >
139+ < >
140+ < style >
141+ { `
142+ :root {
143+ --dual-scroll-sync-border-color: ${ ( args as ExtendedArgs ) . borderColor } ;
144+ --dual-scroll-sync-border-radius: ${ ( args as ExtendedArgs ) . borderRadius } px;
145+ --dual-scroll-sync-highlight-background-color: ${ ( args as ExtendedArgs ) . highlightBackgroundColor } ;
146+ --dual-scroll-sync-highlight-foreground-color: ${ ( args as ExtendedArgs ) . highlightForegroundColor } ;
147+ --dual-scroll-sync-inactive-background-color: ${ ( args as ExtendedArgs ) . inactiveBackgroundColor } ;
148+ --dual-scroll-sync-max-width-nav: ${ ( args as ExtendedArgs ) . maxWidthNav } px;
149+ }
150+ ` }
151+ </ style >
63152 < DualScrollSync
64- items = { items . map ( ( item ) => ( {
153+ { ...args }
154+ items = { items ?. map ( ( item ) => ( {
65155 ...item ,
66- children : < MockContentSection minHeight = "480px" />
156+ children : < MockContentSection />
67157 } ) ) }
68- { ...args }
69158 />
70- </ section >
159+ </ >
71160 )
72161} ;
73162
0 commit comments