Skip to content

Commit 31c5ae9

Browse files
mmalerbazarend
authored andcommitted
feat(material-experimental/theming): add M3 progress bar support (#27880)
1 parent 9ddeec6 commit 31c5ae9

File tree

5 files changed

+56
-19
lines changed

5 files changed

+56
-19
lines changed

src/dev-app/theme-m3.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ html {
4444
@include mat.snack-bar-theme($light-theme);
4545
@include mat.progress-spinner-theme($light-theme);
4646
@include mat.radio-theme($light-theme);
47+
@include mat.progress-bar-theme($light-theme);
4748
}
4849

4950
// Emit dark theme styles.
@@ -60,6 +61,8 @@ html {
6061
@include mat.snack-bar-color($dark-theme);
6162
@include mat.progress-spinner-color($dark-theme);
6263
@include mat.radio-color($dark-theme);
64+
@include mat.progress-bar-color($dark-theme);
65+
6366
}
6467

6568
// Emit density styles for each scale.
@@ -75,5 +78,6 @@ html {
7578
@include mat.snack-bar-density($scale-theme);
7679
@include mat.progress-spinner-density($scale-theme);
7780
@include mat.radio-density($scale-theme);
81+
@include mat.progress-bar-density($scale-theme);
7882
}
7983
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
);
6565
}
6666

67+
/// Generates custom tokens for the mat-radio.
68+
/// @param {Map} $systems The MDC system tokens
69+
/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values
70+
/// @return {Map} A set of custom tokens for the mat-radio
6771
@function radio($systems, $exclude-hardcoded) {
6872
@return (
6973
ripple-color: map.get($systems, md-sys-color, on-surface),

src/material-experimental/theming/_m3-density.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,21 @@ $_density-tokens: (
2222
(mdc, elevated-card): (),
2323
(mdc, outlined-card): (),
2424
(mdc, slider): (),
25+
(mdc, snackbar): (),
2526
(mdc, plain-tooltip): (),
27+
(mdc, circular-progress): (),
2628
(mdc, radio): (
2729
state-layer-size: (40px, 36px, 32px, 28px),
2830
),
31+
(mdc, linear-progress): (),
2932
// Custom Angular Material tokens
3033
(mat, card): (),
3134
(mat, toolbar): (
3235
standard-height: (64px, 60px, 56px, 52px),
3336
mobile-height: (56px, 52px, 48px, 44px),
3437
),
3538
(mat, slider): (),
39+
(mat, snack-bar): (),
3640
(mat, radio): (),
3741
);
3842

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@
213213
mdc-tokens.md-comp-radio-button-values($systems, $exclude-hardcoded),
214214
$token-slots
215215
),
216+
_namespace-tokens(
217+
(mdc, linear-progress),
218+
mdc-tokens.md-comp-linear-progress-indicator-values($systems, $exclude-hardcoded),
219+
$token-slots),
216220
// Choose values for our made up tokens based on MDC system tokens or sensible hardcoded
217221
// values.
218222
_namespace-tokens(
Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1+
@use 'sass:map';
12
@use '../core/style/sass-utils';
23
@use '../core/theming/theming';
34
@use '../core/theming/inspection';
45
@use '../core/tokens/m2/mdc/linear-progress' as tokens-mdc-linear-progress;
56
@use '@material/linear-progress/linear-progress-theme' as mdc-linear-progress-theme;
6-
@use 'sass:map';
77

88
@mixin base($theme) {
9-
// Add default values for tokens not related to color, typography, or density.
10-
@include sass-utils.current-selector-or-root() {
11-
@include mdc-linear-progress-theme.theme(tokens-mdc-linear-progress.get-unthemable-tokens());
9+
@if inspection.get-theme-version($theme) == 1 {
10+
@include _theme-from-tokens(inspection.get-theme-tokens($theme, base));
11+
}
12+
@else {
13+
// Add default values for tokens not related to color, typography, or density.
14+
@include sass-utils.current-selector-or-root() {
15+
@include mdc-linear-progress-theme.theme(tokens-mdc-linear-progress.get-unthemable-tokens());
16+
}
1217
}
1318
}
1419

@@ -31,15 +36,20 @@
3136
}
3237

3338
@mixin color($theme) {
34-
.mat-mdc-progress-bar {
35-
@include _palette-styles($theme, primary);
39+
@if inspection.get-theme-version($theme) == 1 {
40+
@include _theme-from-tokens(inspection.get-theme-tokens($theme, color));
41+
}
42+
@else {
43+
.mat-mdc-progress-bar {
44+
@include _palette-styles($theme, primary);
3645

37-
&.mat-accent {
38-
@include _palette-styles($theme, accent);
39-
}
46+
&.mat-accent {
47+
@include _palette-styles($theme, accent);
48+
}
4049

41-
&.mat-warn {
42-
@include _palette-styles($theme, warn);
50+
&.mat-warn {
51+
@include _palette-styles($theme, warn);
52+
}
4353
}
4454
}
4555
}
@@ -50,15 +60,26 @@
5060

5161
@mixin theme($theme) {
5262
@include theming.private-check-duplicate-theme-styles($theme, 'mat-progress-bar') {
53-
@include base($theme);
54-
@if inspection.theme-has($theme, color) {
55-
@include color($theme);
56-
}
57-
@if inspection.theme-has($theme, density) {
58-
@include density($theme);
63+
@if inspection.get-theme-version($theme) == 1 {
64+
@include _theme-from-tokens(inspection.get-theme-tokens($theme));
5965
}
60-
@if inspection.theme-has($theme, typography) {
61-
@include typography($theme);
66+
@else {
67+
@include base($theme);
68+
@if inspection.theme-has($theme, color) {
69+
@include color($theme);
70+
}
71+
@if inspection.theme-has($theme, density) {
72+
@include density($theme);
73+
}
74+
@if inspection.theme-has($theme, typography) {
75+
@include typography($theme);
76+
}
6277
}
6378
}
6479
}
80+
81+
@mixin _theme-from-tokens($tokens) {
82+
@if ($tokens != ()) {
83+
@include mdc-linear-progress-theme.theme(map.get($tokens, tokens-mdc-linear-progress.$prefix));
84+
}
85+
}

0 commit comments

Comments
 (0)