Skip to content

fix(material/autocomplete): define m2 token values inline #31354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions src/material/autocomplete/_autocomplete-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,44 @@
@use '../core/theming/theming';
@use '../core/theming/inspection';
@use '../core/typography/typography';
@use '../core/style/sass-utils';
@use '../core/tokens/token-utils';
@use 'm2-autocomplete';
@use 'm3-autocomplete';

@mixin base($theme) {
$tokens: m2-autocomplete.get-unthemable-tokens();
@if inspection.get-theme-version($theme) == 1 {
@include token-utils.create-token-values(map.get(m3-autocomplete.get-tokens($theme), base));
} @else {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values-mixed(m2-autocomplete.get-unthemable-tokens());
}
$tokens: map.get(m3-autocomplete.get-tokens($theme), base);
}

@include token-utils.values($tokens);
}

@mixin color($theme) {
$tokens: m2-autocomplete.get-color-tokens($theme);
@if inspection.get-theme-version($theme) == 1 {
@include token-utils.create-token-values(map.get(m3-autocomplete.get-tokens($theme), color));
} @else {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values-mixed(m2-autocomplete.get-color-tokens($theme));
}
$tokens: map.get(m3-autocomplete.get-tokens($theme), color);
}

@include token-utils.values($tokens);
}

@mixin typography($theme) {
$tokens: m2-autocomplete.get-typography-tokens($theme);
@if inspection.get-theme-version($theme) == 1 {
@include token-utils.create-token-values(
map.get(m3-autocomplete.get-tokens($theme), typography));
} @else {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values-mixed(m2-autocomplete.get-typography-tokens($theme));
}
$tokens: map.get(m3-autocomplete.get-tokens($theme), typography);
}

@include token-utils.values($tokens);
}

@mixin density($theme) {
$tokens: m2-autocomplete.get-density-tokens($theme);
@if inspection.get-theme-version($theme) == 1 {
@include token-utils.create-token-values(map.get(m3-autocomplete.get-tokens($theme), density));
} @else {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values-mixed(m2-autocomplete.get-density-tokens($theme));
}
$tokens: map.get(m3-autocomplete.get-tokens($theme), density);
}

@include token-utils.values($tokens);
}

/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
Expand Down
6 changes: 4 additions & 2 deletions src/material/core/theming/_all-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@
@mixin all-component-themes($theme) {
$dedupe-key: 'angular-material-theme';
@include theming.private-check-duplicate-theme-styles($theme, $dedupe-key) {
@include autocomplete-theme.theme($theme);

@include core-theme.theme($theme);
@include card-theme.theme($theme);
@include progress-bar-theme.theme($theme);
@include tooltip-theme.theme($theme);
@include form-field-theme.theme($theme);
@include input-theme.theme($theme);
@include select-theme.theme($theme);
@include autocomplete-theme.theme($theme);
@include dialog-theme.theme($theme);
@include chips-theme.theme($theme);
@include slide-toggle-theme.theme($theme);
Expand Down Expand Up @@ -126,14 +127,15 @@
}

@mixin all-component-colors($theme) {
@include autocomplete-theme.color($theme);

@include core-theme.color($theme);
@include card-theme.color($theme);
@include progress-bar-theme.color($theme);
@include tooltip-theme.color($theme);
@include form-field-theme.color($theme);
@include input-theme.color($theme);
@include select-theme.color($theme);
@include autocomplete-theme.color($theme);
@include dialog-theme.color($theme);
@include chips-theme.color($theme);
@include slide-toggle-theme.color($theme);
Expand Down
11 changes: 11 additions & 0 deletions src/material/core/tokens/_token-utils.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@
@return _create-var(--mat-#{$token}, $sys-fallback);
}

// Outputs a map of token values as CSS variable definitions.
@mixin values($tokens) {
@include sass-utils.current-selector-or-root() {
@each $key, $value in $tokens {
@if $value != null {
--mat-#{$key}: #{$value};
}
}
}
}

// Outputs a map of tokens.
@mixin create-token-values($tokens) {
@include _create-token-values-internal($tokens, false);
Expand Down
Loading