Skip to content

Commit 4b1e4f3

Browse files
committed
feat(Palette): add utility classes for color and gradient backgrounds
Introduced a new SCSS file that defines utility classes for applying colors and gradients as CSS variables. This allows child elements to inherit background colors and gradients from their parent elements, enhancing theming capabilities.
1 parent c5750e4 commit 4b1e4f3

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@use "../00-variables/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 / gradient value in a CSS variable.
7+
* This allows any child element to reuse the parent's background color or image.
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+
* Gradients expose --gradient on .has-{slug}-gradient-background.
22+
*/
23+
24+
@each $color-name, $color-value in $settings-palette {
25+
.has-#{$color-name}-color {
26+
--color: #{$color-value};
27+
}
28+
29+
.has-#{$color-name}-background-color {
30+
--background-color: #{$color-value};
31+
}
32+
}
33+
34+
@each $gradient-name, $gradient-value in $settings-gradients {
35+
.has-#{$gradient-name}-gradient-background {
36+
--gradient: #{$gradient-value};
37+
}
38+
}

0 commit comments

Comments
 (0)