Skip to content

Commit f724ecb

Browse files
committed
fix(material/slider): fix value indicator bubble for m3
1 parent 997bf75 commit f724ecb

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed

src/material-experimental/theming/_custom-tokens.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,13 @@
510510
@function slider($systems, $exclude-hardcoded) {
511511
@return (
512512
value-indicator-opacity: _hardcode(1, $exclude-hardcoded),
513+
value-indicator-padding: _hardcode(0, $exclude-hardcoded),
514+
value-indicator-width: _hardcode(28px, $exclude-hardcoded),
515+
value-indicator-height: _hardcode(28px, $exclude-hardcoded),
516+
value-indicator-caret-display: _hardcode(none, $exclude-hardcoded),
517+
value-indicator-border-radius: _hardcode(50% 50% 50% 0, $exclude-hardcoded),
518+
value-indicator-text-transform: _hardcode(rotate(45deg), $exclude-hardcoded),
519+
value-indicator-container-transform: _hardcode(translateX(-50%) rotate(-45deg), $exclude-hardcoded),
513520
);
514521
}
515522

src/material/core/tokens/m2/mat/_slider.scss

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ $prefix: (mat, slider);
88
// Tokens that can't be configured through Angular Material's current theming API,
99
// but may be in a future version of the theming API.
1010
@function get-unthemable-tokens() {
11-
@return ();
11+
@return (
12+
value-indicator-width: auto,
13+
value-indicator-height: 32px,
14+
value-indicator-caret-display: visible,
15+
value-indicator-border-radius: 4px,
16+
value-indicator-padding: 0 12px,
17+
value-indicator-text-transform: none,
18+
value-indicator-container-transform: translateX(-50%)
19+
);
1220
}
1321

1422
// Tokens that can be configured through Angular Material's color theming API.
@@ -17,14 +25,14 @@ $prefix: (mat, slider);
1725

1826
@return (
1927
// Opacity of value indicator text container
20-
value-indicator-opacity: if($is-dark, 0.9, 0.6),
28+
value-indicator-opacity: if($is-dark, 0.9, 0.6)
2129
);
2230
}
2331

2432
// Tokens that can be configured through Angular Material's typography theming API.
2533
@function get-typography-tokens($theme) {
2634
@return ();
27-
}
35+
}
2836

2937
// Tokens that can be configured through Angular Material's density theming API.
3038
@function get-density-tokens($theme) {
@@ -35,9 +43,9 @@ $prefix: (mat, slider);
3543
// This is used to create token slots.
3644
@function get-token-slots() {
3745
@return sass-utils.deep-merge-all(
38-
get-unthemable-tokens(),
39-
get-color-tokens(token-utils.$placeholder-color-config),
40-
get-typography-tokens(token-utils.$placeholder-typography-config),
41-
get-density-tokens(token-utils.$placeholder-density-config)
46+
get-unthemable-tokens(),
47+
get-color-tokens(token-utils.$placeholder-color-config),
48+
get-typography-tokens(token-utils.$placeholder-typography-config),
49+
get-density-tokens(token-utils.$placeholder-density-config)
4250
);
4351
}

src/material/slider/_slider-theme.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
@else {
1616
// Add default values for tokens not related to color, typography, or density.
1717
@include sass-utils.current-selector-or-root() {
18+
$mat-tokens: tokens-mat-slider.get-unthemable-tokens();
19+
@include token-utils.create-token-values(tokens-mat-slider.$prefix, $mat-tokens);
1820
@include mdc-slider-theme.theme(tokens-mdc-slider.get-unthemable-tokens());
1921
}
2022
}

src/material/slider/slider.scss

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,26 @@ $mat-slider-horizontal-margin: 8px !default;
9494
}
9595

9696
// Add slots for custom Angular Material slider tokens.
97-
@include token-utils.use-tokens(
98-
m2-mat-slider.$prefix,
99-
m2-mat-slider.get-token-slots()
100-
) {
97+
@include token-utils.use-tokens(m2-mat-slider.$prefix, m2-mat-slider.get-token-slots()) {
98+
.mdc-slider__value-indicator-container {
99+
@include token-utils.create-token-slot(transform, value-indicator-container-transform);
100+
}
101+
101102
.mdc-slider__value-indicator {
102-
// There's no token to control this opacity so we have to do it ourselves.
103+
@include token-utils.create-token-slot(width, value-indicator-width);
104+
@include token-utils.create-token-slot(height, value-indicator-height);
105+
@include token-utils.create-token-slot(padding, value-indicator-padding);
103106
@include token-utils.create-token-slot(opacity, value-indicator-opacity);
107+
@include token-utils.create-token-slot(border-radius, value-indicator-border-radius);
108+
109+
&::before {
110+
@include token-utils.create-token-slot(display, value-indicator-caret-display);
111+
}
112+
}
113+
114+
.mdc-slider__value-indicator-text {
115+
@include token-utils.create-token-slot(width, value-indicator-width);
116+
@include token-utils.create-token-slot(transform, value-indicator-text-transform);
104117
}
105118
}
106119

@@ -141,6 +154,10 @@ $mat-slider-horizontal-margin: 8px !default;
141154
.mdc-slider__value-indicator {
142155
word-break: normal;
143156
}
157+
158+
.mdc-slider__value-indicator-text {
159+
text-align: center;
160+
}
144161
}
145162
// In the MDC slider the focus indicator is inside the thumb.
146163
.mdc-slider__thumb--focused .mat-mdc-focus-indicator::before {

0 commit comments

Comments
 (0)