-
Notifications
You must be signed in to change notification settings - Fork 92
Add TimelineCornerIndicatorComponent and TimelineLegendComponent #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kyasbal
merged 4 commits into
GoogleCloudPlatform:epic/timeline-v2
from
kyasbal:epic/timeline-v2-simple-components
Jan 13, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
web/src/app/timeline/components/timeline-corner-indicator.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <!-- | ||
| 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> | ||
| @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> | ||
110 changes: 110 additions & 0 deletions
110
web/src/app/timeline/components/timeline-corner-indicator.component.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| /** | ||
| * 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; | ||
|
|
||
| $scale-color: #2e7d32; | ||
| $move-color: #1976d2; | ||
| $text-color-secondary: #666; | ||
|
|
||
| :host { | ||
| display: block; | ||
| } | ||
|
|
||
| .container { | ||
| height: 100%; | ||
| overflow: hidden; | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: space-around; | ||
| } | ||
|
|
||
| .scale { | ||
| color: $scale-color; | ||
| } | ||
|
|
||
| .move { | ||
| color: $move-color; | ||
| } | ||
|
kyasbal marked this conversation as resolved.
|
||
|
|
||
| .scroll-mode-indicator { | ||
| font-size: 16px; | ||
| color: $text-color-secondary; | ||
| 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: $text-color-secondary; | ||
|
|
||
| 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: $text-color-secondary; | ||
| border: 1.5px solid $text-color-secondary; | ||
| 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: $text-color-secondary; | ||
| padding: 2px 3px; | ||
| font-size: 9px; | ||
| border-radius: 3px; | ||
| box-sizing: border-box; | ||
| mat-icon { | ||
| @include common.adjust-mat-icon-size(9px); | ||
| } | ||
| } | ||
| } | ||
| } | ||
37 changes: 37 additions & 0 deletions
37
web/src/app/timeline/components/timeline-corner-indicator.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } |
52 changes: 52 additions & 0 deletions
52
web/src/app/timeline/components/timeline-corner-indicator.stories.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
113
web/src/app/timeline/components/timeline-legend.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
|
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 | ||
| </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"> | ||
| The upper half of each diamond represents its severity | ||
| </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> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve template readability and reduce redundancy, you can use the
@if/@elsecontrol flow syntax. This avoids repeatingngClassand ternary operators for the icon and text, making the template cleaner. This also reduces the number of calls toisCurrentScalingMode().