You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: en/components/themes/misc/angular-material-theming.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,7 @@ To get started with styling components using the Ignite UI theming engine, creat
101
101
102
102
### ColorPalettes
103
103
104
-
IgniteUIforAngular's [`igx-palette`]({environment:sassApiUrl}/index.html#function-igx-palette) function produces a color palette map including three sub-palettes for the `primary`, `secondary` and `gray` shades as well as five additional colors for `info`, `success`, `warn`, `error` and `surface`. For each color variant, our theming engine automatically generates text contrast colors at build-time, that are also included in the palette. Below, you can see the predefined light material palette:
104
+
IgniteUIforAngular's [`palette`]({environment:sassApiUrl}/index.html#function-igx-palette) function produces a color palette map including three sub-palettes for the `primary`, `secondary` and `gray` shades as well as five additional colors for `info`, `success`, `warn`, `error` and `surface`. For each color variant, our theming engine automatically generates text contrast colors at runtime, that are also included in the palette. Below, you can see the predefined light material palette:
Copy file name to clipboardExpand all lines: en/components/themes/palettes.md
+21-9Lines changed: 21 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,33 +45,45 @@ As the table above shows, the `gray` color doesn't include the `A100`, `A200`, `
45
45
On top of the aforementioned colors, we also include **Level AA**[WCAG](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html) compliant `contrast` colors for each color variant. This means that you can safely use the corresponding `contrast` color variants as foreground colors for the base color variant.
46
46
47
47
> [!NOTE]
48
-
> Contrast colors are generated at build-time by the Sass theming engine based on the main variables color (primary, secondary, etc.).
48
+
> Contrast colors are CSS relative colors and are runtime calculated, based on the corresponding shade color (primary, secondary, etc.).
49
49
50
50
Here's an excerpt of the `primary` variable color as declared in the Light Material Palette:
51
51
52
52
```css
53
53
:root {
54
54
//...
55
55
--ig-primary-500: #09f;
56
-
--ig-primary-500-contrast: black;
56
+
--ig-primary-500-contrast: hsl(from color(from var(--ig-primary-500) var(--y-contrast)) h 0 l);
57
57
--ig-primary-600: hsl(from var(--ig-primary-500) h calc(s *1.26) calc(l *0.89));
58
-
--ig-primary-600-contrast: black;
58
+
--ig-primary-600-contrast: hsl(from color(from var(--ig-primary-600) var(--y-contrast)) h 0 l);
59
59
--ig-primary-700: hsl(from var(--ig-primary-500) h calc(s *1.26) calc(l *0.81));
60
60
//...
61
61
--ig-secondary-400: hsl(from var(--ig-secondary-500) h calc(s *0.875) calc(l *1.08));
62
-
--ig-secondary-400-contrast: black;
62
+
--ig-secondary-400-contrast: hsl(from color(from var(--ig-secondary-400) var(--y-contrast)) h 0 l);
63
63
--ig-secondary-500: #df1b74;
64
-
--ig-secondary-500-contrast: white;
64
+
--ig-secondary-500-contrast: hsl(from color(from var(--ig-secondary-500) var(--y-contrast)) h 0 l);
65
65
--ig-secondary-600: hsl(from var(--ig-secondary-500) h calc(s *1.26) calc(l *0.89));
66
-
--ig-secondary-600-contrast: white;
66
+
--ig-secondary-600-contrast: hsl(from color(from var(--ig-secondary-600) var(--y-contrast)) h 0 l);
All primary color variants are derived from one base variable color variant `--ig-primary-500`. The same goes for the other color variables `--ig-secondary-500`, `--ig-surface-500`, etc. The other variants are generated through the relative color function `hsl()` which takes the main variable color variant `500` and changes it's `staturation` and `lightness`according to the variable variant which is assigned on (`600`,`700`, etc.). We decided to use this approach as it allows us to modify all variants of the `primary`, `secondary`, `surface` and other colors at runtime.
77
+
All primary color variants come from a single base variable: `--ig-primary-500`. This same pattern applies to other color variables like `--ig-secondary-500` and `--ig-surface-500`. The additional variants are created using relative color CSS functions that take the main `500`variable and adjust its `saturation` and `lightness` to create other variants (600, 700, etc.). We chose this approach because it lets us modify all variants of `primary`, `secondary`, `surface`, and other colors during runtime.
72
78
73
-
> [!WARNING]
74
-
> Because the contrast colors are not generated at CSS runtime like the rest, if we change the main color variant(`500`), the contrast color would not be updated. We would need to change them manually. This behavior will be improved upon in an upcoming release, where the contrast colors will also be calculated at CSS runtime.
79
+
The contrast colors are CSS runtime generated, based on the the provided color's luminance and the chosen contrast-level to calculate the best contrast color for it. If we change the main color variant(`500`), the contrast colors will also be updated.
80
+
81
+
> [!NOTE]
82
+
> You could specify the contrast-level globally by using the `palette` mixin, or if you'd like to set it specifically in the scope of your element, you could use the `adaptive-contrast` mixin. They both accept one of the predefined values: `a`, `aa` or `aaa`.
0 commit comments