|
1 | 1 | @use 'sass:map';
|
2 | 2 | @use '@angular/material' as mat;
|
3 | 3 |
|
| 4 | +/// Hardcode the given value, or null if hardcoded values are excluded. |
| 5 | +@function _hardcode($value, $exclude-hardcoded) { |
| 6 | + @return if($exclude-hardcoded, null, $value); |
| 7 | +} |
| 8 | + |
4 | 9 | /// Sets all of the standard typography tokens for the given token base name to the given typography
|
5 | 10 | /// level.
|
6 | 11 | /// @param {Map} $systems The MDC system tokens
|
|
22 | 27 | /// @return {Map} A set of custom tokens for the mat-card
|
23 | 28 | @function card($systems, $exclude-hardcoded) {
|
24 | 29 | @return mat.private-merge-all(
|
25 |
| - _generate-typography-tokens($systems, title-text, title-large), |
26 |
| - _generate-typography-tokens($systems, subtitle-text, title-medium), |
27 |
| - ( |
28 |
| - subtitle-text-color: map.get($systems, md-sys-color, on-surface) |
29 |
| - ) |
| 30 | + _generate-typography-tokens($systems, title-text, title-large), |
| 31 | + _generate-typography-tokens($systems, subtitle-text, title-medium), |
| 32 | + ( |
| 33 | + subtitle-text-color: map.get($systems, md-sys-color, on-surface) |
| 34 | + ) |
30 | 35 | );
|
31 | 36 | }
|
32 | 37 |
|
|
36 | 41 | /// @return {Map} A set of custom tokens for the mat-toolbar
|
37 | 42 | @function toolbar($systems, $exclude-hardcoded) {
|
38 | 43 | @return mat.private-merge-all(
|
39 |
| - _generate-typography-tokens($systems, title-text, title-large), |
40 |
| - ( |
41 |
| - container-background-color: map.get($systems, md-sys-color, surface), |
42 |
| - container-text-color: map.get($systems, md-sys-color, on-surface), |
43 |
| - ) |
| 44 | + _generate-typography-tokens($systems, title-text, title-large), |
| 45 | + ( |
| 46 | + container-background-color: map.get($systems, md-sys-color, surface), |
| 47 | + container-text-color: map.get($systems, md-sys-color, on-surface), |
| 48 | + ) |
44 | 49 | );
|
45 | 50 | }
|
46 | 51 |
|
|
58 | 63 | /// @return {Map} A set of custom tokens for the mat-slider
|
59 | 64 | @function slider($systems, $exclude-hardcoded) {
|
60 | 65 | @return (
|
61 |
| - value-indicator-opacity: 1, |
| 66 | + value-indicator-opacity: _hardcode(1, $exclude-hardcoded), |
62 | 67 | );
|
63 | 68 | }
|
64 | 69 |
|
|
83 | 88 | disabled-label-color: map.get($systems, md-sys-color, on-surface),
|
84 | 89 | );
|
85 | 90 | }
|
| 91 | + |
| 92 | +/// Generates custom tokens for the mat-ripple. |
| 93 | +/// @param {Map} $systems The MDC system tokens |
| 94 | +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values |
| 95 | +/// @return {Map} A set of custom tokens for the mat-ripple |
| 96 | +@function ripple($systems, $exclude-hardcoded) { |
| 97 | + @return ( |
| 98 | + color: mat.private-safe-color-change(map.get($systems, md-sys-color, on-surface), $alpha: 0.1), |
| 99 | + ); |
| 100 | +} |
| 101 | + |
| 102 | +/// Generates custom tokens for the mat-sort. |
| 103 | +/// @param {Map} $systems The MDC system tokens |
| 104 | +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values |
| 105 | +/// @return {Map} A set of custom tokens for the mat-sort |
| 106 | +@function sort($systems, $exclude-hardcoded) { |
| 107 | + @return ( |
| 108 | + arrow-color: map.get($systems, md-sys-color, on-surface), |
| 109 | + ); |
| 110 | +} |
| 111 | + |
| 112 | +/// Generates custom tokens for the mat-stepper. |
| 113 | +/// @param {Map} $systems The MDC system tokens |
| 114 | +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values |
| 115 | +/// @return {Map} A set of custom tokens for the mat-stepper |
| 116 | +@function stepper($systems, $exclude-hardcoded) { |
| 117 | + @return mat.private-merge-all( |
| 118 | + ( |
| 119 | + container-color: map.get($systems, md-sys-color, surface), |
| 120 | + line-color: map.get($systems, md-sys-color, outline-variant), |
| 121 | + header-hover-state-layer-color: mat.private-safe-color-change( |
| 122 | + map.get($systems, md-sys-color, inverse-surface), |
| 123 | + $alpha: map.get($systems, md-sys-state, hover-state-layer-opacity) |
| 124 | + ), |
| 125 | + header-focus-state-layer-color: mat.private-safe-color-change( |
| 126 | + map.get($systems, md-sys-color, inverse-surface), |
| 127 | + $alpha: map.get($systems, md-sys-state, focus-state-layer-opacity) |
| 128 | + ), |
| 129 | + header-label-text-color: map.get($systems, md-sys-color, on-surface-variant), |
| 130 | + header-optional-label-text-color: map.get($systems, md-sys-color, on-surface-variant), |
| 131 | + header-selected-state-label-text-color: map.get($systems, md-sys-color, on-surface), |
| 132 | + header-icon-background-color: map.get($systems, md-sys-color, inverse-surface), |
| 133 | + header-icon-foreground-color: map.get($systems, md-sys-color, inverse-on-surface), |
| 134 | + header-error-state-label-text-color: map.get($systems, md-sys-color, error), |
| 135 | + header-error-state-icon-foreground-color: map.get($systems, md-sys-color, error), |
| 136 | + header-error-state-icon-background-color: _hardcode(transparent, $exclude-hardcoded), |
| 137 | + container-text-font: map.get($systems, md-sys-typescale, body-medium-font), |
| 138 | + header-label-text-font: map.get($systems, md-sys-typescale, title-small-font), |
| 139 | + header-label-text-size: map.get($systems, md-sys-typescale, title-small-size), |
| 140 | + header-label-text-weight: map.get($systems, md-sys-typescale, title-small-weight), |
| 141 | + header-error-state-label-text-size: map.get($systems, md-sys-typescale, title-small-size), |
| 142 | + header-selected-state-label-text-size: map.get($systems, md-sys-typescale, title-small-szie), |
| 143 | + header-selected-state-label-text-weight: map.get( |
| 144 | + $systems, md-sys-typescale, title-small-weight), |
| 145 | + ), |
| 146 | + ); |
| 147 | +} |
| 148 | + |
| 149 | +/// Generates custom tokens for the mat-tab-header. |
| 150 | +/// @param {Map} $systems The MDC system tokens |
| 151 | +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values |
| 152 | +/// @return {Map} A set of custom tokens for the mat-tab-header |
| 153 | +@function tab-header($systems, $exclude-hardcoded) { |
| 154 | + @return mat.private-merge-all( |
| 155 | + _generate-typography-tokens($systems, label-text, title-small), |
| 156 | + ( |
| 157 | + disabled-ripple-color: blue, // TODO(mmalerba): Figure out correct value. |
| 158 | + pagination-icon-color: map.get($systems, md-sys-color, on-surface), |
| 159 | + inactive-label-text-color: map.get($systems, md-sys-color, on-surface), |
| 160 | + active-label-text-color: map.get($systems, md-sys-color, on-surface), |
| 161 | + active-ripple-color: map.get($systems, md-sys-color, on-surface), |
| 162 | + inactive-ripple-color: map.get($systems, md-sys-color, on-surface), |
| 163 | + inactive-focus-label-text-color: map.get($systems, md-sys-color, on-surface), |
| 164 | + inactive-hover-label-text-color: map.get($systems, md-sys-color, on-surface), |
| 165 | + active-focus-label-text-color: map.get($systems, md-sys-color, on-surface), |
| 166 | + active-hover-label-text-color: map.get($systems, md-sys-color, on-surface), |
| 167 | + active-focus-indicator-color: map.get($systems, md-sys-color, primary), |
| 168 | + active-hover-indicator-color: map.get($systems, md-sys-color, primary), |
| 169 | + ), |
| 170 | + ); |
| 171 | +} |
| 172 | + |
| 173 | +/// Generates custom tokens for the mdc-tab-indicator. (MDC has a tab-indicator component, but they |
| 174 | +/// seem to have made up the tokens rather than using ones generated from the token database, |
| 175 | +/// therefore we need a custom token function for it). |
| 176 | +/// @param {Map} $systems The MDC system tokens |
| 177 | +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values |
| 178 | +/// @return {Map} A set of custom tokens for the mdc-tab-indicator |
| 179 | +@function tab-indicator($systems, $exclude-hardcoded) { |
| 180 | + @return ( |
| 181 | + active-indicator-height: _hardcode(2px, $exclude-hardcoded), |
| 182 | + active-indicator-shape: _hardcode(0, $exclude-hardcoded), |
| 183 | + active-indicator-color: map.get($systems, md-sys-color, primary), |
| 184 | + ); |
| 185 | +} |
| 186 | + |
| 187 | +/// Generates custom tokens for the mat-table. |
| 188 | +/// @param {Map} $systems The MDC system tokens |
| 189 | +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values |
| 190 | +/// @return {Map} A set of custom tokens for the mat-table |
| 191 | +@function table($systems, $exclude-hardcoded) { |
| 192 | + @return mat.private-merge-all( |
| 193 | + _generate-typography-tokens($systems, header-headline, title-small), |
| 194 | + _generate-typography-tokens($systems, row-item-label-text, body-medium), |
| 195 | + _generate-typography-tokens($systems, footer-supporting-text, body-medium), |
| 196 | + ( |
| 197 | + row-item-outline-width: _hardcode(1px, $exclude-hardcoded), |
| 198 | + background-color: map.get($systems, md-sys-color, surface), |
| 199 | + header-headline-color: map.get($systems, md-sys-color, on-surface), |
| 200 | + row-item-label-text-color: map.get($systems, md-sys-color, on-surface), |
| 201 | + row-item-outline-color: map.get($systems, md-sys-color, outline-variant), |
| 202 | + ), |
| 203 | + ); |
| 204 | +} |
| 205 | + |
| 206 | +/// Generates custom tokens for the mat-tree. |
| 207 | +/// @param {Map} $systems The MDC system tokens |
| 208 | +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values |
| 209 | +/// @return {Map} A set of custom tokens for the mat-tree |
| 210 | +@function tree($systems, $exclude-hardcoded) { |
| 211 | + @return ( |
| 212 | + container-background-color: map.get($systems, md-sys-color, surface), |
| 213 | + node-text-color: map.get($systems, md-sys-color, on-surface), |
| 214 | + node-text-font: map.get($systems, md-sys-typescale, body-large-font), |
| 215 | + node-text-size: map.get($systems, md-sys-typescale, body-large-size), |
| 216 | + node-text-weight: map.get($systems, md-sys-typescale, body-large-weight), |
| 217 | + ); |
| 218 | +} |
0 commit comments