@@ -46,8 +46,17 @@ $mat-tab-animation-duration: 500ms !default;
46
46
}
47
47
48
48
-webkit-tap-highlight-color : transparent ;
49
+ -webkit-font-smoothing : antialiased ;
50
+ -moz-osx-font-smoothing : grayscale ;
49
51
text-decoration : none ;
50
52
53
+ & .mdc-tab {
54
+ // MDC's tabs stretch to fit the header by default, whereas stretching on our current ones
55
+ // is an opt-in behavior. Also technically we don't need to combine the two classes, but
56
+ // we need the extra specificity to avoid issues with CSS insertion order.
57
+ flex-grow : 0 ;
58
+ }
59
+
51
60
@include token-utils .use-tokens (
52
61
tokens-mat-tab-header .$prefix ,
53
62
tokens-mat-tab-header .get-token-slots ()
@@ -57,28 +66,59 @@ $mat-tab-animation-duration: 500ms !default;
57
66
@include token-utils .create-token-slot (letter-spacing , label- text- letter- spacing);
58
67
@include token-utils .create-token-slot (line-height , label- text- line- height);
59
68
@include token-utils .create-token-slot (font-weight , label- text- weight);
60
- }
61
69
62
- & .mdc-tab {
63
- // MDC's tabs stretch to fit the header by default, whereas stretching on our current ones
64
- // is an opt-in behavior. Also technically we don't need to combine the two classes, but
65
- // we need the extra specificity to avoid issues with CSS insertion order.
66
- flex-grow : 0 ;
70
+ & :hover .mdc-tab__text-label {
71
+ @include token-utils .create-token-slot (color , inactive- hover- label- text- color);
72
+ }
67
73
68
- & :not (.mat-mdc-tab-disabled ).mdc-tab--active .mdc-tab__text-label {
69
- @include token-utils .use-tokens (
70
- tokens-mat-tab-header .$prefix ,
71
- tokens-mat-tab-header .get-token-slots ()
72
- ) {
74
+ & :focus .mdc-tab__text-label {
75
+ @include token-utils .create-token-slot (color , inactive- focus- label- text- color);
76
+ }
77
+
78
+ & .mdc-tab--active {
79
+ .mdc-tab__text-label {
73
80
@include token-utils .create-token-slot (color , active- label- text- color);
74
81
}
82
+
83
+ .mdc-tab__ripple ::before ,
84
+ .mat-ripple-element {
85
+ @include token-utils .create-token-slot (background-color , active- ripple- color);
86
+ }
87
+
88
+ & :hover {
89
+ .mdc-tab__text-label {
90
+ @include token-utils .create-token-slot (color , active- hover- label- text- color);
91
+ }
92
+
93
+ .mdc-tab-indicator__content--underline {
94
+ @include token-utils .create-token-slot (border-color , active- hover- indicator- color);
95
+ }
96
+ }
97
+
98
+ & :focus {
99
+ .mdc-tab__text-label {
100
+ @include token-utils .create-token-slot (color , active- focus- label- text- color);
101
+ }
102
+
103
+ .mdc-tab-indicator__content--underline {
104
+ @include token-utils .create-token-slot (border-color , active- focus- indicator- color);
105
+ }
106
+ }
75
107
}
76
108
}
77
109
78
110
& .mat-mdc-tab-disabled {
79
111
// MDC doesn't support disabled tabs so we need to improvise.
80
112
opacity : 0.4 ;
81
113
114
+ // We use `pointer-events` to make the element unclickable when it's disabled, rather than
115
+ // preventing the default action through JS, because we can't prevent the action reliably
116
+ // due to other directives potentially registering their events earlier. This shouldn't cause
117
+ // the user to click through, because we always have a header behind the tab. Furthermore, this
118
+ // saves us some CSS, because we don't have to add `:not(.mat-mdc-tab-disabled)` to all the
119
+ // hover and focus selectors.
120
+ pointer-events : none ;
121
+
82
122
@include token-utils .use-tokens (
83
123
tokens-mat-tab-header .$prefix ,
84
124
tokens-mat-tab-header .get-token-slots ()
@@ -107,7 +147,7 @@ $mat-tab-animation-duration: 500ms !default;
107
147
tokens-mat-tab-header .$prefix ,
108
148
tokens-mat-tab-header .get-token-slots ()
109
149
) {
110
- @include token-utils .create-token-slot (background-color , ripple- color);
150
+ @include token-utils .create-token-slot (background-color , inactive - ripple- color);
111
151
}
112
152
}
113
153
@@ -154,7 +194,7 @@ $mat-tab-animation-duration: 500ms !default;
154
194
tokens-mat-tab-header .$prefix ,
155
195
tokens-mat-tab-header .get-token-slots ()
156
196
) {
157
- @include token-utils .create-token-slot (background-color , ripple- color);
197
+ @include token-utils .create-token-slot (background-color , inactive - ripple- color);
158
198
}
159
199
}
160
200
}
@@ -202,7 +242,7 @@ $mat-tab-animation-duration: 500ms !default;
202
242
tokens-mat-tab-header .$prefix ,
203
243
tokens-mat-tab-header .get-token-slots ()
204
244
) {
205
- @include token-utils .create-token-slot (background-color , ripple- color);
245
+ @include token-utils .create-token-slot (background-color , inactive - ripple- color);
206
246
}
207
247
}
208
248
0 commit comments