@angular/material 20.1.0-next.0 → 20.1.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/autocomplete/_m2-autocomplete.scss +5 -2
  2. package/bottom-sheet/_m2-bottom-sheet.scss +6 -2
  3. package/button/_m2-button.scss +39 -34
  4. package/button/_m2-fab.scss +14 -10
  5. package/button/_m2-icon-button.scss +7 -5
  6. package/card/_m2-card.scss +1 -1
  7. package/checkbox/_m2-checkbox.scss +2 -3
  8. package/chips/_m2-chip.scss +6 -23
  9. package/core/m2/_theming.scss +72 -108
  10. package/core/option/_m2-optgroup.scss +4 -1
  11. package/core/option/_m2-option.scss +7 -6
  12. package/core/ripple/_m2-ripple.scss +6 -10
  13. package/core/selection/pseudo-checkbox/_m2-pseudo-checkbox.scss +2 -3
  14. package/core/tokens/_m2-utils.scss +1 -11
  15. package/core/tokens/_m3-system.scss +11 -9
  16. package/datepicker/_datepicker-theme.scss +16 -54
  17. package/datepicker/_m2-datepicker.scss +26 -109
  18. package/datepicker/index.d.ts +1 -1
  19. package/dialog/_m2-dialog.scss +6 -4
  20. package/divider/_m2-divider.scss +4 -2
  21. package/fesm2022/button.mjs +2 -2
  22. package/fesm2022/button.mjs.map +1 -1
  23. package/fesm2022/core.mjs +1 -1
  24. package/fesm2022/core.mjs.map +1 -1
  25. package/fesm2022/datepicker.mjs.map +1 -1
  26. package/fesm2022/slider.mjs +2 -2
  27. package/fesm2022/slider.mjs.map +1 -1
  28. package/form-field/_m2-form-field.scss +2 -2
  29. package/list/_m2-list.scss +5 -9
  30. package/menu/_m2-menu.scss +12 -9
  31. package/package.json +2 -2
  32. package/paginator/_m2-paginator.scss +2 -1
  33. package/prebuilt-themes/azure-blue.css +1 -1
  34. package/prebuilt-themes/cyan-orange.css +1 -1
  35. package/prebuilt-themes/deeppurple-amber.css +1 -1
  36. package/prebuilt-themes/indigo-pink.css +1 -1
  37. package/prebuilt-themes/magenta-violet.css +1 -1
  38. package/prebuilt-themes/pink-bluegrey.css +1 -1
  39. package/prebuilt-themes/purple-green.css +1 -1
  40. package/prebuilt-themes/rose-red.css +1 -1
  41. package/radio/_m3-radio.scss +1 -1
  42. package/schematics/ng-add/index.js +1 -1
  43. package/select/_m2-select.scss +4 -3
  44. package/select/_select-theme.scss +6 -3
  45. package/slider/_m2-slider.scss +27 -26
  46. package/slider/_slider-theme.scss +2 -2
  47. package/snack-bar/_m2-snack-bar.scss +0 -1
  48. package/sort/_m2-sort.scss +5 -2
  49. package/table/_m2-table.scss +7 -5
  50. package/tabs/_m2-tabs.scss +5 -11
  51. package/timepicker/_m2-timepicker.scss +5 -2
  52. package/toolbar/_m2-toolbar.scss +4 -2
  53. package/tree/_m2-tree.scss +5 -2
@@ -1,5 +1,6 @@
1
- @use '../core/theming/inspection';
2
1
  @use '../core/style/elevation';
2
+ @use '../core/tokens/m2-utils';
3
+ @use 'sass:map';
3
4
 
4
5
  // Tokens that can't be configured through Angular Material's current theming API,
5
6
  // but may be in a future version of the theming API.
@@ -12,8 +13,10 @@
12
13
 
13
14
  // Tokens that can be configured through Angular Material's color theming API.
14
15
  @function get-color-tokens($theme) {
16
+ $system: m2-utils.get-system($theme);
17
+
15
18
  @return (
16
- autocomplete-background-color: inspection.get-theme-color($theme, system, surface)
19
+ autocomplete-background-color: map.get($system, surface)
17
20
  );
18
21
  }
19
22
 
@@ -1,4 +1,6 @@
1
1
  @use '../core/theming/inspection';
2
+ @use '../core/tokens/m2-utils';
3
+ @use 'sass:map';
2
4
 
3
5
  // Tokens that can't be configured through Angular Material's current theming API,
4
6
  // but may be in a future version of the theming API.
@@ -11,9 +13,11 @@
11
13
 
12
14
  // Tokens that can be configured through Angular Material's color theming API.
13
15
  @function get-color-tokens($theme) {
16
+ $system: m2-utils.get-system($theme);
17
+
14
18
  @return (
15
- bottom-sheet-container-text-color: inspection.get-theme-color($theme, system, on-surface),
16
- bottom-sheet-container-background-color: inspection.get-theme-color($theme, system, surface),
19
+ bottom-sheet-container-text-color: map.get($system, on-surface),
20
+ bottom-sheet-container-background-color: map.get($system, surface),
17
21
  );
18
22
  }
19
23
 
@@ -44,7 +44,6 @@
44
44
  @function get-color-tokens($theme) {
45
45
  $system: m2-utils.get-system($theme);
46
46
  $is-dark: inspection.get-theme-type($theme) == dark;
47
- $outline: inspection.get-theme-color($theme, system, outline);
48
47
  $disabled: m3-utils.color-with-opacity(map.get($system, on-surface), 38%);
49
48
  $disabled-container : m3-utils.color-with-opacity(map.get($system, on-surface), 12%);
50
49
 
@@ -52,55 +51,56 @@
52
51
  button-filled-container-color: map.get($system, surface),
53
52
  button-filled-disabled-container-color: $disabled-container,
54
53
  button-filled-disabled-label-text-color: $disabled,
55
- button-filled-disabled-state-layer-color: inspection.get-theme-color($theme, foreground, base),
54
+ button-filled-disabled-state-layer-color: map.get($system, on-surface-variant),
56
55
  button-filled-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
57
56
  button-filled-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
58
- button-filled-label-text-color: inspection.get-theme-color($theme, foreground, base),
57
+ button-filled-label-text-color: map.get($system, on-surface),
59
58
  button-filled-pressed-state-layer-opacity: map.get($system, pressed-state-layer-opacity),
60
- button-filled-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
61
- button-filled-state-layer-color: inspection.get-theme-color($theme, foreground, base),
59
+ button-filled-ripple-color: m3-utils.color-with-opacity(
60
+ map.get($system, on-surface), map.get($system, pressed-state-layer-opacity)),
61
+ button-filled-state-layer-color: map.get($system, on-surface),
62
62
  button-outlined-disabled-label-text-color: $disabled,
63
- button-outlined-disabled-outline-color: $outline,
64
- button-outlined-disabled-state-layer-color:
65
- inspection.get-theme-color($theme, foreground, base),
63
+ button-outlined-disabled-outline-color: map.get($system, outline),
64
+ button-outlined-disabled-state-layer-color: map.get($system, on-surface-variant),
66
65
  button-outlined-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
67
66
  button-outlined-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
68
- button-outlined-label-text-color: inspection.get-theme-color($theme, foreground, base),
69
- button-outlined-outline-color: $outline,
70
- button-outlined-pressed-state-layer-opacity:
71
- map.get($system, pressed-state-layer-opacity),
72
- button-outlined-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
73
- button-outlined-state-layer-color: inspection.get-theme-color($theme, foreground, base),
67
+ button-outlined-label-text-color: map.get($system, on-surface),
68
+ button-outlined-outline-color: map.get($system, outline),
69
+ button-outlined-pressed-state-layer-opacity: map.get($system, pressed-state-layer-opacity),
70
+ button-outlined-ripple-color: m3-utils.color-with-opacity(
71
+ map.get($system, on-surface), map.get($system, pressed-state-layer-opacity)),
72
+ button-outlined-state-layer-color: map.get($system, on-surface),
74
73
  button-protected-container-color: map.get($system, surface),
75
74
  button-protected-disabled-container-color: $disabled-container,
76
75
  button-protected-disabled-label-text-color: $disabled,
77
- button-protected-disabled-state-layer-color:
78
- inspection.get-theme-color($theme, foreground, base),
76
+ button-protected-disabled-state-layer-color: map.get($system, on-surface-variant),
79
77
  button-protected-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
80
78
  button-protected-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
81
- button-protected-label-text-color: inspection.get-theme-color($theme, foreground, base),
82
- button-protected-pressed-state-layer-opacity:
83
- map.get($system, pressed-state-layer-opacity),
84
- button-protected-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
85
- button-protected-state-layer-color: inspection.get-theme-color($theme, foreground, base),
79
+ button-protected-label-text-color: map.get($system, on-surface),
80
+ button-protected-pressed-state-layer-opacity: map.get($system, pressed-state-layer-opacity),
81
+ button-protected-ripple-color: m3-utils.color-with-opacity(
82
+ map.get($system, on-surface), map.get($system, pressed-state-layer-opacity)),
83
+ button-protected-state-layer-color: map.get($system, on-surface),
86
84
  button-text-disabled-label-text-color: $disabled,
87
- button-text-disabled-state-layer-color: inspection.get-theme-color($theme, foreground, base),
85
+ button-text-disabled-state-layer-color: map.get($system, on-surface-variant),
88
86
  button-text-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
89
87
  button-text-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
90
- button-text-label-text-color: inspection.get-theme-color($theme, foreground, base),
88
+ button-text-label-text-color: map.get($system, on-surface),
91
89
  button-text-pressed-state-layer-opacity: map.get($system, pressed-state-layer-opacity),
92
- button-text-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
93
- button-text-state-layer-color: inspection.get-theme-color($theme, foreground, base),
90
+ button-text-ripple-color: m3-utils.color-with-opacity(
91
+ map.get($system, on-surface), map.get($system, pressed-state-layer-opacity)),
92
+ button-text-state-layer-color: map.get($system, on-surface),
94
93
  button-tonal-container-color: map.get($system, surface),
95
94
  button-tonal-disabled-container-color: $disabled-container,
96
95
  button-tonal-disabled-label-text-color: $disabled,
97
- button-tonal-disabled-state-layer-color: inspection.get-theme-color($theme, foreground, base),
96
+ button-tonal-disabled-state-layer-color: map.get($system, on-surface-variant),
98
97
  button-tonal-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
99
98
  button-tonal-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
100
- button-tonal-label-text-color: inspection.get-theme-color($theme, foreground, base),
99
+ button-tonal-label-text-color: map.get($system, on-surface),
101
100
  button-tonal-pressed-state-layer-opacity: map.get($system, pressed-state-layer-opacity),
102
- button-tonal-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
103
- button-tonal-state-layer-color: inspection.get-theme-color($theme, foreground, base),
101
+ button-tonal-ripple-color: m3-utils.color-with-opacity(
102
+ map.get($system, on-surface), map.get($system, pressed-state-layer-opacity)),
103
+ button-tonal-state-layer-color: map.get($system, on-surface),
104
104
  );
105
105
  }
106
106
 
@@ -116,22 +116,27 @@
116
116
  @return (
117
117
  button-filled-container-color: map.get($system, primary),
118
118
  button-filled-label-text-color: map.get($system, on-primary),
119
- button-filled-ripple-color: m3-utils.color-with-opacity(map.get($system, on-primary), 10%),
119
+ button-filled-ripple-color: m3-utils.color-with-opacity(
120
+ map.get($system, on-primary), map.get($system, pressed-state-layer-opacity)),
120
121
  button-filled-state-layer-color: map.get($system, on-primary),
121
122
  button-outlined-label-text-color: map.get($system, primary),
122
123
  button-outlined-outline-color: map.get(get-color-tokens($theme), button-outlined-outline-color),
123
- button-outlined-ripple-color: m3-utils.color-with-opacity(map.get($system, primary), 10%),
124
+ button-outlined-ripple-color: m3-utils.color-with-opacity(
125
+ map.get($system, primary), map.get($system, pressed-state-layer-opacity)),
124
126
  button-outlined-state-layer-color: map.get($system, primary),
125
127
  button-protected-container-color: map.get($system, primary),
126
128
  button-protected-label-text-color: map.get($system, on-primary),
127
- button-protected-ripple-color: m3-utils.color-with-opacity(map.get($system, on-primary), 10%),
129
+ button-protected-ripple-color: m3-utils.color-with-opacity(
130
+ map.get($system, on-primary), map.get($system, pressed-state-layer-opacity)),
128
131
  button-protected-state-layer-color: map.get($system, on-primary),
129
132
  button-text-label-text-color: map.get($system, primary),
130
- button-text-ripple-color: m3-utils.color-with-opacity(map.get($system, primary), 10%),
133
+ button-text-ripple-color: m3-utils.color-with-opacity(
134
+ map.get($system, primary), map.get($system, pressed-state-layer-opacity)),
131
135
  button-text-state-layer-color: map.get($system, primary),
132
136
  button-tonal-container-color: map.get($system, primary),
133
137
  button-tonal-label-text-color: map.get($system, on-primary),
134
- button-tonal-ripple-color: m3-utils.color-with-opacity(map.get($system, on-primary), 10%),
138
+ button-tonal-ripple-color: m3-utils.color-with-opacity(
139
+ map.get($system, on-primary), map.get($system, pressed-state-layer-opacity)),
135
140
  button-tonal-state-layer-color: map.get($system, on-primary),
136
141
  );
137
142
  }
@@ -39,23 +39,25 @@
39
39
  fab-container-color: map.get($system, surface),
40
40
  fab-disabled-state-container-color: $disabled-container,
41
41
  fab-disabled-state-foreground-color: $disabled,
42
- fab-disabled-state-layer-color: inspection.get-theme-color($theme, foreground, base),
42
+ fab-disabled-state-layer-color: map.get($system, on-surface-variant),
43
43
  fab-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
44
- fab-foreground-color: inspection.get-theme-color($theme, foreground, base),
44
+ fab-foreground-color: map.get($system, on-surface),
45
45
  fab-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
46
46
  fab-pressed-state-layer-opacity: map.get($system, pressed-state-layer-opacity),
47
- fab-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
47
+ fab-ripple-color: m3-utils.color-with-opacity(
48
+ map.get($system, on-surface), map.get($system, pressed-state-layer-opacity)),
48
49
  fab-small-container-color: map.get($system, surface),
49
50
  fab-small-disabled-state-container-color: $disabled-container,
50
51
  fab-small-disabled-state-foreground-color: $disabled,
51
- fab-small-disabled-state-layer-color: inspection.get-theme-color($theme, foreground, base),
52
+ fab-small-disabled-state-layer-color: map.get($system, on-surface-variant),
52
53
  fab-small-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
53
- fab-small-foreground-color: inspection.get-theme-color($theme, foreground, base),
54
+ fab-small-foreground-color: map.get($system, on-surface),
54
55
  fab-small-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
55
56
  fab-small-pressed-state-layer-opacity: map.get($system, pressed-state-layer-opacity),
56
- fab-small-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
57
- fab-small-state-layer-color: inspection.get-theme-color($theme, foreground, base),
58
- fab-state-layer-color: inspection.get-theme-color($theme, foreground, base),
57
+ fab-small-ripple-color: m3-utils.color-with-opacity(
58
+ map.get($system, on-surface), map.get($system, pressed-state-layer-opacity)),
59
+ fab-small-state-layer-color: map.get($system, on-surface),
60
+ fab-state-layer-color: map.get($system, on-surface),
59
61
  );
60
62
  }
61
63
 
@@ -67,10 +69,12 @@
67
69
  @return (
68
70
  fab-container-color: map.get($system, primary),
69
71
  fab-foreground-color: map.get($system, on-primary),
70
- fab-ripple-color: m3-utils.color-with-opacity(map.get($system, on-primary), 10%),
72
+ fab-ripple-color: m3-utils.color-with-opacity(
73
+ map.get($system, primary), map.get($system, pressed-state-layer-opacity)),
71
74
  fab-small-container-color: map.get($system, primary),
72
75
  fab-small-foreground-color: map.get($system, on-primary),
73
- fab-small-ripple-color: m3-utils.color-with-opacity(map.get($system, on-primary), 10%),
76
+ fab-small-ripple-color: m3-utils.color-with-opacity(
77
+ map.get($system, on-primary), map.get($system, pressed-state-layer-opacity)),
74
78
  fab-small-state-layer-color: map.get($system, on-primary),
75
79
  fab-state-layer-color: map.get($system, on-primary),
76
80
  );
@@ -19,14 +19,15 @@
19
19
  $is-dark: inspection.get-theme-type($theme) == dark;
20
20
 
21
21
  @return (
22
- icon-button-disabled-icon-color: if($is-dark, rgba(#fff, 0.5), rgba(#000, 0.38)),
23
- icon-button-disabled-state-layer-color: inspection.get-theme-color($theme, foreground, base),
22
+ icon-button-disabled-icon-color: m3-utils.color-with-opacity(map.get($system, on-surface), 38%),
23
+ icon-button-disabled-state-layer-color: map.get($system, on-surface-variant),
24
24
  icon-button-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
25
25
  icon-button-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
26
26
  icon-button-icon-color: inherit,
27
27
  icon-button-pressed-state-layer-opacity: map.get($system, pressed-state-layer-opacity),
28
- icon-button-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
29
- icon-button-state-layer-color: inspection.get-theme-color($theme, foreground, base),
28
+ icon-button-ripple-color: m3-utils.color-with-opacity(
29
+ map.get($system, on-surface), map.get($system, pressed-state-layer-opacity)),
30
+ icon-button-state-layer-color: map.get($system, on-surface),
30
31
  );
31
32
  }
32
33
 
@@ -38,7 +39,8 @@
38
39
  @return (
39
40
  icon-button-icon-color: map.get($system, primary),
40
41
  icon-button-state-layer-color: map.get($system, primary),
41
- icon-button-ripple-color: m3-utils.color-with-opacity(map.get($system, primary), 10%),
42
+ icon-button-ripple-color: m3-utils.color-with-opacity(
43
+ map.get($system, primary), map.get($system, pressed-state-layer-opacity)),
42
44
  );
43
45
  }
44
46
 
@@ -23,7 +23,7 @@
23
23
  card-elevated-container-elevation: elevation.get-box-shadow(1),
24
24
  card-outlined-container-color: map.get($system, surface),
25
25
  card-outlined-container-elevation: elevation.get-box-shadow(0),
26
- card-outlined-outline-color: inspection.get-theme-color($theme, system, outline),
26
+ card-outlined-outline-color: map.get($system, outline),
27
27
  card-subtitle-text-color: map.get($system, on-surface-variant),
28
28
  card-filled-container-color: map.get($system, surface),
29
29
  card-filled-container-elevation: elevation.get-box-shadow(0)
@@ -10,7 +10,7 @@
10
10
  $system: m2-utils.get-system($theme);
11
11
 
12
12
  @return (
13
- checkbox-disabled-selected-checkmark-color: #fff,
13
+ checkbox-disabled-selected-checkmark-color: map.get($system, surface),
14
14
  checkbox-selected-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
15
15
  checkbox-selected-hover-state-layer-opacity: map.get($system, hover-state-layer-opacity),
16
16
  checkbox-selected-pressed-state-layer-opacity: map.get($system, pressed-state-layer-opacity),
@@ -25,7 +25,6 @@
25
25
  $system: m2-utils.get-system($theme);
26
26
  $system: m3-utils.replace-colors-with-variant($system, secondary, $color-variant);
27
27
  $is-dark: inspection.get-theme-type($theme) == dark;
28
- $foreground-base: inspection.get-theme-color($theme, foreground, base);
29
28
  $disabled: m3-utils.color-with-opacity(map.get($system, on-surface), 38%);
30
29
 
31
30
  $tokens: (
@@ -46,7 +45,7 @@
46
45
  checkbox-selected-pressed-state-layer-color: map.get($system, secondary),
47
46
  checkbox-unselected-focus-state-layer-color: map.get($system, on-surface),
48
47
  checkbox-unselected-hover-state-layer-color: map.get($system, on-surface),
49
- checkbox-unselected-pressed-state-layer-color: $foreground-base,
48
+ checkbox-unselected-pressed-state-layer-color: map.get($system, on-surface),
50
49
  );
51
50
 
52
51
  @each $token in $exclude {
@@ -1,8 +1,5 @@
1
1
  @use 'sass:map';
2
- @use 'sass:meta';
3
- @use 'sass:color';
4
2
  @use '../core/theming/inspection';
5
- @use '../core/m2/palette' as m2-palette;
6
3
  @use '../core/theming/theming';
7
4
  @use '../core/tokens/m2-utils';
8
5
  @use '../core/tokens/m3-utils';
@@ -40,38 +37,24 @@
40
37
  // Tokens that can be configured through Angular Material's color theming API.
41
38
  @function get-color-tokens($theme, $color-variant: null) {
42
39
  $system: m2-utils.get-system($theme);
43
- $foreground: null;
44
- $background: null;
45
- $state-layer-color: inspection.get-theme-color($theme, foreground, base);
40
+ $background: m3-utils.color-with-opacity(map.get($system, on-surface), 12%);
41
+ $foreground: map.get($system, on-surface);
46
42
 
47
- @if $color-variant == null {
48
- $is-dark: inspection.get-theme-type($theme) == dark;
49
- $grey-50: map.get(m2-palette.$grey-palette, 50);
50
- $grey-900: map.get(m2-palette.$grey-palette, 900);
51
- $foreground: if($is-dark, $grey-50, $grey-900);
52
-
53
- $surface: map.get($system, surface);
54
- $background: if(
55
- meta.type-of($state-layer-color) == color and meta.type-of($surface) == color,
56
- color.mix($state-layer-color, $surface, 12%),
57
- $state-layer-color
58
- );
59
- }
60
- @else {
43
+ @if $color-variant {
61
44
  $system: m3-utils.replace-colors-with-variant($system, primary, $color-variant);
62
-
63
45
  $background: map.get($system, primary);
64
46
  $foreground: map.get($system, on-primary);
65
47
  }
48
+
66
49
  @return (
67
50
  chip-disabled-label-text-color: $foreground,
68
51
  chip-elevated-container-color: $background,
69
52
  chip-elevated-disabled-container-color: $background,
70
53
  chip-elevated-selected-container-color: $background,
71
54
  chip-flat-disabled-selected-container-color: $background,
72
- chip-focus-state-layer-color: $state-layer-color,
55
+ chip-focus-state-layer-color: map.get($system, on-surface),
73
56
  chip-focus-state-layer-opacity: map.get($system, focus-state-layer-opacity),
74
- chip-hover-state-layer-color: $state-layer-color,
57
+ chip-hover-state-layer-color: map.get($system, on-surface),
75
58
  chip-label-text-color: $foreground,
76
59
  chip-selected-disabled-trailing-icon-color: $foreground,
77
60
  chip-selected-focus-state-layer-color: map.get($system, focus-state-layer-opacity),
@@ -113,18 +113,34 @@
113
113
  @return $theme;
114
114
  }
115
115
 
116
- // Creates a light-themed color configuration from the specified
117
- // primary, accent and warn palettes.
118
- @function _mat-create-light-color-config($primary, $accent, $warn: null) {
119
- $warn: if($warn != null, $warn, define-palette(palette.$red-palette));
120
- @return (
121
- primary: $primary,
122
- accent: $accent,
123
- warn: $warn,
124
- is-dark: false,
125
- foreground: palette.$light-theme-foreground-palette,
126
- background: palette.$light-theme-background-palette,
127
- system: (
116
+ @function _define-system($primary, $accent, $warn, $is-dark) {
117
+ $system: (
118
+ primary: map.get($primary, default),
119
+ on-primary: map.get($primary, default-contrast),
120
+ secondary: map.get($accent, default),
121
+ on-secondary: map.get($accent, default-contrast),
122
+ error: map.get($warn, default),
123
+ on-error: map.get($warn, default-contrast),
124
+ shadow: black,
125
+ hover-state-layer-opacity: 0.04,
126
+ focus-state-layer-opacity: 0.12,
127
+ pressed-state-layer-opacity: 0.12,
128
+ );
129
+
130
+ @if $is-dark {
131
+ @return map.merge($system, (
132
+ surface: map.get(palette.$grey-palette, 800),
133
+ surface-variant: #4a4a4a,
134
+ on-surface: white,
135
+ on-surface-variant: rgba(white, 0.7),
136
+ background: #303030,
137
+ inverse-surface: white,
138
+ inverse-on-surface: rgba(black, 0.87),
139
+ outline: rgba(white, 0.12),
140
+ outline-variant: rgba(white, 0.38),
141
+ ));
142
+ } @else {
143
+ @return map.merge($system, (
128
144
  surface: white,
129
145
  surface-variant: #f6f6f6,
130
146
  on-surface: rgba(black, 0.87),
@@ -134,62 +150,34 @@
134
150
  inverse-on-surface: white,
135
151
  outline: rgba(black, 0.12),
136
152
  outline-variant: rgba(black, 0.38),
137
- hover-state-layer-opacity: 0.04,
138
- focus-state-layer-opacity: 0.12,
139
- pressed-state-layer-opacity: 0.12,
140
- shadow: black,
141
- primary: map.get($primary, default),
142
- on-primary: map.get($primary, default-contrast),
143
- secondary: map.get($accent, default),
144
- on-secondary: map.get($accent, default-contrast),
145
- error: map.get($warn, default),
146
- on-error: map.get($warn, default-contrast),
147
- ),
148
- );
153
+ ));
154
+ }
149
155
  }
150
156
 
151
- // Creates a dark-themed color configuration from the specified
157
+ // Creates a color configuration from the specified
152
158
  // primary, accent and warn palettes.
153
- @function _mat-create-dark-color-config($primary, $accent, $warn: null) {
159
+ @function _mat-create-color-config($primary, $accent, $warn: null, $is-dark) {
154
160
  $warn: if($warn != null, $warn, define-palette(palette.$red-palette));
161
+ $foreground:
162
+ if($is-dark, palette.$dark-theme-foreground-palette, palette.$light-theme-foreground-palette);
163
+ $background:
164
+ if($is-dark, palette.$dark-theme-background-palette, palette.$light-theme-background-palette);
165
+
155
166
  @return (
156
167
  primary: $primary,
157
168
  accent: $accent,
158
169
  warn: $warn,
159
- is-dark: true,
160
- foreground: palette.$dark-theme-foreground-palette,
161
- background: palette.$dark-theme-background-palette,
162
- system: (
163
- surface: map.get(palette.$grey-palette, 800),
164
- surface-variant: #4a4a4a,
165
- on-surface: white,
166
- on-surface-variant: rgba(white, 0.7),
167
- background: #303030,
168
- inverse-surface: white,
169
- inverse-on-surface: rgba(black, 0.87),
170
- outline: rgba(white, 0.12),
171
- outline-variant: rgba(white, 0.38),
172
- hover-state-layer-opacity: 0.04,
173
- focus-state-layer-opacity: 0.12,
174
- pressed-state-layer-opacity: 0.12,
175
- shadow: black,
176
- primary: map.get($primary, default),
177
- on-primary: map.get($primary, default-contrast),
178
- secondary: map.get($accent, default),
179
- on-secondary: map.get($accent, default-contrast),
180
- error: map.get($warn, default),
181
- on-error: map.get($warn, default-contrast),
182
- ),
170
+ is-dark: $is-dark,
171
+ foreground: $foreground,
172
+ background: $background,
183
173
  );
184
174
  }
185
175
 
186
- // TODO: Remove legacy API and rename `$primary` below to `$config`. Currently it cannot be renamed
187
- // as it would break existing apps that set the parameter by name.
188
-
189
- /// Creates a container object for a light theme to be given to individual component theme mixins.
176
+ /// Creates a container object for a theme to be given to individual component theme mixins.
190
177
  /// @param {Map} $primary The theme configuration object.
191
178
  /// @returns {Map} A complete Angular Material theme map.
192
- @function define-light-theme($primary, $accent: null, $warn: define-palette(palette.$red-palette)) {
179
+ @function _define-theme(
180
+ $primary, $accent: null, $warn: define-palette(palette.$red-palette), $is-dark) {
193
181
  // This function creates a container object for the individual component theme mixins. Consumers
194
182
  // can construct such an object by calling this function, or by building the object manually.
195
183
  // There are two possible ways to invoke this function in order to create such an object:
@@ -206,13 +194,15 @@
206
194
  @if $accent != null {
207
195
  @warn theming.$private-legacy-theme-warning;
208
196
  $theme: _mat-validate-theme(
209
- (
210
- _is-legacy-theme: true,
211
- color: _mat-create-light-color-config($primary, $accent, $warn),
212
- )
197
+ (
198
+ _is-legacy-theme: true,
199
+ color: _mat-create-color-config($primary, $accent, $warn, $is-dark),
200
+ )
213
201
  );
214
202
 
215
- @return _internalize-theme(theming.private-create-backwards-compatibility-theme($theme));
203
+ $theme: _internalize-theme(theming.private-create-backwards-compatibility-theme($theme));
204
+ $theme: map.set($theme, _mat-system, _define-system($primary, $accent, $warn, $is-dark));
205
+ @return $theme;
216
206
  }
217
207
  // If the map pattern is used (1), we just pass-through the configurations for individual
218
208
  // parts of the theming system, but update the `color` configuration if set. As explained
@@ -224,15 +214,30 @@
224
214
  $accent: map.get($color-settings, accent);
225
215
  $warn: map.get($color-settings, warn);
226
216
  $result: map.merge(
227
- $result,
228
- (
229
- color: _mat-create-light-color-config($primary, $accent, $warn),
230
- )
217
+ $result,
218
+ (
219
+ color: _mat-create-color-config($primary, $accent, $warn, $is-dark),
220
+ )
231
221
  );
232
222
  }
233
- @return _internalize-theme(
234
- theming.private-create-backwards-compatibility-theme(_mat-validate-theme($result))
223
+ $theme: _internalize-theme(
224
+ theming.private-create-backwards-compatibility-theme(_mat-validate-theme($result))
235
225
  );
226
+ $primary: map.get($result, primary) or map.get($result, color, primary) or ();
227
+ $accent: map.get($result, accent) or map.get($result, color, accent) or ();
228
+ $warn: map.get($result, warn) or map.get($result, color, warn) or ();
229
+ $theme: map.set($theme, _mat-system, _define-system($primary, $accent, $warn, $is-dark));
230
+ @return $theme;
231
+ }
232
+
233
+ // TODO: Remove legacy API and rename `$primary` below to `$config`. Currently it cannot be renamed
234
+ // as it would break existing apps that set the parameter by name.
235
+
236
+ /// Creates a container object for a light theme to be given to individual component theme mixins.
237
+ /// @param {Map} $primary The theme configuration object.
238
+ /// @returns {Map} A complete Angular Material theme map.
239
+ @function define-light-theme($primary, $accent: null, $warn: define-palette(palette.$red-palette)) {
240
+ @return _define-theme($primary, $accent, $warn, false);
236
241
  }
237
242
 
238
243
  // TODO: Remove legacy API and rename below `$primary` to `$config`. Currently it cannot be renamed
@@ -242,48 +247,7 @@
242
247
  /// @param {Map} $primary The theme configuration object.
243
248
  /// @returns {Map} A complete Angular Material theme map.
244
249
  @function define-dark-theme($primary, $accent: null, $warn: define-palette(palette.$red-palette)) {
245
- // This function creates a container object for the individual component theme mixins. Consumers
246
- // can construct such an object by calling this function, or by building the object manually.
247
- // There are two possible ways to invoke this function in order to create such an object:
248
- //
249
- // (1) Passing in a map that holds optional configurations for individual parts of the
250
- // theming system. For `color` configurations, the function only expects the palettes
251
- // for `primary` and `accent` (and optionally `warn`). The function will expand the
252
- // shorthand into an actual configuration that can be consumed in `-color` mixins.
253
- // (2) Legacy pattern: Passing in the palettes as parameters. This is not as flexible
254
- // as passing in a configuration map because only the `color` system can be configured.
255
- //
256
- // If the legacy pattern is used, we generate a container object only with a dark-themed
257
- // configuration for the `color` theming part.
258
- @if $accent != null {
259
- @warn theming.$private-legacy-theme-warning;
260
- $theme: _mat-validate-theme(
261
- (
262
- _is-legacy-theme: true,
263
- color: _mat-create-dark-color-config($primary, $accent, $warn),
264
- )
265
- );
266
- @return _internalize-theme(theming.private-create-backwards-compatibility-theme($theme));
267
- }
268
- // If the map pattern is used (1), we just pass-through the configurations for individual
269
- // parts of the theming system, but update the `color` configuration if set. As explained
270
- // above, the color shorthand will be expanded to an actual dark-themed color configuration.
271
- $result: $primary;
272
- @if map.get($primary, color) {
273
- $color-settings: map.get($primary, color);
274
- $primary: map.get($color-settings, primary);
275
- $accent: map.get($color-settings, accent);
276
- $warn: map.get($color-settings, warn);
277
- $result: map.merge(
278
- $result,
279
- (
280
- color: _mat-create-dark-color-config($primary, $accent, $warn),
281
- )
282
- );
283
- }
284
- @return _internalize-theme(
285
- theming.private-create-backwards-compatibility-theme(_mat-validate-theme($result))
286
- );
250
+ @return _define-theme($primary, $accent, $warn, true);
287
251
  }
288
252
 
289
253
  /// Gets the color configuration from the given theme or configuration.
@@ -1,4 +1,6 @@
1
1
  @use '../theming/inspection';
2
+ @use '../tokens/m2-utils';
3
+ @use 'sass:map';
2
4
 
3
5
  // Tokens that can't be configured through Angular Material's current theming API,
4
6
  // but may be in a future version of the theming API.
@@ -8,8 +10,9 @@
8
10
 
9
11
  // Tokens that can be configured through Angular Material's color theming API.
10
12
  @function get-color-tokens($theme) {
13
+ $system: m2-utils.get-system($theme);
11
14
  @return (
12
- optgroup-label-text-color: inspection.get-theme-color($theme, system, on-surface),
15
+ optgroup-label-text-color: map.get($system, on-surface),
13
16
  );
14
17
  }
15
18
 
@@ -12,17 +12,18 @@
12
12
  // Tokens that can be configured through Angular Material's color theming API.
13
13
  @function get-color-tokens($theme, $color-variant) {
14
14
  $is-dark: inspection.get-theme-type($theme) == dark;
15
- $active-state-layer-color: inspection.get-theme-color($theme, foreground, base,
16
- if($is-dark, 0.08, 0.04));
17
15
  $system: m2-utils.get-system($theme);
18
16
  $system: m3-utils.replace-colors-with-variant($system, primary, $color-variant);
19
17
 
20
18
  @return (
21
19
  option-selected-state-label-text-color: map.get($system, primary),
22
- option-label-text-color: inspection.get-theme-color($theme, system, on-surface),
23
- option-hover-state-layer-color: $active-state-layer-color,
24
- option-focus-state-layer-color: $active-state-layer-color,
25
- option-selected-state-layer-color: $active-state-layer-color,
20
+ option-label-text-color: map.get($system, on-surface),
21
+ option-hover-state-layer-color: m3-utils.color-with-opacity(
22
+ map.get($system, on-surface), map.get($system, hover-state-layer-opacity)),
23
+ option-focus-state-layer-color: m3-utils.color-with-opacity(
24
+ map.get($system, on-surface), map.get($system, focus-state-layer-opacity)),
25
+ option-selected-state-layer-color: m3-utils.color-with-opacity(
26
+ map.get($system, on-surface), map.get($system, pressed-state-layer-opacity)),
26
27
  );
27
28
  }
28
29
 
@@ -1,5 +1,6 @@
1
- @use 'sass:meta';
2
- @use '../theming/inspection';
1
+ @use 'sass:map';
2
+ @use '../tokens/m2-utils';
3
+ @use '../tokens/m3-utils';
3
4
 
4
5
  // Tokens that can't be configured through Angular Material's current theming API,
5
6
  // but may be in a future version of the theming API.
@@ -9,16 +10,11 @@
9
10
 
10
11
  // Tokens that can be configured through Angular Material's color theming API.
11
12
  @function get-color-tokens($theme) {
12
- $is-dark: inspection.get-theme-type($theme) == dark;
13
- $base: inspection.get-theme-color($theme, foreground, base);
14
-
15
- // If the base is a color *type* we can use it directly in the `rgba` call below.
16
- // If it's anything else (e.g. a CSS variable) we fall back to using static colors
17
- // since we don't have a way of adjusting the opacity.
18
- $color: if(meta.type-of($base) == color, $base, if($is-dark, #fff, #000));
13
+ $system: m2-utils.get-system($theme);
19
14
 
20
15
  @return (
21
- ripple-color: rgba($color, 0.1),
16
+ ripple-color: m3-utils.color-with-opacity(
17
+ map.get($system, on-surface), map.get($system, pressed-state-layer-opacity)),
22
18
  );
23
19
  }
24
20