Skip to content

Commit 4012cae

Browse files
committed
Style plugin_selector_component for Angular MDC Component migration.
1 parent b846aae commit 4012cae

File tree

2 files changed

+64
-56
lines changed

2 files changed

+64
-56
lines changed

tensorboard/webapp/header/plugin_selector_component.ng.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
limitations under the License.
1616
-->
1717
<mat-tab-group
18+
mat-stretch-tabs="false"
1819
class="active-plugin-list"
1920
[selectedIndex]="getActivePluginIndex()"
2021
animationDuration="100ms"
@@ -34,10 +35,14 @@
3435
</ng-template>
3536
</mat-tab>
3637
</mat-tab-group>
37-
<mat-form-field floatLabel="never" *ngIf="disabledPlugins.length > 0">
38+
<mat-form-field
39+
floatLabel="never"
40+
*ngIf="disabledPlugins.length > 0"
41+
subscriptSizing = "dynamic">
3842
<mat-label>Inactive</mat-label>
3943
<mat-select
4044
[value]="selectedPlugin"
45+
[hideSingleSelectionIndicator]="true"
4146
(selectionChange)="onDisabledPluginSelectionChanged($event)"
4247
>
4348
<mat-option

tensorboard/webapp/header/plugin_selector_component.scss

+58-55
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,39 @@ limitations under the License.
2323
overflow: hidden;
2424
}
2525

26-
mat-form-field {
27-
flex: 0 0;
28-
/* visually center align with _text_ of the select to the center. */
29-
margin-top: 5px;
30-
/* default width is 180px */
31-
width: 130px;
26+
:host mat-form-field ::ng-deep {
27+
// Default width is calculated by the contents of the longest value in the
28+
// select. We override both the trigger and panel widths to be a bit shorter
29+
// than what we see in practice.
30+
// TODO: In Angular 16+ use the panelWidth attribute to set the width of the
31+
// panel to be different than the trigger. (We would likely want the
32+
// trigger to be shorter and the panel to be longer).
33+
width: 144px;
34+
35+
.mdc-text-field {
36+
@include tb-theme-background-prop(background-color, app-bar);
37+
// Default padding is "0 16px".
38+
padding: 0 4px;
39+
}
40+
41+
label.mdc-floating-label.mat-mdc-floating-label,
42+
.mat-mdc-select,
43+
.mat-mdc-select-value,
44+
.mat-mdc-select-arrow {
45+
// Inherit from `color` on the toolbar.
46+
color: inherit;
47+
}
48+
49+
.mdc-text-field--filled:not(.mdc-text-field--disabled) .mdc-line-ripple::before {
50+
// Inherit from `border-color` on the toolbar.
51+
border-color: inherit;
52+
}
3253
}
3354

3455
mat-label,
3556
mat-select,
3657
mat-option {
58+
font-size: 14px;
3759
font-weight: 500;
3860
text-transform: uppercase;
3961
}
@@ -53,83 +75,64 @@ mat-option {
5375
width: 100%;
5476
}
5577

56-
// TODO(tensorboard-team): Can probably remove after migrating away from Legacy Material components.
57-
// These styles exist in `mat-toolbar` already, but the combination of the
58-
// dark theme selector being `body.dark-theme` and the legacy select component
59-
// being used causes the styles to be overwritten in a dark theme.
60-
:host ::ng-deep .mat-form-field.mat-form-field.mat-form-field {
61-
.mat-form-field-underline,
62-
.mat-form-field-ripple,
63-
&.mat-focused .mat-form-field-ripple {
64-
background-color: currentColor;
65-
}
66-
67-
.mat-select-value,
68-
.mat-select-arrow,
69-
&.mat-focused .mat-form-field-label,
70-
&.mat-focused .mat-select-arrow {
71-
color: inherit;
72-
}
73-
}
74-
7578
:host ::ng-deep .active-plugin-list {
7679
// Override mat-tab styling. By default, mat-tab has the right styling but,
7780
// here, we are using it under dark header background. Must invert the color.
7881

79-
&.mat-primary .mat-tab-list .mat-ink-bar {
80-
background-color: currentColor;
82+
.mat-mdc-tab:not(.mat-mdc-tab-disabled) .mdc-tab-indicator__content--underline {
83+
border-color: currentColor;
8184
}
8285

83-
.mat-tab-label,
84-
.mat-tab-link {
85-
// Inherit from `color` on the toolbar.
86-
color: inherit;
87-
// default is .6 and it is too dark against dark background.
88-
opacity: 0.7;
86+
.mat-mdc-tab:not(.mat-mdc-tab-disabled) {
8987

90-
&.mat-tab-label-active {
91-
opacity: 1;
88+
.mdc-tab__text-label {
89+
// Inherit from `color` on the toolbar.
90+
color: inherit;
91+
// default is .6 and it is too dark against dark background.
92+
opacity: 0.7;
9293
}
93-
}
9494

95-
.mat-tab-header-pagination-chevron {
96-
border-color: currentColor;
95+
&.mdc-tab--active .mdc-tab__text-label {
96+
// Repeat color with more-specific selector to override dark-mode styling.
97+
// Inherit from `color` on the toolbar.
98+
color: inherit;
99+
opacity: 1;
100+
}
97101
}
98102

99-
.mat-tab-header-pagination-disabled {
103+
.mat-mdc-tab-header-pagination-disabled {
100104
visibility: hidden;
101105
}
102106

103-
.mat-tab-disabled {
107+
.mat-mdc-tab-disabled {
104108
display: none;
105109
}
106110

107-
mat-tab-list,
108-
.mat-tab-header,
109-
.mat-tab-labels,
110-
.mat-tab-label {
111+
mat-mdc-tab-list,
112+
.mat-mdc-tab-header,
113+
.mat-mdc-tab-labels,
114+
// Extra-specific selector to override dark-mode styling.
115+
.mat-mdc-tab-header .mat-mdc-tab,
116+
.mdc-tab__text-label {
111117
height: 100%;
112118
}
113119

114-
.mat-tab-label {
115-
min-width: 48px; /* default is 160px which is too big for us */
120+
.mat-mdc-tab {
121+
letter-spacing: 0.25px;
122+
min-width: 48px; /* default is 90px which is too big for us */
116123
padding: 0; /* default is 24px */
117124
text-transform: uppercase;
118125
}
119126

120-
.mat-tab-label-content {
121-
height: 100%;
122-
}
123-
124127
mat-tab-header {
125-
.mat-tab-list {
128+
.mat-mdc-tab-list {
126129
// 36px is the size of the chevron. Please see [1] for the reason.
127130
padding: 0 36px;
128131
}
129132

130133
> {
131134
:first-child,
132-
.mat-tab-label-container,
135+
.mat-mdc-tab-label-container,
133136
:last-child {
134137
// [1]: Reason for customizing the mat-tab-header.
135138
//
@@ -150,16 +153,16 @@ mat-option {
150153
}
151154

152155
:first-child,
153-
.mat-tab-label-container {
156+
.mat-mdc-tab-label-container {
154157
left: 0;
155158
}
156159

157160
:last-child,
158-
.mat-tab-label-container {
161+
.mat-mdc-tab-label-container {
159162
right: 0;
160163
}
161164

162-
.mat-tab-header-pagination {
165+
.mat-mdc-tab-header-pagination {
163166
@include tb-theme-background-prop(background-color, app-bar);
164167
}
165168
}

0 commit comments

Comments
 (0)