Skip to content

Commit a780406

Browse files
committed
refactor: merge tabs tokens
1 parent b2265f4 commit a780406

13 files changed

+125
-466
lines changed

src/material/core/tokens/_m2-tokens.scss

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@
2929
@use '../../sort/m2-sort';
3030
@use '../../stepper/m2-stepper';
3131
@use '../../table/m2-table';
32-
@use '../../tabs/m2-secondary-navigation-tab';
33-
@use '../../tabs/m2-tab-header';
34-
@use '../../tabs/m2-tab-header-with-background';
35-
@use '../../tabs/m2-tab-indicator';
32+
@use '../../tabs/m2-tabs';
3633
@use '../../timepicker/m2-timepicker';
3734
@use '../../toolbar/m2-toolbar';
3835
@use '../../tooltip/m2-tooltip';
@@ -117,17 +114,14 @@
117114
_get-tokens-for-module($theme, m2-pseudo-checkbox),
118115
_get-tokens-for-module($theme, m2-radio),
119116
_get-tokens-for-module($theme, m2-ripple),
120-
_get-tokens-for-module($theme, m2-secondary-navigation-tab),
121117
_get-tokens-for-module($theme, m2-select),
122118
_get-tokens-for-module($theme, m2-sidenav),
123119
_get-tokens-for-module($theme, m2-slide-toggle),
124120
_get-tokens-for-module($theme, m2-slider),
125121
_get-tokens-for-module($theme, m2-snack-bar),
126122
_get-tokens-for-module($theme, m2-sort),
127123
_get-tokens-for-module($theme, m2-stepper),
128-
_get-tokens-for-module($theme, m2-tab-header),
129-
_get-tokens-for-module($theme, m2-tab-header-with-background),
130-
_get-tokens-for-module($theme, m2-tab-indicator),
124+
_get-tokens-for-module($theme, m2-tabs),
131125
_get-tokens-for-module($theme, m2-table),
132126
_get-tokens-for-module($theme, m2-timepicker),
133127
_get-tokens-for-module($theme, m2-toolbar),

src/material/core/tokens/_m3-tokens.scss

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
@use '../../sort/m3-sort';
3030
@use '../../stepper/m3-stepper';
3131
@use '../../table/m3-table';
32-
@use '../../tabs/m3-secondary-navigation-tab';
33-
@use '../../tabs/m3-tab-header';
34-
@use '../../tabs/m3-tab-indicator';
32+
@use '../../tabs/m3-tabs';
3533
@use '../../timepicker/m3-timepicker';
3634
@use '../../toolbar/m3-toolbar';
3735
@use '../../tooltip/m3-tooltip';
@@ -442,16 +440,14 @@ $system-variables-prefix) {
442440
m3-pseudo-checkbox.get-tokens($systems, $exclude-hardcoded, $token-slots),
443441
m3-radio.get-tokens($systems, $exclude-hardcoded, $token-slots),
444442
m3-ripple.get-tokens($systems, $exclude-hardcoded, $token-slots),
445-
m3-secondary-navigation-tab.get-tokens($systems, $exclude-hardcoded, $token-slots),
443+
m3-tabs.get-tokens($systems, $exclude-hardcoded, $token-slots),
446444
m3-select.get-tokens($systems, $exclude-hardcoded, $token-slots),
447445
m3-sidenav.get-tokens($systems, $exclude-hardcoded, $token-slots),
448446
m3-slide-toggle.get-tokens($systems, $exclude-hardcoded, $token-slots),
449447
m3-slider.get-tokens($systems, $exclude-hardcoded, $token-slots),
450448
m3-snack-bar.get-tokens($systems, $exclude-hardcoded, $token-slots),
451449
m3-sort.get-tokens($systems, $exclude-hardcoded, $token-slots),
452450
m3-stepper.get-tokens($systems, $exclude-hardcoded, $token-slots),
453-
m3-tab-header.get-tokens($systems, $exclude-hardcoded, $token-slots),
454-
m3-tab-indicator.get-tokens($systems, $exclude-hardcoded, $token-slots),
455451
m3-table.get-tokens($systems, $exclude-hardcoded, $token-slots),
456452
m3-timepicker.get-tokens($systems, $exclude-hardcoded, $token-slots),
457453
m3-toolbar.get-tokens($systems, $exclude-hardcoded, $token-slots),

src/material/tabs/BUILD.bazel

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ package(default_visibility = ["//visibility:public"])
1313
sass_library(
1414
name = "m3",
1515
srcs = [
16-
"_m3-secondary-navigation-tab.scss",
17-
"_m3-tab-header.scss",
18-
"_m3-tab-indicator.scss",
16+
"_m3-tabs.scss",
1917
],
2018
deps = [
2119
"//src/material/core/style:sass_utils",
@@ -26,10 +24,7 @@ sass_library(
2624
sass_library(
2725
name = "m2",
2826
srcs = [
29-
"_m2-secondary-navigation-tab.scss",
30-
"_m2-tab-header.scss",
31-
"_m2-tab-header-with-background.scss",
32-
"_m2-tab-indicator.scss",
27+
"_m2-tabs.scss",
3328
],
3429
deps = [
3530
"//src/material/core/style:elevation",

src/material/tabs/_m2-secondary-navigation-tab.scss

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/material/tabs/_m2-tab-header-with-background.scss

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/material/tabs/_m2-tab-indicator.scss

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/material/tabs/_m2-tab-header.scss renamed to src/material/tabs/_m2-tabs.scss

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
1-
@use '../core/tokens/m2-utils';
1+
@use 'sass:map';
2+
@use '../core/theming/theming';
23
@use '../core/theming/inspection';
34
@use '../core/style/sass-utils';
5+
@use '../core/tokens/m2-utils';
46

57
// The prefix used to generate the fully qualified name for tokens in this file.
68
$prefix: (mat, tab);
79

810
// Tokens that can't be configured through Angular Material's current theming API,
911
// but may be in a future version of the theming API.
12+
//
13+
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
14+
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
15+
// our CSS.
1016
@function get-unthemable-tokens() {
1117
@return (
18+
// This is specified both here and in the density tokens, because it determines the size of the
19+
// tab itself and there are internal tests who don't configure the theme correctly.
20+
container-height: 48px,
1221
// For some period of time, the MDC tabs removed the divider. This has been added back in
1322
// and will be present in M3.
1423
divider-color: transparent,
1524
divider-height: 0,
25+
active-indicator-height: 2px,
26+
// Currently set to zero, but used by the gmat styles to make the indicator rounded.
27+
active-indicator-shape: 0,
1628
);
1729
}
1830

@@ -40,6 +52,9 @@ $prefix: (mat, tab);
4052
active-hover-label-text-color: $active-label-text-color,
4153
active-focus-indicator-color: $active-label-text-color,
4254
active-hover-indicator-color: $active-label-text-color,
55+
active-indicator-color: inspection.get-theme-color($theme, $palette-name, default),
56+
background-color: inspection.get-theme-color($theme, $palette-name, default),
57+
foreground-color: inspection.get-theme-color($theme, $palette-name, default-contrast),
4358
);
4459
}
4560

@@ -57,16 +72,26 @@ $prefix: (mat, tab);
5772

5873
// Tokens that can be configured through Angular Material's density theming API.
5974
@function get-density-tokens($theme) {
60-
@return ();
75+
$scale: theming.clamp-density(inspection.get-theme-density($theme), -4);
76+
77+
@return (
78+
container-height: map.get((
79+
0: 48px,
80+
-1: 44px,
81+
-2: 40px,
82+
-3: 36px,
83+
-4: 32px,
84+
), $scale),
85+
);
6186
}
6287

6388
// Combines the tokens generated by the above functions into a single map with placeholder values.
6489
// This is used to create token slots.
6590
@function get-token-slots() {
6691
@return sass-utils.deep-merge-all(
67-
get-unthemable-tokens(),
68-
get-color-tokens(m2-utils.$placeholder-color-config),
69-
get-typography-tokens(m2-utils.$placeholder-typography-config),
70-
get-density-tokens(m2-utils.$placeholder-density-config)
92+
get-unthemable-tokens(),
93+
get-color-tokens(m2-utils.$placeholder-color-config),
94+
get-typography-tokens(m2-utils.$placeholder-typography-config),
95+
get-density-tokens(m2-utils.$placeholder-density-config)
7196
);
7297
}

src/material/tabs/_m3-secondary-navigation-tab.scss

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/material/tabs/_m3-tab-header.scss

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)