Skip to content

Commit 94d5850

Browse files
authored
fix(material/progress-bar): adjust buffer colors (#22164)
* fix(material/progress-bar): adjust buffer colors * fix(material/progress-bar): use fallback for variables
1 parent 7a972fb commit 94d5850

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/material/progress-bar/_progress-bar-theme.scss

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
@use 'sass:map';
2+
@use 'sass:meta';
3+
@use 'sass:color';
24
@use '../core/theming/palette';
35
@use '../core/theming/theming';
46

7+
// Approximates the correct buffer color by using a mix between the theme color
8+
// and the theme's background color.
9+
@function _get-buffer-color($theme, $background) {
10+
$theme-color: theming.color($theme);
11+
// Return fallback color if the theme uses variables to define colors.
12+
@if (meta.type-of($theme-color) != 'color' or meta.type-of($background) != 'color') {
13+
@return theming.color($theme, lighter);
14+
}
15+
@return color.mix($theme-color, $background, $weight: 25%);
16+
}
17+
518
@mixin color($config-or-theme) {
619
$config: theming.get-color-config($config-or-theme);
720
$primary: map.get($config, primary);
821
$accent: map.get($config, accent);
922
$warn: map.get($config, warn);
23+
$background: map.get(map.get($config, background), background);
1024

1125
.mat-progress-bar-background {
12-
fill: theming.color($primary, lighter);
26+
fill: _get-buffer-color($primary, $background);
1327
}
1428

1529
.mat-progress-bar-buffer {
16-
background-color: theming.color($primary, lighter);
30+
background-color: _get-buffer-color($primary, $background);
1731
}
1832

1933
.mat-progress-bar-fill::after {
@@ -22,11 +36,11 @@
2236

2337
.mat-progress-bar.mat-accent {
2438
.mat-progress-bar-background {
25-
fill: theming.color($accent, lighter);
39+
fill: _get-buffer-color($accent, $background);
2640
}
2741

2842
.mat-progress-bar-buffer {
29-
background-color: theming.color($accent, lighter);
43+
background-color: _get-buffer-color($accent, $background);
3044
}
3145

3246
.mat-progress-bar-fill::after {
@@ -36,11 +50,11 @@
3650

3751
.mat-progress-bar.mat-warn {
3852
.mat-progress-bar-background {
39-
fill: theming.color($warn, lighter);
53+
fill: _get-buffer-color($warn, $background);
4054
}
4155

4256
.mat-progress-bar-buffer {
43-
background-color: theming.color($warn, lighter);
57+
background-color: _get-buffer-color($warn, $background);
4458
}
4559

4660
.mat-progress-bar-fill::after {

0 commit comments

Comments
 (0)