Skip to content

Commit 5d338e2

Browse files
authored
HParams: Restyle remove column button (#6466)
## Motivation for features / changes The styling on the remove button was broken by one of the recent changes to the column header. I am fixing and improving it. ## Screenshots of UI changes (or N/A) Dark Mode ![image](https://github.com/tensorflow/tensorboard/assets/78179109/8ef08b52-3266-4b07-b846-7ed8cf7ae1ec) Light Mode ![image](https://github.com/tensorflow/tensorboard/assets/78179109/b42871d5-f6cf-46e4-8a29-c94fe911913a)
1 parent f6f6c44 commit 5d338e2

File tree

3 files changed

+51
-48
lines changed

3 files changed

+51
-48
lines changed

tensorboard/webapp/widgets/data_table/header_cell_component.ng.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222
[ngClass]="highlightStyle$ | async"
2323
>
2424
<ng-content></ng-content>
25-
<div *ngIf="hparamsEnabled && header.removable" class="delete-icon-container">
25+
<div
26+
*ngIf="hparamsEnabled && header.removable"
27+
class="delete-button-container"
28+
>
2629
<button
27-
class="delete-icon"
30+
class="delete-button"
2831
mat-icon-button
2932
i18n-aria-label="A button to delete a data table column."
3033
aria-label="Delete column"
@@ -56,7 +59,10 @@
5659
svgIcon="arrow_downward_24px"
5760
></mat-icon>
5861
</div>
59-
<div *ngIf="controlsEnabled" class="context-menu-container">
62+
<div
63+
*ngIf="header.removable || header.sortable"
64+
class="context-menu-container"
65+
>
6066
<button
6167
mat-icon-button
6268
class="context-menu-trigger"

tensorboard/webapp/widgets/data_table/header_cell_component.scss

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
@import 'tensorboard/webapp/theme/tb_theme';
1818

1919
$_accent: map-get(mat.get-color-config($tb-theme), accent);
20+
$_icon_size: 12px;
2021

2122
:host {
2223
display: table-cell;
@@ -27,73 +28,69 @@ $_accent: map-get(mat.get-color-config($tb-theme), accent);
2728
.context-menu-container {
2829
opacity: 0.8;
2930
}
31+
32+
.show-on-hover {
33+
opacity: 0.3;
34+
}
3035
}
3136
}
37+
3238
.sorting-icon-container {
33-
width: 12px;
34-
height: 12px;
39+
width: $_icon_size;
40+
height: $_icon_size;
3541
border-radius: 5px;
3642
}
37-
.cell mat-icon {
38-
height: 12px;
39-
width: 12px;
40-
}
43+
4144
.cell {
4245
align-items: center;
4346
display: flex;
44-
}
45-
.cell .sorting-icon-container {
46-
::ng-deep path {
47-
fill: unset;
48-
}
49-
}
5047

51-
.cell:hover .delete-icon-container {
52-
opacity: 1;
53-
}
48+
&:hover {
49+
.delete-button-container {
50+
opacity: 1;
51+
}
52+
}
5453

55-
.delete-icon {
56-
background-color: #fff;
57-
border: 0;
58-
border-radius: 50%;
59-
color: mat.get-color-from-palette(mat.$gray-palette, 500);
60-
font-size: 11px;
61-
height: 11px;
62-
margin-top: 2px;
63-
padding: 0;
64-
width: 11px;
54+
mat-icon {
55+
height: $_icon_size;
56+
width: $_icon_size;
57+
}
6558

66-
.mat-icon {
67-
width: 100%;
68-
height: 100%;
59+
.sorting-icon-container {
60+
::ng-deep path {
61+
fill: unset;
62+
}
6963
}
7064
}
7165

72-
.delete-icon:hover {
73-
background-color: mat.get-color-from-palette(mat.$gray-palette, 400);
66+
.delete-button {
67+
display: flex;
68+
align-items: center;
7469
color: #fff;
70+
font-size: $_icon_size;
71+
height: $_icon_size;
72+
width: $_icon_size;
73+
line-height: $_icon_size;
7574
cursor: pointer;
76-
}
7775

78-
.delete-icon-container {
79-
margin-left: -12px;
80-
opacity: 0;
81-
position: absolute;
76+
.mat-icon {
77+
line-height: $_icon_size;
78+
}
8279
}
8380

84-
.delete-icon:hover {
81+
.delete-button-container {
82+
border-radius: 50%;
8583
background-color: mat.get-color-from-palette(mat.$gray-palette, 400);
86-
cursor: pointer;
84+
margin-left: -$_icon_size;
85+
height: $_icon_size;
86+
opacity: 0;
87+
position: absolute;
8788
}
8889

8990
.show {
9091
opacity: 1;
9192
}
9293

93-
:host:hover .show-on-hover {
94-
opacity: 0.3;
95-
}
96-
9794
.show-on-hover {
9895
opacity: 0;
9996
}

tensorboard/webapp/widgets/data_table/header_cell_component_test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ describe('header cell', () => {
133133
.query(By.directive(HeaderCellComponent))
134134
.componentInstance.deleteButtonClicked.subscribe();
135135
fixture.debugElement
136-
.query(By.css('.delete-icon'))
136+
.query(By.css('.delete-button'))
137137
.triggerEventHandler('click', {});
138138

139139
expect(deleteButtonClickedSpy).toHaveBeenCalledOnceWith({
@@ -150,13 +150,13 @@ describe('header cell', () => {
150150
it('renders delete button when hparamsEnabled is true', () => {
151151
const fixture = createComponent({hparamsEnabled: true});
152152

153-
expect(fixture.debugElement.query(By.css('.delete-icon'))).toBeTruthy();
153+
expect(fixture.debugElement.query(By.css('.delete-button'))).toBeTruthy();
154154
});
155155

156156
it('does not render delete button when hparamsEnabled is false', () => {
157157
const fixture = createComponent({hparamsEnabled: false});
158158

159-
expect(fixture.debugElement.query(By.css('.delete-icon'))).toBeFalsy();
159+
expect(fixture.debugElement.query(By.css('.delete-button'))).toBeFalsy();
160160
});
161161

162162
it('does not render delete button when removable is false', () => {
@@ -170,7 +170,7 @@ describe('header cell', () => {
170170
},
171171
});
172172

173-
expect(fixture.debugElement.query(By.css('.delete-icon'))).toBeFalsy();
173+
expect(fixture.debugElement.query(By.css('.delete-button'))).toBeFalsy();
174174
});
175175
});
176176

0 commit comments

Comments
 (0)