Content-Length: 440784 | pFad | http://github.com/angular/components/commit/#start-of-content

6847BDD4 fix(material/slider): use system color (#31305) · angular/components@029e39c · GitHub
Skip to content

Commit 029e39c

Browse files
andrewseguinAndrew Seguin
and
Andrew Seguin
authored
fix(material/slider): use system color (#31305)
Co-authored-by: Andrew Seguin <andrewseguin@google.com>
1 parent 009424c commit 029e39c

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

src/material/slider/_m2-slider.scss

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
@use 'sass:map';
22
@use '../core/theming/inspection';
33
@use '../core/style/elevation';
4+
@use '../core/tokens/m2-utils';
5+
@use '../core/tokens/m3-utils';
46

57
// Tokens that can't be configured through Angular Material's current theming API,
68
// but may be in a future version of the theming API.
@@ -31,44 +33,44 @@
3133

3234
// Tokens that can be configured through Angular Material's color theming API.
3335
@function get-color-tokens($theme) {
36+
$system: m2-utils.get-system($theme);
3437
$theme-color-tokens: private-get-color-palette-color-tokens($theme, primary);
35-
$is-dark: inspection.get-theme-type($theme) == dark;
36-
$on-surface: if($is-dark, #fff, #000);
3738

3839
@return map.merge(
3940
$theme-color-tokens,
4041
(
41-
slider-disabled-active-track-color: inspection.get-theme-color($theme, system, on-surface),
42-
slider-disabled-handle-color: inspection.get-theme-color($theme, system, on-surface),
43-
slider-disabled-inactive-track-color: inspection.get-theme-color($theme, system, on-surface),
44-
slider-label-container-color: $on-surface,
45-
slider-label-label-text-color: if($is-dark, #000, #fff),
46-
slider-value-indicator-opacity: if($is-dark, 0.9, 0.6),
47-
slider-with-overlap-handle-outline-color: #fff,
42+
slider-disabled-active-track-color: map.get($system, on-surface),
43+
slider-disabled-handle-color: map.get($system, on-surface),
44+
slider-disabled-inactive-track-color: map.get($system, on-surface),
45+
slider-label-container-color: map.get($system, inverse-surface),
46+
slider-label-label-text-color: map.get($system, inverse-on-surface),
47+
slider-value-indicator-opacity: 1,
48+
slider-with-overlap-handle-outline-color: map.get($system, on-surface),
4849
slider-with-tick-marks-disabled-container-color:
4950
inspection.get-theme-color($theme, system, on-surface),
5051
),
5152
);
5253
}
5354

5455
// Generates tokens for the slider properties that change based on the theme.
55-
@function private-get-color-palette-color-tokens($theme, $palette-name) {
56-
$color: inspection.get-theme-color($theme, $palette-name);
57-
$hover-ripple-color: if($color == null, null, #{rgba($color, 0.05)});
58-
$focus-ripple-color: if($color == null, null, #{rgba($color, 0.2)});
59-
$on-color: inspection.get-theme-color($theme, $palette-name, default-contrast);
56+
@function private-get-color-palette-color-tokens($theme, $color-variant) {
57+
$system: m2-utils.get-system($theme);
58+
$system: m3-utils.replace-colors-with-variant($system, primary, $color-variant);
59+
$color: map.get($system, primary);
6060

6161
@return (
62-
slider-active-track-color: $color,
63-
slider-focus-handle-color: $color,
64-
slider-focus-state-layer-color: $focus-ripple-color,
65-
slider-handle-color: $color,
66-
slider-hover-handle-color: $color,
67-
slider-hover-state-layer-color: $hover-ripple-color,
68-
slider-inactive-track-color: $color,
69-
slider-ripple-color: $color,
70-
slider-with-tick-marks-active-container-color: $on-color,
71-
slider-with-tick-marks-inactive-container-color: $color,
62+
slider-active-track-color: map.get($system, primary),
63+
slider-focus-handle-color: map.get($system, primary),
64+
slider-handle-color: map.get($system, primary),
65+
slider-hover-handle-color: map.get($system, primary),
66+
slider-focus-state-layer-color: m3-utils.color-with-opacity(
67+
map.get($system, primary), map.get($system, focus-state-layer-opacity)),
68+
slider-hover-state-layer-color: m3-utils.color-with-opacity(
69+
map.get($system, primary), map.get($system, hover-state-layer-opacity)),
70+
slider-inactive-track-color: map.get($system, primary),
71+
slider-ripple-color: map.get($system, primary),
72+
slider-with-tick-marks-active-container-color: map.get($system, on-primary),
73+
slider-with-tick-marks-inactive-container-color: map.get($system, primary),
7274
);
7375
}
7476

src/material/slider/_slider-theme.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333

3434
.mat-accent {
3535
@include token-utils.create-token-values-mixed(
36-
m2-slider.private-get-color-palette-color-tokens($theme, accent));
36+
m2-slider.private-get-color-palette-color-tokens($theme, secondary));
3737
}
3838

3939
.mat-warn {
4040
@include token-utils.create-token-values-mixed(
41-
m2-slider.private-get-color-palette-color-tokens($theme, warn));
41+
m2-slider.private-get-color-palette-color-tokens($theme, error));
4242
}
4343
}
4444
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/angular/components/commit/#start-of-content

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy