Skip to content

Commit

Permalink
fix(material/tabs): move unthemable tokens to theme mixin
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.tabs-theme that are not
emitted by any of: mat.tabs-color, mat.tabs-typography,
mat.tabs-density. If you rely on the partial mixins only and don't
call mat.tabs-theme, you can add mat.tabs-base to get the
missing styles.
  • Loading branch information
mmalerba committed Oct 5, 2023
1 parent c77ffa0 commit e61dedd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/material/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ list-density, list-base;
stepper-typography, stepper-density, stepper-base;
@forward './table/table-theme' as table-* show table-theme, table-color, table-typography,
table-density;
@forward './tabs/tabs-theme' as tabs-* show tabs-theme, tabs-color, tabs-typography, tabs-density;
@forward './tabs/tabs-theme' as tabs-* show tabs-theme, tabs-color, tabs-typography, tabs-density,
tabs-base;
@forward './toolbar/toolbar-theme' as toolbar-* show toolbar-theme, toolbar-color,
toolbar-typography, toolbar-density, toolbar-base;
@forward './tooltip/tooltip-theme' as tooltip-* show tooltip-theme, tooltip-color,
Expand Down
10 changes: 0 additions & 10 deletions src/material/tabs/_tabs-common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@ $mat-tab-animation-duration: 500ms !default;
overflow: hidden;
position: relative;
flex-shrink: 0;

@include mdc-tab-indicator-theme.theme(tokens-mdc-tab-indicator.get-unthemable-tokens());
@include mdc-tab-theme.secondary-navigation-tab-theme(tokens-mdc-tab.get-unthemable-tokens());
@include token-utils.create-token-values(
tokens-mat-tab-header.$prefix, tokens-mat-tab-header.get-unthemable-tokens());
}

.mdc-tab-indicator .mdc-tab-indicator__content {
Expand Down Expand Up @@ -352,11 +347,6 @@ $mat-tab-animation-duration: 500ms !default;

@mixin paginated-tab-header-with-background($header-selector, $tab-selector) {
&.mat-tabs-with-background {
@include token-utils.create-token-values(
tokens-mat-tab-header-with-background.$prefix,
tokens-mat-tab-header-with-background.get-unthemable-tokens()
);

@include token-utils.use-tokens(
tokens-mat-tab-header-with-background.$prefix,
tokens-mat-tab-header-with-background.get-token-slots()
Expand Down
16 changes: 16 additions & 0 deletions src/material/tabs/_tabs-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
@use '../core/typography/typography';
@use '../core/tokens/token-utils';

@mixin base($theme) {
.mat-mdc-tab-header {
@include mdc-tab-indicator-theme.theme(tokens-mdc-tab-indicator.get-unthemable-tokens());
@include mdc-tab-theme.secondary-navigation-tab-theme(tokens-mdc-tab.get-unthemable-tokens());
@include token-utils.create-token-values(
tokens-mat-tab-header.$prefix, tokens-mat-tab-header.get-unthemable-tokens());
}
.mat-tabs-with-background {
@include token-utils.create-token-values(
tokens-mat-tab-header-with-background.$prefix,
tokens-mat-tab-header-with-background.get-unthemable-tokens()
);
}
}

@mixin color($theme) {
.mat-mdc-tab-group, .mat-mdc-tab-nav-bar {
@include _palette-styles($theme, primary);
Expand Down Expand Up @@ -77,6 +92,7 @@

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-tabs') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down

0 comments on commit e61dedd

Please sign in to comment.