Skip to content

Commit fbde5ef

Browse files
committed
fix(slider): some potentially broken styles when using css variables
Fixes a few places in the slider theme which can break if the consumer is using CSS variables for their theme.
1 parent 0f6cd05 commit fbde5ef

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

src/material/slider/_slider-theme.scss

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
$mat-slider-disabled-color: mat-color($foreground, slider-off);
2727
$mat-slider-labeled-min-value-thumb-color: mat-color($foreground, slider-min);
2828
$mat-slider-labeled-min-value-thumb-label-color: mat-color($foreground, slider-off);
29-
$mat-slider-focus-ring-color: mat-color($accent, default, 0.2);
30-
$mat-slider-focus-ring-min-value-color: mat-color($foreground, base, 0.12);
31-
$mat-slider-tick-color: mat-color($foreground, base, 0.7);
29+
$mat-slider-tick-opacity: 0.7;
30+
$mat-slider-tick-color: mat-color($foreground, base, $mat-slider-tick-opacity);
3231
$mat-slider-tick-size: 2px;
3332

3433
.mat-slider-track-background {
@@ -48,7 +47,13 @@
4847
}
4948

5049
.mat-slider-focus-ring {
51-
background-color: $mat-slider-focus-ring-color;
50+
$opacity: 0.2;
51+
$color: mat-color($accent, default, $opacity);
52+
background-color: $color;
53+
54+
@if (type-of($color) != color) {
55+
opacity: $opacity;
56+
}
5257
}
5358

5459
.mat-slider:hover,
@@ -74,7 +79,13 @@
7479

7580
.mat-slider-min-value {
7681
.mat-slider-focus-ring {
77-
background-color: $mat-slider-focus-ring-min-value-color;
82+
$opacity: 0.12;
83+
$color: mat-color($foreground, base, $opacity);
84+
background-color: $color;
85+
86+
@if (type-of($color) != color) {
87+
opacity: $opacity;
88+
}
7889
}
7990

8091
&.mat-slider-thumb-label-showing {
@@ -112,6 +123,10 @@
112123

113124
.mat-slider-has-ticks .mat-slider-wrapper::after {
114125
border-color: $mat-slider-tick-color;
126+
127+
@if (type-of($mat-slider-tick-color) != color) {
128+
opacity: $mat-slider-tick-opacity;
129+
}
115130
}
116131

117132
.mat-slider-horizontal .mat-slider-ticks {
@@ -121,11 +136,19 @@
121136
// (see https://bugzilla.mozilla.org/show_bug.cgi?id=1314319).
122137
background-image: -moz-repeating-linear-gradient(0.0001deg, $mat-slider-tick-color,
123138
$mat-slider-tick-color $mat-slider-tick-size, transparent 0, transparent);
139+
140+
@if (type-of($mat-slider-tick-color) != color) {
141+
opacity: $mat-slider-tick-opacity;
142+
}
124143
}
125144

126145
.mat-slider-vertical .mat-slider-ticks {
127146
background-image: repeating-linear-gradient(to bottom, $mat-slider-tick-color,
128147
$mat-slider-tick-color $mat-slider-tick-size, transparent 0, transparent);
148+
149+
@if (type-of($mat-slider-tick-color) != color) {
150+
opacity: $mat-slider-tick-opacity;
151+
}
129152
}
130153
}
131154

0 commit comments

Comments
 (0)