|
1 | 1 | @use 'sass:map'; |
2 | | -@use '../core/style/sass-utils'; |
3 | 2 | @use '../core/tokens/m3-utils'; |
4 | 3 |
|
5 | 4 | // The prefix used to generate the fully qualified name for tokens in this file. |
6 | 5 | $prefix: (mat, badge); |
7 | 6 |
|
8 | 7 | /// Generates custom tokens for the mat-badge. |
9 | | -/// @param {Map} $systems The MDC system tokens |
10 | | -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values |
11 | | -/// @param {Map} $token-slots Possible token slots |
12 | | -/// @return {Map} A set of custom tokens for the mat-badge |
13 | | -@function get-tokens($systems, $exclude-hardcoded, $token-slots) { |
14 | | - $tokens: ( |
15 | | - background-color: map.get($systems, md-sys-color, error), |
16 | | - text-color: map.get($systems, md-sys-color, on-error), |
17 | | - disabled-state-background-color: sass-utils.safe-color-change( |
18 | | - map.get($systems, md-sys-color, error), |
19 | | - $alpha: 0.38), |
20 | | - disabled-state-text-color: map.get($systems, md-sys-color, on-error), |
21 | | - text-font: map.get($systems, md-sys-typescale, label-small-font), |
22 | | - text-size: map.get($systems, md-sys-typescale, label-small-size), |
23 | | - text-weight: map.get($systems, md-sys-typescale, label-small-weight), |
24 | | - small-size-text-size: m3-utils.hardcode(0, $exclude-hardcoded), |
25 | | - container-shape: map.get($systems, md-sys-shape, corner-full), |
26 | | - container-size: m3-utils.hardcode(16px, $exclude-hardcoded), |
27 | | - line-height: m3-utils.hardcode(16px, $exclude-hardcoded), |
28 | | - legacy-container-size: m3-utils.hardcode(unset, $exclude-hardcoded), |
29 | | - legacy-small-size-container-size: m3-utils.hardcode(unset, $exclude-hardcoded), |
30 | | - small-size-container-size: m3-utils.hardcode(6px, $exclude-hardcoded), |
31 | | - small-size-line-height: m3-utils.hardcode(6px, $exclude-hardcoded), |
32 | | - container-padding: m3-utils.hardcode(0 4px, $exclude-hardcoded), |
33 | | - small-size-container-padding: m3-utils.hardcode(0, $exclude-hardcoded), |
34 | | - container-offset: m3-utils.hardcode(-12px 0, $exclude-hardcoded), |
35 | | - small-size-container-offset: m3-utils.hardcode(-6px 0, $exclude-hardcoded), |
36 | | - container-overlap-offset: m3-utils.hardcode(-12px, $exclude-hardcoded), |
37 | | - small-size-container-overlap-offset: m3-utils.hardcode(-6px, $exclude-hardcoded), |
38 | | - |
39 | | - // This size isn't in the M3 spec so we emit the same values as for `medium`. |
40 | | - large-size-container-size: m3-utils.hardcode(16px, $exclude-hardcoded), |
41 | | - large-size-line-height: m3-utils.hardcode(16px, $exclude-hardcoded), |
42 | | - large-size-container-offset: m3-utils.hardcode(-12px 0, $exclude-hardcoded), |
43 | | - large-size-container-overlap-offset: m3-utils.hardcode(-12px, $exclude-hardcoded), |
44 | | - large-size-text-size: map.get($systems, md-sys-typescale, label-small-size), |
45 | | - large-size-container-padding: m3-utils.hardcode(0 4px, $exclude-hardcoded), |
46 | | - legacy-large-size-container-size: m3-utils.hardcode(unset, $exclude-hardcoded), |
47 | | - ); |
| 8 | +@function get-tokens($theme, $color-variant: null) { |
| 9 | + $system: m3-utils.get-system($theme); |
| 10 | + @if $color-variant { |
| 11 | + $system: m3-utils.replace-colors-with-variant($system, error, $color-variant); |
| 12 | + } |
48 | 13 |
|
49 | | - $variant-tokens: ( |
50 | | - primary: ( |
51 | | - background-color: map.get($systems, md-sys-color, primary), |
52 | | - text-color: map.get($systems, md-sys-color, on-primary), |
53 | | - disabled-state-background-color: sass-utils.safe-color-change( |
54 | | - map.get($systems, md-sys-color, primary), |
55 | | - $alpha: 0.38, |
56 | | - ), |
57 | | - disabled-state-text-color: map.get($systems, md-sys-color, on-primary), |
| 14 | + $tokens: ( |
| 15 | + base: ( |
| 16 | + container-shape: map.get($system, corner-full), |
| 17 | + container-size: 16px, |
| 18 | + legacy-container-size: unset, |
| 19 | + legacy-small-size-container-size: unset, |
| 20 | + small-size-container-size: 6px, |
| 21 | + container-padding: 0 4px, |
| 22 | + small-size-container-padding: 0, |
| 23 | + container-offset: -12px 0, |
| 24 | + small-size-container-offset: -6px 0, |
| 25 | + container-overlap-offset: -12px, |
| 26 | + small-size-container-overlap-offset: -6px, |
| 27 | + large-size-container-size: 16px, |
| 28 | + large-size-container-offset: -12px 0, |
| 29 | + large-size-container-overlap-offset: -12px, |
| 30 | + large-size-container-padding: 0 4px, |
| 31 | + legacy-large-size-container-size: unset, |
58 | 32 | ), |
59 | | - secondary: ( |
60 | | - background-color: map.get($systems, md-sys-color, secondary), |
61 | | - text-color: map.get($systems, md-sys-color, on-secondary), |
62 | | - disabled-state-background-color: sass-utils.safe-color-change( |
63 | | - map.get($systems, md-sys-color, secondary), |
64 | | - $alpha: 0.38, |
65 | | - ), |
66 | | - disabled-state-text-color: map.get($systems, md-sys-color, on-secondary), |
| 33 | + color: ( |
| 34 | + background-color: map.get($system, error), |
| 35 | + text-color: map.get($system, on-error), |
| 36 | + disabled-state-background-color: m3-utils.color-with-opacity(map.get($system, error), 38%), |
| 37 | + disabled-state-text-color: map.get($system, on-error), |
67 | 38 | ), |
68 | | - tertiary: ( |
69 | | - background-color: map.get($systems, md-sys-color, tertiary), |
70 | | - text-color: map.get($systems, md-sys-color, on-tertiary), |
71 | | - disabled-state-background-color: sass-utils.safe-color-change( |
72 | | - map.get($systems, md-sys-color, tertiary), |
73 | | - $alpha: 0.38, |
74 | | - ), |
75 | | - disabled-state-text-color: map.get($systems, md-sys-color, on-tertiary), |
| 39 | + typography: ( |
| 40 | + text-font: map.get($system, label-small-font), |
| 41 | + text-size: map.get($system, label-small-size), |
| 42 | + text-weight: map.get($system, label-small-weight), |
| 43 | + large-size-text-size: map.get($system, label-small-size), |
| 44 | + small-size-text-size: 0, |
| 45 | + line-height: 16px, |
| 46 | + small-size-line-height: 6px, |
| 47 | + large-size-line-height: 16px, |
76 | 48 | ), |
77 | | - error: () // Default, no overrides needed |
| 49 | + density: (), |
78 | 50 | ); |
79 | 51 |
|
80 | | - @return m3-utils.namespace($prefix, ($tokens, $variant-tokens), $token-slots); |
| 52 | + @return $tokens; |
81 | 53 | } |
0 commit comments