File tree Expand file tree Collapse file tree 4 files changed +37
-2
lines changed
Expand file tree Collapse file tree 4 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -86,12 +86,15 @@ class WebpackThemeJsonPlugin {
8686 const tasks = {
8787 'settings-color-palette' ( key , value ) {
8888 let result = ''
89+ const palette = [ ]
8990
9091 for ( const color of value ) {
91- result += `${ getVariableName ( 'settings-color-' + color . slug ) } : ${ color . color } ;\n`
92+ const colorVar = getVariableName ( 'settings-color-' + color . slug )
93+ result += `${ colorVar } : ${ color . color } ;\n`
94+ palette . push ( `${ color . slug } : ${ colorVar } ` )
9295 }
9396
94- return result
97+ return result + `$settings-palette: ( ${ palette . join ( ', ' ) } );\n`
9598 } ,
9699 'settings-custom' : 'default' ,
97100 'settings-spacing-spacingSizes' ( key , value ) {
Original file line number Diff line number Diff line change 1+ @use " ../01-abstract/theme-json.scss" as * ;
2+
3+ /*
4+ * Palette : Usefully to get the color or background color of a parent element
5+ * Usage Example:
6+ * Use these classes to store a color value in a CSS variable.
7+ * This allows any child element to reuse the parent's background color.
8+ *
9+ * HTML:
10+ * <div class="has-primary-background-color">
11+ * <span class="child-element">
12+ * I will use the parent's background as my text color
13+ * </span>
14+ * </div>
15+ *
16+ * CSS:
17+ * .child-element {
18+ * color: var(--background-color);
19+ * }
20+ */
21+
22+ @each $color-name , $color-value in $settings-palette {
23+ .has-#{$color-name } -color {
24+ --color : #{$color-value } ;
25+ }
26+
27+ .has-#{$color-name } -background-color {
28+ --background-color : #{$color-value } ;
29+ }
30+ }
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ variables.$entry-file-name: "editor";
3434@use " 04-utilities/sr-only" ;
3535@use " 04-utilities/js-animation" ;
3636@use " 04-utilities/aria" ;
37+ @use " 04-utilities/palette" ;
3738
3839/* *
3940 * Blocks
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ variables.$entry-file-name: "style";
3838@use " 04-utilities/sr-only" ;
3939@use " 04-utilities/js-animation" ;
4040@use " 04-utilities/aria" ;
41+ @use " 04-utilities/palette" ;
4142
4243/* *
4344 * Components
You can’t perform that action at this time.
0 commit comments