Skip to content

Commit

Permalink
fix(material/list): Move unthemable tokens to theme mixin (#27607)
Browse files Browse the repository at this point in the history
Though these tokens are not currently affected by the theme, in the
future they will be affected by the design system used for theming (M2
or M3)

BREAKING CHANGE:
There are new styles emitted by `mat.list-theme` that are not
emitted by any of: `mat.list-color`, `mat.list-typography`,
`mat.list-density`. If you rely on the partial mixins only and don't
call `mat.list-theme`, you can add `mat.list-base` to get the
missing styles.
  • Loading branch information
amysorto authored Aug 14, 2023
1 parent 65c9717 commit 7c16cc8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/material/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
@forward './icon/icon-theme' as icon-* show icon-theme, icon-color, icon-typography, icon-density;
@forward './input/input-theme' as input-* show input-theme, input-color, input-typography,
input-density;
@forward './list/list-theme' as list-* show list-theme, list-color, list-typography, list-density;
@forward './list/list-theme' as list-* show list-theme, list-color, list-typography,
list-density, list-base;
@forward './menu/menu-theme' as menu-* show menu-theme, menu-color, menu-typography, menu-density;
@forward './paginator/paginator-theme' as paginator-* show paginator-theme, paginator-color,
paginator-typography, paginator-density;
Expand Down
9 changes: 9 additions & 0 deletions src/material/list/_list-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@
@use '@material/radio/radio-theme' as mdc-radio-theme;
@use '@material/list/list-theme' as mdc-list-theme;

@use '../core/style/sass-utils';
@use '../core/theming/theming';
@use '../core/tokens/m2/mdc/checkbox' as tokens-mdc-checkbox;
@use '../core/tokens/m2/mdc/radio' as tokens-mdc-radio;
@use '../core/tokens/m2/mdc/list' as tokens-mdc-list;
@use '../core/typography/typography';
@use '../core/typography/typography-utils';

@mixin base($config-or-theme) {
// Add default values for tokens not related to color, typography, or density.
@include sass-utils.current-selector-or-root() {
@include mdc-list-theme.theme(tokens-mdc-list.get-unthemable-tokens());
}
}

@mixin color($config-or-theme) {
$config: theming.get-color-config($config-or-theme);
$primary: map.get($config, primary);
Expand Down Expand Up @@ -140,6 +148,7 @@
$density: theming.get-density-config($theme);
$typography: theming.get-typography-config($theme);

@include base($theme);
@if $color != null {
@include color($color);
}
Expand Down
5 changes: 0 additions & 5 deletions src/material/list/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@
@include token-utils.create-token-slot(background-color, list-item-leading-avatar-color);
}
}

// Add default values for tokens that aren't outputted by the theming API.
.mat-mdc-list-base {
@include mdc-list-theme.theme(m2-mdc-list.get-unthemable-tokens());
}
}

a.mdc-list-item--activated {
Expand Down

0 comments on commit 7c16cc8

Please sign in to comment.