22 configureTheme ,
33 defineComponents ,
44 IgcButtonComponent ,
5+ IgcButtonGroupComponent ,
6+ IgcToggleButtonComponent ,
57 IgcAvatarComponent ,
68 IgcCheckboxComponent ,
79 IgcRatingComponent ,
@@ -19,6 +21,8 @@ defineComponents(
1921 IgcSelectComponent ,
2022 IgcSwitchComponent ,
2123 IgcButtonComponent ,
24+ IgcButtonGroupComponent ,
25+ IgcToggleButtonComponent ,
2226) ;
2327
2428type User = {
@@ -81,11 +85,16 @@ function getAvatar() {
8185 return `https://static.infragistics.com/xplatform/images/people/${ type } /${ idx } .jpg` ;
8286}
8387
84- async function setTheme ( theme ?: string ) {
85- theme = theme ?? getElement < IgcSelectComponent > ( IgcSelectComponent . tagName ) . value ;
86- const variant = getElement < IgcSwitchComponent > ( IgcSwitchComponent . tagName ) . checked
87- ? 'dark'
88- : 'light' ;
88+ let currentTheme = sessionStorage . getItem ( 'theme' ) ?? 'bootstrap' ;
89+ let currentVariant = sessionStorage . getItem ( 'theme-variant' ) === 'dark' ? 'dark' : 'light' ;
90+ const storedSize = Number ( sessionStorage . getItem ( 'size' ) ?? 3 ) ;
91+
92+ async function setTheme ( theme : string , variant : string ) {
93+ currentTheme = theme ;
94+ currentVariant = variant ;
95+
96+ sessionStorage . setItem ( 'theme' , theme ) ;
97+ sessionStorage . setItem ( 'theme-variant' , variant ) ;
8998
9099 await import (
91100 /* @vite -ignore */
@@ -96,22 +105,30 @@ async function setTheme(theme?: string) {
96105 . slice ( 0 , - 1 )
97106 . forEach ( ( s ) => s . remove ( ) ) ;
98107
99- configureTheme ( theme as any ) ;
108+ configureTheme ( theme as any , variant as any ) ;
100109}
101110
102111const themeChoose = html `
103112 < div class ="sample-drop-down ">
104113 < igc-select
105- value ="bootstrap "
114+ style ="--ig-size: 1; "
115+ value =${ currentTheme }
106116 outlined
107117 title ="Choose theme "
108- @igcChange =${ ( { detail } : CustomEvent ) => setTheme ( detail . value ) }
118+ @igcChange =${ ( { detail } : CustomEvent ) => setTheme ( detail . value , currentVariant ) }
109119 >
110120 ${ themes . map ( ( theme ) => html `< igc-select-item .value =${ theme } > ${ theme } </ igc-select-item > ` ) }
111121 </ igc-select >
122+ < igc-button-group selection ="single-required " style ="--ig-size: 1; ">
123+ < igc-toggle-button value ="small " ?selected =${ storedSize === 1 } @click =${ ( ) => setSize ( 1 ) } > Small</ igc-toggle-button >
124+ < igc-toggle-button value ="medium " ?selected =${ storedSize === 2 } @click =${ ( ) => setSize ( 2 ) } > Medium</ igc-toggle-button >
125+ < igc-toggle-button value ="large " ?selected =${ storedSize === 3 } @click =${ ( ) => setSize ( 3 ) } > Large</ igc-toggle-button >
126+ </ igc-button-group >
112127 < igc-switch
128+ id ="theme-variant "
113129 label-position ="after "
114- @igcChange =${ ( ) => setTheme ( ) }
130+ ?checked =${ currentVariant === 'dark' }
131+ @igcChange =${ ( e : CustomEvent ) => setTheme ( currentTheme , ( e . target as IgcSwitchComponent ) . checked ? 'dark' : 'light' ) }
115132 > Dark variant</ igc-switch
116133 >
117134 </ div >
@@ -128,7 +145,7 @@ const columns: ColumnConfiguration<User>[] = [
128145 } ,
129146 {
130147 field : 'name' ,
131- cellTemplate : ( params ) => html `< igc-input .value =${ params . value } > </ igc-input > ` ,
148+ cellTemplate : ( params ) => html `< igc-input style =" padding-block: .4rem " .value =${ params . value } > </ igc-input > ` ,
132149 filterable : true ,
133150 sortable : true ,
134151 } ,
@@ -148,17 +165,17 @@ const columns: ColumnConfiguration<User>[] = [
148165 cellTemplate : ( params ) =>
149166 html `< igc-rating
150167 readonly
151- style =" --ig-size: 1 "
168+
152169 .value =${ params . value }
153170 > </ igc-rating > ` ,
154171 } ,
155172 {
156173 field : 'priority' ,
157174 cellTemplate : ( params ) =>
158175 html `< igc-select
176+ style ="padding-block: .4rem "
159177 outlined
160178 .value =${ params . value }
161- style ="--ig-size: 1"
162179 > ${ choices . map (
163180 ( choice ) => html `< igc-select-item .value =${ choice } > ${ choice } </ igc-select-item > ` ,
164181 ) } </ igc-select
@@ -195,6 +212,7 @@ const columns: ColumnConfiguration<User>[] = [
195212 html `< igc-checkbox
196213 label-position ="before "
197214 ?checked =${ params . value }
215+ style ="margin: 0 auto;"
198216 > </ igc-checkbox > ` ,
199217 } ,
200218] ;
@@ -224,19 +242,27 @@ const toggleFiltering = () => {
224242 column . filterable = ! column . filterable ;
225243} ;
226244
245+ const setSize = ( size : number ) => {
246+ sessionStorage . setItem ( 'size' , String ( size ) ) ;
247+ document . getElementById ( 'demo' ) ! . style . setProperty ( '--ig-size' , String ( size ) ) ;
248+ } ;
249+
227250render (
228251 html `
229- < igc-button
230- variant ="outlined "
231- @click =${ toggleColumn }
232- > Toggle column</ igc-button
233- >
234- < igc-button
235- variant ="outlined "
236- @click =${ toggleFiltering }
237- > Toggle filtering</ igc-button
238- >
239- ${ themeChoose }
252+ < div class ="actions-panel ">
253+ < igc-switch
254+ label-position ="after "
255+ @igcChange =${ toggleColumn }
256+ > Toggle column</ igc-switch
257+ >
258+ < igc-switch
259+ label-position ="after "
260+ @igcChange =${ toggleFiltering }
261+ > Toggle filtering</ igc-switch
262+ >
263+
264+ ${ themeChoose }
265+ </ div >
240266 < igc-grid-lite .data =${ data } >
241267 ${ columns . map (
242268 ( col ) =>
@@ -261,4 +287,5 @@ render(
261287 ` ,
262288 document . getElementById ( 'demo' ) ! ,
263289) ;
264- await setTheme ( 'bootstrap' ) ;
290+ setSize ( storedSize ) ;
291+ await setTheme ( currentTheme , currentVariant ) ;
0 commit comments