@angular/material 16.1.5 → 16.1.6

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 (62) hide show
  1. package/bottom-sheet/_bottom-sheet-theme.scss +10 -11
  2. package/button-toggle/_button-toggle-theme.scss +20 -97
  3. package/button-toggle/_button-toggle-variables.scss +2 -0
  4. package/core/tokens/_token-utils.scss +1 -0
  5. package/core/tokens/m2/mat/_bottom-sheet.scss +56 -0
  6. package/core/tokens/m2/mat/_divider.scss +45 -0
  7. package/core/tokens/m2/mat/_legacy-button-toggle.scss +63 -0
  8. package/core/tokens/m2/mat/_sidenav.scss +65 -0
  9. package/core/tokens/m2/mat/_standard-button-toggle.scss +87 -0
  10. package/core/tokens/m2/mat/_toolbar.scss +79 -0
  11. package/divider/_divider-theme.scss +6 -8
  12. package/esm2022/bottom-sheet/bottom-sheet-container.mjs +3 -3
  13. package/esm2022/button-toggle/button-toggle.mjs +2 -2
  14. package/esm2022/chips/chip-option.mjs +2 -2
  15. package/esm2022/chips/chip-row.mjs +10 -7
  16. package/esm2022/chips/chip.mjs +2 -2
  17. package/esm2022/core/version.mjs +1 -1
  18. package/esm2022/divider/divider.mjs +2 -2
  19. package/esm2022/form-field/form-field.mjs +3 -3
  20. package/esm2022/menu/menu-item.mjs +4 -4
  21. package/esm2022/menu/menu.mjs +3 -3
  22. package/esm2022/radio/radio.mjs +13 -1
  23. package/esm2022/sidenav/drawer.mjs +3 -3
  24. package/esm2022/sidenav/sidenav.mjs +3 -3
  25. package/esm2022/slide-toggle/slide-toggle.mjs +2 -2
  26. package/esm2022/toolbar/toolbar.mjs +2 -2
  27. package/fesm2022/bottom-sheet.mjs +2 -2
  28. package/fesm2022/bottom-sheet.mjs.map +1 -1
  29. package/fesm2022/button-toggle.mjs +2 -2
  30. package/fesm2022/button-toggle.mjs.map +1 -1
  31. package/fesm2022/chips.mjs +13 -10
  32. package/fesm2022/chips.mjs.map +1 -1
  33. package/fesm2022/core.mjs +1 -1
  34. package/fesm2022/core.mjs.map +1 -1
  35. package/fesm2022/divider.mjs +2 -2
  36. package/fesm2022/divider.mjs.map +1 -1
  37. package/fesm2022/form-field.mjs +2 -2
  38. package/fesm2022/form-field.mjs.map +1 -1
  39. package/fesm2022/menu.mjs +5 -5
  40. package/fesm2022/menu.mjs.map +1 -1
  41. package/fesm2022/radio.mjs +12 -0
  42. package/fesm2022/radio.mjs.map +1 -1
  43. package/fesm2022/sidenav.mjs +4 -4
  44. package/fesm2022/sidenav.mjs.map +1 -1
  45. package/fesm2022/slide-toggle.mjs +2 -2
  46. package/fesm2022/slide-toggle.mjs.map +1 -1
  47. package/fesm2022/toolbar.mjs +2 -2
  48. package/fesm2022/toolbar.mjs.map +1 -1
  49. package/legacy-prebuilt-themes/legacy-deeppurple-amber.css +1 -1
  50. package/legacy-prebuilt-themes/legacy-indigo-pink.css +1 -1
  51. package/legacy-prebuilt-themes/legacy-pink-bluegrey.css +1 -1
  52. package/legacy-prebuilt-themes/legacy-purple-green.css +1 -1
  53. package/package.json +2 -2
  54. package/prebuilt-themes/deeppurple-amber.css +1 -1
  55. package/prebuilt-themes/indigo-pink.css +1 -1
  56. package/prebuilt-themes/pink-bluegrey.css +1 -1
  57. package/prebuilt-themes/purple-green.css +1 -1
  58. package/radio/index.d.ts +4 -1
  59. package/schematics/ng-add/index.js +1 -1
  60. package/schematics/ng-add/index.mjs +1 -1
  61. package/sidenav/_sidenav-theme.scss +6 -69
  62. package/toolbar/_toolbar-theme.scss +25 -71
@@ -1,26 +1,25 @@
1
- @use 'sass:map';
2
- @use '../core/style/private';
3
1
  @use '../core/typography/typography';
4
- @use '../core/typography/typography-utils';
5
2
  @use '../core/theming/theming';
3
+ @use '../core/style/sass-utils';
4
+ @use '../core/tokens/token-utils';
5
+ @use '../core/tokens/m2/mat/bottom-sheet' as tokens-mat-bottom-sheet;
6
6
 
7
7
  @mixin color($config-or-theme) {
8
8
  $config: theming.get-color-config($config-or-theme);
9
- $background: map.get($config, background);
10
- $foreground: map.get($config, foreground);
11
9
 
12
- .mat-bottom-sheet-container {
13
- @include private.private-theme-elevation(16, $config);
14
- background: theming.get-color-from-palette($background, dialog);
15
- color: theming.get-color-from-palette($foreground, text);
10
+ @include sass-utils.current-selector-or-root() {
11
+ @include token-utils.create-token-values(tokens-mat-bottom-sheet.$prefix,
12
+ tokens-mat-bottom-sheet.get-color-tokens($config));
16
13
  }
17
14
  }
18
15
 
19
16
  @mixin typography($config-or-theme) {
20
17
  $config: typography.private-typography-to-2014-config(
21
18
  theming.get-typography-config($config-or-theme));
22
- .mat-bottom-sheet-container {
23
- @include typography-utils.typography-level($config, body-1);
19
+
20
+ @include sass-utils.current-selector-or-root() {
21
+ @include token-utils.create-token-values(tokens-mat-bottom-sheet.$prefix,
22
+ tokens-mat-bottom-sheet.get-typography-tokens($config));
24
23
  }
25
24
  }
26
25
 
@@ -1,118 +1,41 @@
1
- @use 'sass:map';
2
- @use '../core/style/private';
3
1
  @use '../core/theming/theming';
4
2
  @use '../core/typography/typography';
5
- @use '../core/typography/typography-utils';
6
- @use '../core/density/private/compatibility';
7
- @use './button-toggle-variables';
3
+ @use '../core/tokens/m2/mat/legacy-button-toggle' as tokens-mat-legacy-button-toggle;
4
+ @use '../core/tokens/m2/mat/standard-button-toggle' as tokens-mat-standard-button-toggle;
5
+ @use '../core/tokens/token-utils';
6
+ @use '../core/style/sass-utils';
8
7
 
9
8
  @mixin color($config-or-theme) {
10
9
  $config: theming.get-color-config($config-or-theme);
11
- $foreground: map.get($config, foreground);
12
- $background: map.get($config, background);
13
- $divider-color: theming.get-color-from-palette($foreground, divider);
14
- $theme-divider-color: map.get($foreground, divider);
15
10
 
16
- // By default the theme usually has an rgba color for the dividers, which can
17
- // stack up with the background of a button toggle. This can cause the border
18
- // of a selected toggle to look different from an deselected one. We use a solid
19
- // color to ensure that the border always stays the same.
20
- $divider-color: if(type-of($theme-divider-color) == color,
21
- theming.private-rgba-to-hex($theme-divider-color, map.get($background, card)),
22
- $theme-divider-color
23
- );
24
-
25
- .mat-button-toggle-standalone,
26
- .mat-button-toggle-group {
27
- @include private.private-theme-overridable-elevation(2, $config);
28
- }
29
-
30
- .mat-button-toggle-standalone.mat-button-toggle-appearance-standard,
31
- .mat-button-toggle-group-appearance-standard {
32
- &:not([class*='mat-elevation-z']) {
33
- box-shadow: none;
34
- }
35
- }
36
-
37
- .mat-button-toggle {
38
- color: theming.get-color-from-palette($foreground, hint-text);
39
-
40
- .mat-button-toggle-focus-overlay {
41
- background-color: theming.get-color-from-palette($background, focused-button);
42
- }
43
- }
44
-
45
- .mat-button-toggle-appearance-standard {
46
- color: theming.get-color-from-palette($foreground, text);
47
- background: theming.get-color-from-palette($background, card);
48
-
49
- .mat-button-toggle-focus-overlay {
50
- background-color: theming.get-color-from-palette($background, focused-button, 1);
51
- }
52
- }
53
-
54
- .mat-button-toggle-group-appearance-standard .mat-button-toggle + .mat-button-toggle {
55
- border-left: solid 1px $divider-color;
56
- }
57
-
58
- [dir='rtl'] .mat-button-toggle-group-appearance-standard .mat-button-toggle + .mat-button-toggle {
59
- border-left: none;
60
- border-right: solid 1px $divider-color;
61
- }
62
-
63
- .mat-button-toggle-group-appearance-standard.mat-button-toggle-vertical {
64
- .mat-button-toggle + .mat-button-toggle {
65
- border-left: none;
66
- border-right: none;
67
- border-top: solid 1px $divider-color;
68
- }
69
- }
70
-
71
- .mat-button-toggle-checked {
72
- background-color: theming.get-color-from-palette($background, selected-button);
73
- color: theming.get-color-from-palette($foreground, secondary-text);
74
-
75
- &.mat-button-toggle-appearance-standard {
76
- color: theming.get-color-from-palette($foreground, text);
77
- }
78
- }
79
-
80
- .mat-button-toggle-disabled {
81
- color: theming.get-color-from-palette($foreground, disabled-button);
82
- background-color: theming.get-color-from-palette($background, disabled-button-toggle);
83
-
84
- &.mat-button-toggle-appearance-standard {
85
- background: theming.get-color-from-palette($background, card);
86
- }
87
-
88
- &.mat-button-toggle-checked {
89
- background-color: theming.get-color-from-palette($background, selected-disabled-button);
90
- }
91
- }
92
-
93
- .mat-button-toggle-standalone.mat-button-toggle-appearance-standard,
94
- .mat-button-toggle-group-appearance-standard {
95
- border: solid 1px $divider-color;
11
+ @include sass-utils.current-selector-or-root() {
12
+ @include token-utils.create-token-values(tokens-mat-legacy-button-toggle.$prefix,
13
+ tokens-mat-legacy-button-toggle.get-color-tokens($config));
14
+ @include token-utils.create-token-values(tokens-mat-standard-button-toggle.$prefix,
15
+ tokens-mat-standard-button-toggle.get-color-tokens($config));
96
16
  }
97
17
  }
98
18
 
99
19
  @mixin typography($config-or-theme) {
100
20
  $config: typography.private-typography-to-2014-config(
101
21
  theming.get-typography-config($config-or-theme));
102
- .mat-button-toggle {
103
- font-family: typography-utils.font-family($config);
22
+
23
+ @include sass-utils.current-selector-or-root() {
24
+ @include token-utils.create-token-values(tokens-mat-legacy-button-toggle.$prefix,
25
+ tokens-mat-legacy-button-toggle.get-typography-tokens($config));
26
+ @include token-utils.create-token-values(tokens-mat-standard-button-toggle.$prefix,
27
+ tokens-mat-standard-button-toggle.get-typography-tokens($config));
104
28
  }
105
29
  }
106
30
 
107
31
  @mixin density($config-or-theme) {
108
32
  $density-scale: theming.get-density-config($config-or-theme);
109
- $standard-height: compatibility.private-density-prop-value(
110
- button-toggle-variables.$standard-density-config, $density-scale, height);
111
33
 
112
- @include compatibility.private-density-legacy-compatibility() {
113
- .mat-button-toggle-appearance-standard .mat-button-toggle-label-content {
114
- line-height: $standard-height;
115
- }
34
+ @include sass-utils.current-selector-or-root() {
35
+ @include token-utils.create-token-values(tokens-mat-legacy-button-toggle.$prefix,
36
+ tokens-mat-legacy-button-toggle.get-density-tokens($density-scale));
37
+ @include token-utils.create-token-values(tokens-mat-standard-button-toggle.$prefix,
38
+ tokens-mat-standard-button-toggle.get-density-tokens($density-scale));
116
39
  }
117
40
  }
118
41
 
@@ -1,3 +1,5 @@
1
+ // TODO(crisbeto): this file isn't used anymore and should be removed.
2
+
1
3
  $standard-height: 48px !default;
2
4
  // Minimum height for highest density can vary based on the content that developers
3
5
  // project into button-toggle's. We use a minimum of `24px` though because commonly
@@ -40,6 +40,7 @@ $placeholder-typography-config: (
40
40
  button: $_placeholder-typography-level-config,
41
41
  overline: $_placeholder-typography-level-config,
42
42
  subheading-1: $_placeholder-typography-level-config,
43
+ title: $_placeholder-typography-level-config,
43
44
  );
44
45
 
45
46
  // Placeholder density config that can be passed to token getter functions when generating token
@@ -0,0 +1,56 @@
1
+ @use 'sass:map';
2
+ @use '../../token-utils';
3
+ @use '../../../typography/typography-utils';
4
+ @use '../../../theming/theming';
5
+ @use '../../../style/sass-utils';
6
+
7
+ // The prefix used to generate the fully qualified name for tokens in this file.
8
+ $prefix: (mat, bottom-sheet);
9
+
10
+ // Tokens that can't be configured through Angular Material's current theming API,
11
+ // but may be in a future version of the theming API.
12
+ @function get-unthemable-tokens() {
13
+ @return (
14
+ // TODO: will be necessary for M3.
15
+ container-shape: 4px,
16
+ );
17
+ }
18
+
19
+ // Tokens that can be configured through Angular Material's color theming API.
20
+ @function get-color-tokens($config) {
21
+ $foreground: map.get($config, foreground);
22
+ $background: map.get($config, background);
23
+
24
+ @return (
25
+ container-text-color: theming.get-color-from-palette($foreground, text),
26
+ container-background-color: theming.get-color-from-palette($background, dialog),
27
+ );
28
+ }
29
+
30
+ // Tokens that can be configured through Angular Material's typography theming API.
31
+ @function get-typography-tokens($config) {
32
+ @return (
33
+ container-text-font: typography-utils.font-family($config, body-1) or
34
+ typography-utils.font-family($config),
35
+ container-text-line-height: typography-utils.line-height($config, body-1),
36
+ container-text-size: typography-utils.font-size($config, body-1),
37
+ container-text-tracking: typography-utils.letter-spacing($config, body-1),
38
+ container-text-weight: typography-utils.font-weight($config, body-1),
39
+ );
40
+ }
41
+
42
+ // Tokens that can be configured through Angular Material's density theming API.
43
+ @function get-density-tokens($config) {
44
+ @return ();
45
+ }
46
+
47
+ // Combines the tokens generated by the above functions into a single map with placeholder values.
48
+ // This is used to create token slots.
49
+ @function get-token-slots() {
50
+ @return sass-utils.deep-merge-all(
51
+ get-unthemable-tokens(),
52
+ get-color-tokens(token-utils.$placeholder-color-config),
53
+ get-typography-tokens(token-utils.$placeholder-typography-config),
54
+ get-density-tokens(token-utils.$placeholder-density-config)
55
+ );
56
+ }
@@ -0,0 +1,45 @@
1
+ @use 'sass:map';
2
+ @use '../../token-utils';
3
+ @use '../../../theming/theming';
4
+ @use '../../../style/sass-utils';
5
+
6
+ // The prefix used to generate the fully qualified name for tokens in this file.
7
+ $prefix: (mat, divider);
8
+
9
+ // Tokens that can't be configured through Angular Material's current theming API,
10
+ // but may be in a future version of the theming API.
11
+ @function get-unthemable-tokens() {
12
+ @return (
13
+ width: 1px
14
+ );
15
+ }
16
+
17
+ // Tokens that can be configured through Angular Material's color theming API.
18
+ @function get-color-tokens($config) {
19
+ $foreground: map.get($config, foreground);
20
+
21
+ @return (
22
+ color: theming.get-color-from-palette($foreground, divider)
23
+ );
24
+ }
25
+
26
+ // Tokens that can be configured through Angular Material's typography theming API.
27
+ @function get-typography-tokens($config) {
28
+ @return ();
29
+ }
30
+
31
+ // Tokens that can be configured through Angular Material's density theming API.
32
+ @function get-density-tokens($config) {
33
+ @return ();
34
+ }
35
+
36
+ // Combines the tokens generated by the above functions into a single map with placeholder values.
37
+ // This is used to create token slots.
38
+ @function get-token-slots() {
39
+ @return sass-utils.deep-merge-all(
40
+ get-unthemable-tokens(),
41
+ get-color-tokens(token-utils.$placeholder-color-config),
42
+ get-typography-tokens(token-utils.$placeholder-typography-config),
43
+ get-density-tokens(token-utils.$placeholder-density-config)
44
+ );
45
+ }
@@ -0,0 +1,63 @@
1
+ @use 'sass:map';
2
+ @use '../../token-utils';
3
+ @use '../../../typography/typography-utils';
4
+ @use '../../../theming/theming';
5
+ @use '../../../style/sass-utils';
6
+
7
+ // The prefix used to generate the fully qualified name for tokens in this file.
8
+ $prefix: (mat, legacy-button-toggle);
9
+
10
+ // Tokens that can't be configured through Angular Material's current theming API,
11
+ // but may be in a future version of the theming API.
12
+ @function get-unthemable-tokens() {
13
+ @return (
14
+ height: 36px,
15
+ shape: 2px,
16
+ focus-state-layer-opacity: 1,
17
+ );
18
+ }
19
+
20
+ // Tokens that can be configured through Angular Material's color theming API.
21
+ @function get-color-tokens($config) {
22
+ $foreground: map.get($config, foreground);
23
+ $background: map.get($config, background);
24
+
25
+ @return (
26
+ text-color: theming.get-color-from-palette($foreground, hint-text),
27
+ state-layer-color: theming.get-color-from-palette($background, focused-button),
28
+ selected-state-text-color: theming.get-color-from-palette($foreground, secondary-text),
29
+ selected-state-background-color: theming.get-color-from-palette($background, selected-button),
30
+ disabled-state-text-color: theming.get-color-from-palette($foreground, disabled-button),
31
+ disabled-state-background-color:
32
+ theming.get-color-from-palette($background, disabled-button-toggle),
33
+ disabled-selected-state-background-color:
34
+ theming.get-color-from-palette($background, selected-disabled-button)
35
+ );
36
+ }
37
+
38
+ // Tokens that can be configured through Angular Material's typography theming API.
39
+ @function get-typography-tokens($config) {
40
+ @return (
41
+ // TODO(crisbeto): other components have tokens for all typography dimensions (font weight,
42
+ // letter spacing etc). The button toggle only has the font to match what it had in the
43
+ // old theming API and to reduce internal breakages. We should introduce more typography
44
+ // tokens at some point.
45
+ text-font: typography-utils.font-family($config),
46
+ );
47
+ }
48
+
49
+ // Tokens that can be configured through Angular Material's density theming API.
50
+ @function get-density-tokens($config) {
51
+ @return ();
52
+ }
53
+
54
+ // Combines the tokens generated by the above functions into a single map with placeholder values.
55
+ // This is used to create token slots.
56
+ @function get-token-slots() {
57
+ @return sass-utils.deep-merge-all(
58
+ get-unthemable-tokens(),
59
+ get-color-tokens(token-utils.$placeholder-color-config),
60
+ get-typography-tokens(token-utils.$placeholder-typography-config),
61
+ get-density-tokens(token-utils.$placeholder-density-config)
62
+ );
63
+ }
@@ -0,0 +1,65 @@
1
+ @use 'sass:color';
2
+ @use 'sass:map';
3
+ @use 'sass:meta';
4
+ @use '../../token-utils';
5
+ @use '../../../theming/theming';
6
+ @use '../../../style/sass-utils';
7
+
8
+ // The prefix used to generate the fully qualified name for tokens in this file.
9
+ $prefix: (mat, sidenav);
10
+
11
+ // Tokens that can't be configured through Angular Material's current theming API,
12
+ // but may be in a future version of the theming API.
13
+ @function get-unthemable-tokens() {
14
+ @return (
15
+ // Currently zero, but it appears to be relevant for M3.
16
+ // See: https://m3.material.io/components/navigation-drawer/overview
17
+ container-shape: 0,
18
+ );
19
+ }
20
+
21
+ // Tokens that can be configured through Angular Material's color theming API.
22
+ @function get-color-tokens($config) {
23
+ $is-dark: map.get($config, is-dark);
24
+ $foreground: map.get($config, foreground);
25
+ $background: map.get($config, background);
26
+ $scrim-opacity: 0.6;
27
+ $scrim-color: theming.get-color-from-palette($background, card, $scrim-opacity);
28
+ $fallback-scrim-color: if($is-dark, rgba(#fff, $scrim-opacity), rgba(#000, $scrim-opacity));
29
+
30
+ @return (
31
+ container-divider-color: theming.get-color-from-palette($foreground, divider),
32
+ container-background-color: theming.get-color-from-palette($background, dialog),
33
+ container-text-color: theming.get-color-from-palette($foreground, text),
34
+ content-background-color: theming.get-color-from-palette($background, background),
35
+ content-text-color: theming.get-color-from-palette($foreground, text),
36
+
37
+ // We use invert() here to have the darken the background color expected to be used.
38
+ // If the background is light, we use a dark backdrop. If the background is dark, we
39
+ // use a light backdrop. If the value isn't a color, Sass will throw an error so we
40
+ // fall back to something generic.
41
+ scrim-color: if(meta.type-of($scrim-color) == color,
42
+ color.invert($scrim-color), $fallback-scrim-color),
43
+ );
44
+ }
45
+
46
+ // Tokens that can be configured through Angular Material's typography theming API.
47
+ @function get-typography-tokens($config) {
48
+ @return ();
49
+ }
50
+
51
+ // Tokens that can be configured through Angular Material's density theming API.
52
+ @function get-density-tokens($config) {
53
+ @return ();
54
+ }
55
+
56
+ // Combines the tokens generated by the above functions into a single map with placeholder values.
57
+ // This is used to create token slots.
58
+ @function get-token-slots() {
59
+ @return sass-utils.deep-merge-all(
60
+ get-unthemable-tokens(),
61
+ get-color-tokens(token-utils.$placeholder-color-config),
62
+ get-typography-tokens(token-utils.$placeholder-typography-config),
63
+ get-density-tokens(token-utils.$placeholder-density-config)
64
+ );
65
+ }
@@ -0,0 +1,87 @@
1
+ @use 'sass:map';
2
+ @use 'sass:meta';
3
+ @use '../../token-utils';
4
+ @use '../../../typography/typography-utils';
5
+ @use '../../../theming/theming';
6
+ @use '../../../style/sass-utils';
7
+
8
+ // The prefix used to generate the fully qualified name for tokens in this file.
9
+ $prefix: (mat, standard-button-toggle);
10
+
11
+ // Tokens that can't be configured through Angular Material's current theming API,
12
+ // but may be in a future version of the theming API.
13
+ @function get-unthemable-tokens() {
14
+ @return (
15
+ shape: 4px,
16
+ hover-state-layer-opacity: 0.04,
17
+ focus-state-layer-opacity: 0.12,
18
+ );
19
+ }
20
+
21
+ // Tokens that can be configured through Angular Material's color theming API.
22
+ @function get-color-tokens($config) {
23
+ $foreground: map.get($config, foreground);
24
+ $background: map.get($config, background);
25
+ $theme-divider-color: theming.get-color-from-palette($foreground, divider);
26
+
27
+ // By default the theme usually has an rgba color for the dividers, which can
28
+ // stack up with the background of a button toggle. This can cause the border
29
+ // of a selected toggle to look different from an deselected one. We use a solid
30
+ // color to ensure that the border always stays the same.
31
+ $divider-color: if(meta.type-of($theme-divider-color) == color,
32
+ theming.private-rgba-to-hex($theme-divider-color, map.get($background, card)),
33
+ $theme-divider-color
34
+ );
35
+
36
+ @return (
37
+ text-color: theming.get-color-from-palette($foreground, text),
38
+ background-color: theming.get-color-from-palette($background, card),
39
+ state-layer-color: theming.get-color-from-palette($background, focused-button, 1),
40
+ selected-state-background-color: theming.get-color-from-palette($background, selected-button),
41
+ selected-state-text-color: theming.get-color-from-palette($foreground, text),
42
+ disabled-state-text-color: theming.get-color-from-palette($foreground, disabled-button),
43
+ disabled-state-background-color: theming.get-color-from-palette($background, card),
44
+ disabled-selected-state-text-color: theming.get-color-from-palette($foreground, text),
45
+ disabled-selected-state-background-color:
46
+ theming.get-color-from-palette($background, selected-disabled-button),
47
+ divider-color: $divider-color,
48
+ );
49
+ }
50
+
51
+ // Tokens that can be configured through Angular Material's typography theming API.
52
+ @function get-typography-tokens($config) {
53
+ @return (
54
+ // TODO(crisbeto): other components have tokens for all typography dimensions (font weight,
55
+ // letter spacing etc). The button toggle only has the font to match what it had in the
56
+ // old theming API and to reduce internal breakages. We should introduce more typography
57
+ // tokens at some point.
58
+ text-font: typography-utils.font-family($config),
59
+ );
60
+ }
61
+
62
+ // Tokens that can be configured through Angular Material's density theming API.
63
+ @function get-density-tokens($config) {
64
+ $density-scale: theming.clamp-density($config, -4);
65
+ $size-scale: (
66
+ 0: 48px,
67
+ -1: 44px,
68
+ -2: 40px,
69
+ -3: 36px,
70
+ -4: 24px,
71
+ );
72
+
73
+ @return (
74
+ height: map.get($size-scale, $density-scale)
75
+ );
76
+ }
77
+
78
+ // Combines the tokens generated by the above functions into a single map with placeholder values.
79
+ // This is used to create token slots.
80
+ @function get-token-slots() {
81
+ @return sass-utils.deep-merge-all(
82
+ get-unthemable-tokens(),
83
+ get-color-tokens(token-utils.$placeholder-color-config),
84
+ get-typography-tokens(token-utils.$placeholder-typography-config),
85
+ get-density-tokens(token-utils.$placeholder-density-config)
86
+ );
87
+ }
@@ -0,0 +1,79 @@
1
+ @use 'sass:map';
2
+ @use '../../token-utils';
3
+ @use '../../../typography/typography-utils';
4
+ @use '../../../theming/theming';
5
+ @use '../../../style/sass-utils';
6
+
7
+ // The prefix used to generate the fully qualified name for tokens in this file.
8
+ $prefix: (mat, toolbar);
9
+
10
+ // Tokens that can't be configured through Angular Material's current theming API,
11
+ // but may be in a future version of the theming API.
12
+ @function get-unthemable-tokens() {
13
+ @return ();
14
+ }
15
+
16
+ // Tokens that can be configured through Angular Material's color theming API.
17
+ @function get-color-tokens($config) {
18
+ $foreground: map.get($config, foreground);
19
+ $background: map.get($config, background);
20
+
21
+ @return private-get-color-palette-color-tokens(
22
+ $background-color: theming.get-color-from-palette($background, app-bar),
23
+ $text-color: theming.get-color-from-palette($foreground, text),
24
+ );
25
+ }
26
+
27
+ // Tokens that can be configured through Angular Material's typography theming API.
28
+ @function get-typography-tokens($config) {
29
+ @return (
30
+ title-text-font: typography-utils.font-family($config, title) or
31
+ typography-utils.font-family($config),
32
+ title-text-line-height: typography-utils.line-height($config, title),
33
+ title-text-size: typography-utils.font-size($config, title),
34
+ title-text-tracking: typography-utils.letter-spacing($config, title),
35
+ title-text-weight: typography-utils.font-weight($config, title),
36
+ );
37
+ }
38
+
39
+ // Tokens that can be configured through Angular Material's density theming API.
40
+ @function get-density-tokens($config) {
41
+ $density-scale: theming.clamp-density($config, -3);
42
+ $standard-scale: (
43
+ 0: 64px,
44
+ -1: 60px,
45
+ -2: 56px,
46
+ -3: 52px,
47
+ );
48
+
49
+ $mobile-scale: (
50
+ 0: 56px,
51
+ -1: 52px,
52
+ -2: 48px,
53
+ -3: 44px,
54
+ );
55
+
56
+ @return (
57
+ standard-height: map.get($standard-scale, $density-scale),
58
+ mobile-height: map.get($mobile-scale, $density-scale),
59
+ );
60
+ }
61
+
62
+ // Generates the tokens used to theme the toolbar based on a palette.
63
+ @function private-get-color-palette-color-tokens($background-color, $text-color) {
64
+ @return (
65
+ container-background-color: $background-color,
66
+ container-text-color: $text-color,
67
+ );
68
+ }
69
+
70
+ // Combines the tokens generated by the above functions into a single map with placeholder values.
71
+ // This is used to create token slots.
72
+ @function get-token-slots() {
73
+ @return sass-utils.deep-merge-all(
74
+ get-unthemable-tokens(),
75
+ get-color-tokens(token-utils.$placeholder-color-config),
76
+ get-typography-tokens(token-utils.$placeholder-typography-config),
77
+ get-density-tokens(token-utils.$placeholder-density-config)
78
+ );
79
+ }
@@ -1,16 +1,14 @@
1
- @use 'sass:map';
1
+ @use '../core/style/sass-utils';
2
2
  @use '../core/theming/theming';
3
+ @use '../core/tokens/token-utils';
4
+ @use '../core/tokens/m2/mat/divider' as tokens-mat-divider;
3
5
 
4
6
  @mixin color($config-or-theme) {
5
7
  $config: theming.get-color-config($config-or-theme);
6
- $foreground: map.get($config, foreground);
7
8
 
8
- .mat-divider {
9
- border-top-color: theming.get-color-from-palette($foreground, divider);
10
- }
11
-
12
- .mat-divider-vertical {
13
- border-right-color: theming.get-color-from-palette($foreground, divider);
9
+ @include sass-utils.current-selector-or-root() {
10
+ @include token-utils.create-token-values(tokens-mat-divider.$prefix,
11
+ tokens-mat-divider.get-color-tokens($config));
14
12
  }
15
13
  }
16
14