|
| 1 | +@use '../core/theming/inspection'; |
| 2 | +@use '../core/tokens/token-utils'; |
| 3 | +@use '../core/typography/typography'; |
| 4 | +@use './m2-chart'; |
| 5 | +@use './m3-chart'; |
| 6 | +@use 'sass:map'; |
| 7 | + |
| 8 | +/// Outputs base theme styles for the mat-chart. |
| 9 | +/// @param {Map} $theme The theme to generate base styles for. |
| 10 | +@mixin base($theme) { |
| 11 | + $tokens: map.get(m2-chart.get-tokens($theme), base); |
| 12 | + @if inspection.get-theme-version($theme) == 1 { |
| 13 | + $tokens: map.get(m3-chart.get-tokens($theme), base); |
| 14 | + } |
| 15 | + |
| 16 | + @include token-utils.values($tokens); |
| 17 | +} |
| 18 | + |
| 19 | +/// Outputs color theme styles for the mat-chart. |
| 20 | +/// @param {Map} $theme The theme to generate color styles for. |
| 21 | +/// @param {String} $color-variant The color variant to use. |
| 22 | +@mixin color($theme, $color-variant: null) { |
| 23 | + $tokens: map.get(m2-chart.get-tokens($theme), color); |
| 24 | + @if inspection.get-theme-version($theme) == 1 { |
| 25 | + $tokens: map.get(m3-chart.get-tokens($theme, $color-variant), color); |
| 26 | + } |
| 27 | + |
| 28 | + @include token-utils.values($tokens); |
| 29 | +} |
| 30 | + |
| 31 | +/// Outputs typography theme styles for the mat-chart. |
| 32 | +/// @param {Map} $theme The theme to generate typography styles for. |
| 33 | +@mixin typography($theme) { |
| 34 | + $tokens: map.get(m2-chart.get-tokens($theme), typography); |
| 35 | + @if inspection.get-theme-version($theme) == 1 { |
| 36 | + $tokens: map.get(m3-chart.get-tokens($theme), typography); |
| 37 | + } |
| 38 | + |
| 39 | + @include token-utils.values($tokens); |
| 40 | +} |
| 41 | + |
| 42 | +/// Outputs density theme styles for the mat-chart. |
| 43 | +/// @param {Map} $theme The theme to generate density styles for. |
| 44 | +@mixin density($theme) { |
| 45 | + $tokens: map.get(m2-chart.get-tokens($theme), density); |
| 46 | + @if inspection.get-theme-version($theme) == 1 { |
| 47 | + $tokens: map.get(m3-chart.get-tokens($theme), density); |
| 48 | + } |
| 49 | + |
| 50 | + @include token-utils.values($tokens); |
| 51 | +} |
| 52 | + |
| 53 | +/// Outputs all theme styles for the mat-chart. |
| 54 | +/// @param {Map} $theme The theme to generate styles for. |
| 55 | +/// @param {String} $color-variant The color variant to use. |
| 56 | +@mixin theme($theme, $color-variant: null) { |
| 57 | + @if inspection.get-theme-version($theme) == 1 { |
| 58 | + @include base($theme); |
| 59 | + @include color($theme, $color-variant); |
| 60 | + @include density($theme); |
| 61 | + @include typography($theme); |
| 62 | + } @else { |
| 63 | + @include base($theme); |
| 64 | + @if inspection.theme-has($theme, color) { |
| 65 | + @include color($theme); |
| 66 | + } |
| 67 | + @if inspection.theme-has($theme, density) { |
| 68 | + @include density($theme); |
| 69 | + } |
| 70 | + @if inspection.theme-has($theme, typography) { |
| 71 | + @include typography($theme); |
| 72 | + } |
| 73 | + } |
| 74 | +} |
0 commit comments