Skip to content

Commit 4550637

Browse files
authored
fix(material/slider): fix value indicator bubble for m3 (#28250)
* fix(material/slider): fix value indicator bubble for m3 * fixup! fix(material/slider): fix value indicator bubble for m3 * fixup! fix(material/slider): fix value indicator bubble for m3
1 parent 7e7570d commit 4550637

File tree

5 files changed

+51
-26
lines changed

5 files changed

+51
-26
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,14 @@
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:
520+
_hardcode(translateX(-50%) rotate(-45deg), $exclude-hardcoded)
513521
);
514522
}
515523

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: block,
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 {

yarn.lock

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6895,20 +6895,10 @@ camelcase@^6.2.0:
68956895
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a"
68966896
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
68976897

6898-
caniuse-lite@^1.0.30001317, caniuse-lite@^1.0.30001370, caniuse-lite@^1.0.30001449:
6899-
version "1.0.30001495"
6900-
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001495.tgz"
6901-
integrity sha512-F6x5IEuigtUfU5ZMQK2jsy5JqUUlEFRVZq8bO2a+ysq5K7jD6PPc9YXZj78xDNS3uNchesp1Jw47YXEqr+Viyg==
6902-
6903-
caniuse-lite@^1.0.30001517:
6904-
version "1.0.30001519"
6905-
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001519.tgz#3e7b8b8a7077e78b0eb054d69e6edf5c7df35601"
6906-
integrity sha512-0QHgqR+Jv4bxHMp8kZ1Kn8CH55OikjKJ6JmKkZYP1F3D7w+lnFXF70nG5eNfsZS89jadi5Ywy5UCSKLAglIRkg==
6907-
6908-
caniuse-lite@^1.0.30001538, caniuse-lite@^1.0.30001541:
6909-
version "1.0.30001551"
6910-
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001551.tgz#1f2cfa8820bd97c971a57349d7fd8f6e08664a3e"
6911-
integrity sha512-vtBAez47BoGMMzlbYhfXrMV1kvRF2WP/lqiMuDu1Sb4EE4LKEgjopFDSRtZfdVnslNRpOqV/woE+Xgrwj6VQlg==
6898+
caniuse-lite@^1.0.30001317, caniuse-lite@^1.0.30001370, caniuse-lite@^1.0.30001449, caniuse-lite@^1.0.30001517, caniuse-lite@^1.0.30001538, caniuse-lite@^1.0.30001541:
6899+
version "1.0.30001570"
6900+
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001570.tgz"
6901+
integrity sha512-+3e0ASu4sw1SWaoCtvPeyXp+5PsjigkSt8OXZbF9StH5pQWbxEjLAZE3n8Aup5udop1uRiKA7a4utUk/uoSpUw==
69126902

69136903
canonical-path@^1.0.0:
69146904
version "1.0.0"

0 commit comments

Comments
 (0)