Skip to content

Commit 7819915

Browse files
authored
Linked Time: Update prospective fob styling (#6070)
See #6055 for motivation and styling Unfortunately I broke the zoom functionality with that PR and thus reverted it via #6068 There was [discussion](#6055 (comment)) around removing the DOM restructure present in #6055 and because that was ultimately to blame for the breakage I am resubmitting the PR but without the DOM restructure.
1 parent a59e6e9 commit 7819915

File tree

8 files changed

+54
-20
lines changed

8 files changed

+54
-20
lines changed

tensorboard/webapp/metrics/views/card_renderer/scalar_card_test.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3455,20 +3455,23 @@ describe('scalar card', () => {
34553455
expect(fobs.length).toEqual(1);
34563456

34573457
// Click the prospective fob to set the start time
3458-
fixture.debugElement
3459-
.query(By.css('.prospective-fob-area'))
3460-
.nativeElement.click();
3458+
testController.prospectiveFobClicked(new MouseEvent('mouseclick'));
3459+
fixture.detectChanges();
3460+
3461+
// One start fob
3462+
fobs = fixture.debugElement.queryAll(By.directive(CardFobComponent));
3463+
expect(fobs.length).toEqual(2);
34613464
fixture.detectChanges();
34623465

34633466
// One start fob + 1 prospective fob
3467+
testController.prospectiveStep = 25;
3468+
fixture.detectChanges();
3469+
34643470
fobs = fixture.debugElement.queryAll(By.directive(CardFobComponent));
34653471
expect(fobs.length).toEqual(2);
34663472

34673473
// Click the prospective fob to set the end time
3468-
testController.prospectiveStep = 25;
3469-
fixture.debugElement
3470-
.query(By.css('.prospective-fob-area'))
3471-
.nativeElement.click();
3474+
testController.prospectiveFobClicked(new MouseEvent('mouseclick'));
34723475
fixture.detectChanges();
34733476

34743477
// One start fob, one end fob

tensorboard/webapp/widgets/card_fob/card_fob_component.ng.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
limitations under the License.
1616
-->
1717

18-
<div class="fob">
18+
<div
19+
[ngClass]="{'fob': true, 'unremovable': !allowRemoval, 'prospective': isProspective}"
20+
>
1921
<span
2022
contenteditable
2123
#stepSpan
@@ -34,4 +36,11 @@
3436
>
3537
<mat-icon svgIcon="close_24px"></mat-icon>
3638
</button>
39+
<button
40+
aria-label="Deselect fob"
41+
(click)="fobRemoved.emit()"
42+
*ngIf="isProspective"
43+
>
44+
<mat-icon svgIcon="keep_24px"></mat-icon>
45+
</button>
3746
</div>

tensorboard/webapp/widgets/card_fob/card_fob_component.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,35 @@ limitations under the License.
2525
border-radius: 25px;
2626
padding: 2px 2px 2px 4px;
2727
font-size: 11px;
28+
text-align: center;
2829
width: min-content;
2930

31+
> .prospective {
32+
padding-top: 1px;
33+
}
34+
3035
&:hover {
3136
cursor: grab;
37+
38+
&.prospective {
39+
cursor: pointer;
40+
}
3241
}
3342
&:active {
3443
cursor: grabbing;
3544
}
45+
46+
&.unremovable {
47+
padding: 2px 4px;
48+
}
49+
50+
&.prospective {
51+
align-items: center;
52+
box-sizing: border-box;
53+
border: 1px dashed mat.get-color-from-palette(mat.$gray-palette, 500);
54+
font-weight: bold;
55+
height: 17px;
56+
}
3657
}
3758

3859
span {

tensorboard/webapp/widgets/card_fob/card_fob_component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export class CardFobComponent {
3838

3939
@Input() allowRemoval?: boolean = true;
4040

41+
@Input() isProspective?: boolean = false;
42+
4143
@Output() stepChanged = new EventEmitter<number | null>();
4244
@Output() fobRemoved = new EventEmitter();
4345

tensorboard/webapp/widgets/card_fob/card_fob_controller_component.ng.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,23 @@
2222
<div
2323
#prospectiveFobWrapper
2424
*ngIf="prospectiveStep !== null"
25-
class="time-fob-wrapper prospectiveFob"
25+
class="time-fob-wrapper"
2626
[style.transform]="getCssTranslatePxForProspectiveFob()"
2727
>
2828
<div *ngIf="showExtendedLine" class="extended-line"></div>
2929
<card-fob
3030
[ngClass]="isVertical() ? 'vertical-fob' : 'horizontal-fob'"
3131
[allowRemoval]="false"
32+
[isProspective]="true"
3233
[step]="prospectiveStep"
3334
></card-fob>
3435
</div>
3536
<div
3637
class="prospective-fob-area"
3738
[ngClass]="isVertical() ? 'vertical-prospective-area' : 'horizontal-prospective-area'"
38-
(mousemove)="mouseOver($event)"
39-
(mouseleave)="onProspectiveAreaMouseLeave()"
39+
(mousemove)="mouseOverProspectiveFobArea($event)"
4040
(click)="prospectiveFobClicked($event)"
41+
(mouseleave)="onProspectiveAreaMouseLeave()"
4142
></div>
4243
</ng-container>
4344
<div

tensorboard/webapp/widgets/card_fob/card_fob_controller_component.scss

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,9 @@ limitations under the License.
5151
}
5252
}
5353

54-
.prospectiveFob {
55-
opacity: 0.8;
56-
cursor: pointer;
57-
}
58-
5954
.horizontal-prospective-area {
6055
bottom: 0;
56+
cursor: pointer;
6157
position: absolute;
6258
// Height/Width to match x-axis
6359
height: 30px;

tensorboard/webapp/widgets/card_fob/card_fob_controller_component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export class CardFobControllerComponent {
240240
this.hasFobMoved = true;
241241
}
242242

243-
mouseOver(event: MouseEvent) {
243+
mouseOverProspectiveFobArea(event: MouseEvent) {
244244
if (
245245
this.timeSelection?.end !== null &&
246246
this.timeSelection?.end !== undefined

tensorboard/webapp/widgets/card_fob/card_fob_controller_test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,9 +1417,11 @@ describe('card_fob_controller', () => {
14171417
});
14181418
fixture.detectChanges();
14191419

1420-
fixture.debugElement
1421-
.query(By.css('.prospective-fob-area'))
1422-
.nativeElement.click();
1420+
const testController = fixture.debugElement.query(
1421+
By.directive(CardFobControllerComponent)
1422+
).componentInstance;
1423+
testController.prospectiveFobClicked(new MouseEvent('mouseclick'));
1424+
14231425
expect(onTimeSelectionChanged.calls.allArgs()).toEqual([
14241426
[
14251427
{

0 commit comments

Comments
 (0)