Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
Copyright 2026 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<div class="container">
<div class="scroll-mode-indicator">
<div class="label">Scroll Mode:</div>
<mat-icon
[ngClass]="{
scale: isCurrentScalingMode(),
move: !isCurrentScalingMode(),
}"
>{{ isCurrentScalingMode() ? "zoom_out_map" : "open_with" }}</mat-icon
>
<div
class="mode"
[ngClass]="{
scale: isCurrentScalingMode(),
move: !isCurrentScalingMode(),
}"
>
{{ isCurrentScalingMode() ? "Scale" : "Move" }}
</div>
</div>
Comment on lines +18 to +27

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve template readability and reduce redundancy, you can use the @if/@else control flow syntax. This avoids repeating ngClass and ternary operators for the icon and text, making the template cleaner. This also reduces the number of calls to isCurrentScalingMode().

  <div class="scroll-mode-indicator">
    <div class="label">Scroll Mode:</div>
    @if (isCurrentScalingMode()) {
      <mat-icon class="scale">zoom_out_map</mat-icon>
      <div class="mode scale">Scale</div>
    } @else {
      <mat-icon class="move">open_with</mat-icon>
      <div class="mode move">Move</div>
    }
  </div>

<div
class="hint"
[style.visibility]="isCurrentScalingMode() ? 'hidden' : 'visible'"
>
<mat-icon>lightbulb</mat-icon>
<p class="hint-message">
Hold <span class="shift-key">SHIFT</span> &
<span class="scroll"><mat-icon>swap_vert</mat-icon>SCROLL</span> to scale
time
</p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@use "../../common.scss" as common;

:host {
display: block;
}

.container {
height: 100%;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: space-around;
}

.scale {
color: #2e7d32;
}

.move {
color: #1976d2;
}
Comment thread
kyasbal marked this conversation as resolved.

.scroll-mode-indicator {
font-size: 16px;
color: #666;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
display: flex;
align-items: center;
justify-content: center;
padding: 0 5px;

.label {
font-size: 12px;
}

mat-icon {
margin-left: 5px;
@include common.adjust-mat-icon-size(16px);
}
}

.mode {
font-weight: bold;
}

.hint {
display: flex;
align-items: center;
justify-content: center;
gap: 5px;
color: #666;

mat-icon {
@include common.adjust-mat-icon-size(16px);
}

.hint-message {
font-size: 10px;
display: flex;
align-items: center;
gap: 5px;

.shift-key {
font-weight: bold;
color: #666;
border: 1.5px solid #666;
padding: 1px 3px;
font-size: 9px;
border-radius: 3px;
box-sizing: border-box;
}

.scroll {
display: flex;
align-items: center;
font-weight: bold;
color: white;
background-color: #666;
padding: 2px 3px;
font-size: 9px;
border-radius: 3px;
box-sizing: border-box;
mat-icon {
@include common.adjust-mat-icon-size(9px);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { CommonModule } from '@angular/common';
import { Component, input } from '@angular/core';
import { MatIconModule } from '@angular/material/icon';
import { KHIIconRegistrationModule } from 'src/app/shared/module/icon-registration.module';

/**
* The left top corner indicator of the timeline chart.
* It shows the scroll mode of the timeline chart.
*/
@Component({
selector: 'khi-timeline-corner-indicator',
templateUrl: './timeline-corner-indicator.component.html',
styleUrls: ['./timeline-corner-indicator.component.scss'],
imports: [CommonModule, MatIconModule, KHIIconRegistrationModule],
})
export class TimelineCornerIndicatorComponent {
/**
* Whether the current scroll mode is the scaling mode.
*/
readonly isCurrentScalingMode = input(false);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { componentWrapperDecorator, Meta, StoryObj } from '@storybook/angular';
import { TimelineCornerIndicatorComponent } from './timeline-corner-indicator.component';

const meta: Meta<TimelineCornerIndicatorComponent> = {
title: 'Timeline/CornerIndicator',
component: TimelineCornerIndicatorComponent,
tags: ['autodocs'],
parameters: {
layout: 'fullscreen',
},
argTypes: {},
decorators: [
componentWrapperDecorator(
(story) => `
<div style="height: 60px; width: 300px;">
${story}
</div>
`,
),
],
};

export default meta;
type Story = StoryObj<TimelineCornerIndicatorComponent>;

export const Default: Story = {
args: {
isCurrentScalingMode: false,
},
};

export const CurrentScalingMode: Story = {
args: {
isCurrentScalingMode: true,
},
};
113 changes: 113 additions & 0 deletions web/src/app/timeline/components/timeline-legend.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<!--
Copyright 2026 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<div class="container">
<mat-expansion-panel [(expanded)]="expanded">
<mat-expansion-panel-header>Legends</mat-expansion-panel-header>
@let t = timeline();
@if (t === null) {
<ng-container *ngTemplateOutlet="noTimelineSelected"></ng-container>
} @else if (t.layer <= TimelineLayer.Namespace) {
<ng-container
*ngTemplateOutlet="noResourceOrSubresourceSelected"
></ng-container>
Comment thread
kyasbal marked this conversation as resolved.
} @else {
@let tt = timelineTypeLegend();
@if (tt !== null) {
<div
class="timeline-type"
[style.--timeline-type-color]="tt.color"
[style.--timeline-type-background-color]="tt.backgroundColor"
>
<mat-icon>timeline</mat-icon>
<p>Timeline type</p>
<p class="label">{{ tt.label }}</p>
</div>
}
<div class="toggle-button-container">
<mat-button-toggle-group [(value)]="legendType">
<mat-button-toggle value="revisions"
><div class="legend-type-title">
<mat-icon>capture</mat-icon>Revisions
</div></mat-button-toggle
>
<mat-button-toggle value="events"
><div class="legend-type-title">
<mat-icon>nearby </mat-icon>Events
Comment thread
kyasbal marked this conversation as resolved.
Outdated
</div></mat-button-toggle
>
</mat-button-toggle-group>
</div>
@switch (legendType()) {
@case ("revisions") {
@for (legend of revisionLegends(); track legend.label) {
<div class="legend-container">
<div
class="revision-rect"
[style.--revision-color]="legend.color"
[ngClass]="{
'style-normal': legend.style === RevisionStateStyle.Normal,
'style-partial-info':
legend.style === RevisionStateStyle.PartialInfo,
'style-deleted': legend.style === RevisionStateStyle.Deleted,
}"
>
<mat-icon class="material-icons-outlined">{{
legend.icon
}}</mat-icon>
</div>
<p>{{ legend.label }}</p>
</div>
}
}
@case ("events") {
@for (legend of eventLegends(); track legend.label) {
<div class="legend-container">
<div
class="event-rect"
[style.--event-color]="legend.color"
></div>
<p>{{ legend.label }}</p>
</div>
}
<p class="severity-info">
Upper part of each events represents its severity.
Comment thread
kyasbal marked this conversation as resolved.
Outdated
</p>
}
}
}
</mat-expansion-panel>
</div>

<ng-template #noTimelineSelected>
<div class="empty-legend-message">
<div class="empty-legend-message-title">
<mat-icon>ads_click</mat-icon>
<p>No timeline selected</p>
</div>
<p>Please select a timeline to show legends</p>
</div>
</ng-template>

<ng-template #noResourceOrSubresourceSelected>
<div class="empty-legend-message">
<div class="empty-legend-message-title">
<mat-icon>ads_click</mat-icon>
<p>No resource or subresource selected</p>
</div>
<p>Please select a resource or subresource to show legends</p>
</div>
</ng-template>
Loading