|
| 1 | +@use '../core/mdc-helpers/mdc-helpers'; |
1 | 2 | @use '../core/theming/theming';
|
2 |
| -@use '../core/tokens/m2/mdc/linear-progress' as tokens-mdc-linear-progress; |
| 3 | +@use '@material/theme/theme-color' as mdc-theme-color; |
3 | 4 | @use '@material/linear-progress/linear-progress-theme' as mdc-linear-progress-theme;
|
4 |
| -@use 'sass:map'; |
| 5 | +@use 'sass:color'; |
| 6 | +@use 'sass:meta'; |
5 | 7 |
|
6 |
| -@mixin _palette-styles($config, $palette-name) { |
7 |
| - $palette-config: map.merge($config, (primary: map.get($config, $palette-name))); |
8 |
| - $color-tokens: tokens-mdc-linear-progress.get-color-tokens($palette-config); |
| 8 | + |
| 9 | +@mixin _palette-styles($color) { |
| 10 | + $color-value: mdc-theme-color.prop-value($color); |
9 | 11 |
|
10 | 12 | // We can't set the `track-color` using `theme`, because it isn't possible for it to use a CSS
|
11 | 13 | // variable since MDC's buffer animation works by constructing an SVG string from this color.
|
12 |
| - // We also can't set the `track-color` by creating our own token slot because the track-color |
13 |
| - // is set in the SVG string in `theme-styles`. |
14 | 14 | @include mdc-linear-progress-theme.theme-styles((
|
15 | 15 | // TODO(crisbeto): the buffer color should come from somewhere in MDC, however at the time of
|
16 | 16 | // writing, their buffer color is hardcoded to #e6e6e6 which both doesn't account for theming
|
17 | 17 | // and doesn't match the Material design spec. For now we approximate the buffer background by
|
18 | 18 | // applying an opacity to the color of the bar.
|
19 |
| - track-color: map.get($color-tokens, track-color), |
| 19 | + track-color: if( |
| 20 | + meta.type-of($color-value) == color, |
| 21 | + color.adjust($color-value, $alpha: -0.75), |
| 22 | + $color-value |
| 23 | + ), |
20 | 24 | ));
|
21 | 25 |
|
22 |
| - @include mdc-linear-progress-theme.theme($color-tokens); |
| 26 | + @include mdc-linear-progress-theme.theme(( |
| 27 | + active-indicator-color: $color-value, |
| 28 | + )); |
23 | 29 | }
|
24 | 30 |
|
25 | 31 | @mixin color($config-or-theme) {
|
26 | 32 | $config: theming.get-color-config($config-or-theme);
|
| 33 | + @include mdc-helpers.using-mdc-theme($config) { |
| 34 | + .mat-mdc-progress-bar { |
| 35 | + @include _palette-styles(primary); |
27 | 36 |
|
28 |
| - .mat-mdc-progress-bar { |
29 |
| - @include _palette-styles($config, primary); |
30 |
| - |
31 |
| - &.mat-accent { |
32 |
| - @include _palette-styles($config, accent); |
33 |
| - } |
| 37 | + &.mat-accent { |
| 38 | + @include _palette-styles(secondary); |
| 39 | + } |
34 | 40 |
|
35 |
| - &.mat-warn { |
36 |
| - @include _palette-styles($config, warn); |
| 41 | + &.mat-warn { |
| 42 | + @include _palette-styles(error); |
| 43 | + } |
37 | 44 | }
|
38 | 45 | }
|
39 | 46 | }
|
|
0 commit comments