File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -342,6 +342,31 @@ <h3 class="pl-c-annotations__item-title">{{ title }}</h3>
342342
343343 <!-- load Pattern Lab data -->
344344 < script src ="styleguide/data/patternlab-data.js "> </ script >
345+
346+ <!-- applying theme config to get classes on before PL renders so there's no flash of unstyled content -->
347+ <!-- @todo Consider moving this to own file -->
348+ < script >
349+ if ( config && config . theme ) {
350+ if ( config . theme . color === 'light' ) {
351+ document . body . classList . add ( 'pl-c-body--theme-light' ) ;
352+ }
353+ if ( config . theme . layout === 'vertical' ) {
354+ document . body . classList . add ( 'pl-c-body--theme-sidebar' ) ;
355+ }
356+ switch ( config . theme . density ) {
357+ case 'cozy' :
358+ document . body . classList . add ( 'pl-c-body--theme-density-cozy' ) ;
359+ break ;
360+ case 'comfortable' :
361+ document . body . classList . add ( 'pl-c-body--theme-density-comfortable' ) ;
362+ break ;
363+ default :
364+ // not sure if you even need/want this
365+ document . body . classList . add ( 'pl-c-body--theme-density-compact' ) ;
366+ }
367+ }
368+ </ script >
369+
345370 < script src ="annotations/annotations.js "> </ script >
346371
347372 <!-- load Pattern Lab external library js -->
Original file line number Diff line number Diff line change 3737
3838 <!-- load Pattern Lab data -->
3939 < script src ="styleguide/data/patternlab-data.js "> </ script >
40+
41+ <!-- applying theme config to get classes on before PL renders so there's no flash of unstyled content -->
42+ <!-- @todo Consider moving this to own file -->
43+ < script >
44+ if ( config && config . theme ) {
45+ if ( config . theme . color === 'light' ) {
46+ document . body . classList . add ( 'pl-c-body--theme-light' ) ;
47+ }
48+ if ( config . theme . layout === 'vertical' ) {
49+ document . body . classList . add ( 'pl-c-body--theme-sidebar' ) ;
50+ }
51+ switch ( config . theme . density ) {
52+ case 'cozy' :
53+ document . body . classList . add ( 'pl-c-body--theme-density-cozy' ) ;
54+ break ;
55+ case 'comfortable' :
56+ document . body . classList . add ( 'pl-c-body--theme-density-comfortable' ) ;
57+ break ;
58+ default :
59+ // not sure if you even need/want this
60+ document . body . classList . add ( 'pl-c-body--theme-density-compact' ) ;
61+ }
62+ }
63+ </ script >
64+
4065 < script src ="annotations/annotations.js "> </ script >
4166
4267 <!-- load Pattern Lab external library js -->
You can’t perform that action at this time.
0 commit comments