Skip to content

Commit 5935172

Browse files
authored
fix(material/tabs): move unthemable tokens to theme mixin (#27891)
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.
1 parent 5bdeecb commit 5935172

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/material/_index.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ menu-base;
130130
stepper-typography, stepper-density, stepper-base;
131131
@forward './table/table-theme' as table-* show table-theme, table-color, table-typography,
132132
table-density, table-base;
133-
@forward './tabs/tabs-theme' as tabs-* show tabs-theme, tabs-color, tabs-typography, tabs-density;
133+
@forward './tabs/tabs-theme' as tabs-* show tabs-theme, tabs-color, tabs-typography, tabs-density,
134+
tabs-base;
134135
@forward './toolbar/toolbar-theme' as toolbar-* show toolbar-theme, toolbar-color,
135136
toolbar-typography, toolbar-density, toolbar-base;
136137
@forward './tooltip/tooltip-theme' as tooltip-* show tooltip-theme, tooltip-color,

src/material/tabs/_tabs-common.scss

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,6 @@ $mat-tab-animation-duration: 500ms !default;
215215
overflow: hidden;
216216
position: relative;
217217
flex-shrink: 0;
218-
219-
@include mdc-tab-indicator-theme.theme(tokens-mdc-tab-indicator.get-unthemable-tokens());
220-
@include mdc-tab-theme.secondary-navigation-tab-theme(tokens-mdc-tab.get-unthemable-tokens());
221-
@include token-utils.create-token-values(
222-
tokens-mat-tab-header.$prefix, tokens-mat-tab-header.get-unthemable-tokens());
223218
}
224219

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

353348
@mixin paginated-tab-header-with-background($header-selector, $tab-selector) {
354349
&.mat-tabs-with-background {
355-
@include token-utils.create-token-values(
356-
tokens-mat-tab-header-with-background.$prefix,
357-
tokens-mat-tab-header-with-background.get-unthemable-tokens()
358-
);
359-
360350
@include token-utils.use-tokens(
361351
tokens-mat-tab-header-with-background.$prefix,
362352
tokens-mat-tab-header-with-background.get-token-slots()

src/material/tabs/_tabs-theme.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@use '@material/tab-indicator/tab-indicator-theme' as mdc-tab-indicator-theme;
22
@use '@material/tab/tab-theme' as mdc-tab-theme;
3+
@use '../core/style/sass-utils';
34
@use '../core/tokens/m2/mdc/tab' as tokens-mdc-tab;
45
@use '../core/tokens/m2/mdc/tab-indicator' as tokens-mdc-tab-indicator;
56
@use '../core/tokens/m2/mat/tab-header' as tokens-mat-tab-header;
@@ -9,6 +10,19 @@
910
@use '../core/typography/typography';
1011
@use '../core/tokens/token-utils';
1112

13+
@mixin base($theme) {
14+
@include sass-utils.current-selector-or-root() {
15+
@include mdc-tab-indicator-theme.theme(tokens-mdc-tab-indicator.get-unthemable-tokens());
16+
@include mdc-tab-theme.secondary-navigation-tab-theme(tokens-mdc-tab.get-unthemable-tokens());
17+
@include token-utils.create-token-values(
18+
tokens-mat-tab-header.$prefix, tokens-mat-tab-header.get-unthemable-tokens());
19+
@include token-utils.create-token-values(
20+
tokens-mat-tab-header-with-background.$prefix,
21+
tokens-mat-tab-header-with-background.get-unthemable-tokens()
22+
);
23+
}
24+
}
25+
1226
@mixin color($theme) {
1327
.mat-mdc-tab-group, .mat-mdc-tab-nav-bar {
1428
@include _palette-styles($theme, primary);
@@ -77,6 +91,7 @@
7791

7892
@mixin theme($theme) {
7993
@include theming.private-check-duplicate-theme-styles($theme, 'mat-tabs') {
94+
@include base($theme);
8095
@if inspection.theme-has($theme, color) {
8196
@include color($theme);
8297
}

0 commit comments

Comments
 (0)