|
| 1 | +@use 'sass:color'; |
| 2 | +@use 'sass:meta'; |
| 3 | +@use '../../token-utils'; |
| 4 | +@use '../../../theming/inspection'; |
| 5 | +@use '../../../style/sass-utils'; |
| 6 | + |
| 7 | +// The prefix used to generate the fully qualified name for tokens in this file. |
| 8 | +$prefix: (mat, sort); |
| 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($theme) { |
| 18 | + $table-background: inspection.get-theme-color($theme, background, card); |
| 19 | + $text-color: inspection.get-theme-color($theme, foreground, secondary-text); |
| 20 | + $arrow-color: null; |
| 21 | + |
| 22 | + // Because the arrow is made up of multiple elements that are stacked on top of each other, |
| 23 | + // we can't use the semi-transparent color from the theme directly. If the value is a color |
| 24 | + // *type*, we convert it into a solid color by taking the opacity from the rgba value and |
| 25 | + // using the value to determine the percentage of the background to put into foreground |
| 26 | + // when mixing the colors together. Otherwise, if it resolves to something different |
| 27 | + // (e.g. it resolves to a CSS variable), we use the color directly. |
| 28 | + @if (meta.type-of($table-background) == color and meta.type-of($text-color) == color) { |
| 29 | + $text-opacity: opacity($text-color); |
| 30 | + $arrow-color: color.mix($table-background, rgba($text-color, 1), (1 - $text-opacity) * 100%); |
| 31 | + } |
| 32 | + @else { |
| 33 | + $arrow-color: $text-color; |
| 34 | + } |
| 35 | + |
| 36 | + @return ( |
| 37 | + arrow-color: $arrow-color, |
| 38 | + ); |
| 39 | +} |
| 40 | + |
| 41 | +// Tokens that can be configured through Angular Material's typography theming API. |
| 42 | +@function get-typography-tokens($theme) { |
| 43 | + @return (); |
| 44 | +} |
| 45 | + |
| 46 | +// Tokens that can be configured through Angular Material's density theming API. |
| 47 | +@function get-density-tokens($theme) { |
| 48 | + @return (); |
| 49 | +} |
| 50 | + |
| 51 | +// Combines the tokens generated by the above functions into a single map with placeholder values. |
| 52 | +// This is used to create token slots. |
| 53 | +@function get-token-slots() { |
| 54 | + @return sass-utils.deep-merge-all( |
| 55 | + get-unthemable-tokens(), |
| 56 | + get-color-tokens(token-utils.$placeholder-color-config), |
| 57 | + get-typography-tokens(token-utils.$placeholder-typography-config), |
| 58 | + get-density-tokens(token-utils.$placeholder-density-config) |
| 59 | + ); |
| 60 | +} |
0 commit comments