Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions projects/components/src/link/link.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
@import 'color-palette';

.ht-link {
display: flex;
align-items: center;
text-decoration-line: none;
text-decoration: none;
color: inherit;
Expand Down
17 changes: 2 additions & 15 deletions projects/components/src/tabs/content/tab-group.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,8 @@
flex-direction: row;
align-items: center;

.tab-badge {
@include font-label($gray-5);
display: flex;
justify-content: center;
text-align: center;
margin-left: 6px;
padding: 0 6px;
height: 16px;
background-color: $gray-2;
border-radius: 8px;

&.active {
background-color: $gray-9;
color: white;
}
.tab-label-tag {
margin-left: 4px;
}
}

Expand Down
20 changes: 17 additions & 3 deletions projects/components/src/tabs/content/tab-group.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChangeDetectionStrategy, Component, ContentChildren, QueryList } from '@angular/core';
import { Color } from '@hypertrace/common';
import { TabComponent } from './tab/tab.component';

@Component({
Expand All @@ -12,9 +13,14 @@ import { TabComponent } from './tab/tab.component';
<ng-template mat-tab-label>
<div class="tab-label">
{{ tab.label }}
<div *ngIf="tab.badge" [ngClass]="{ active: activeTabIndex === i }" class="tab-badge">
{{ tab.badge }}
</div>
<ng-container *ngIf="tab.labelTag">
<ht-label-tag
class="tab-label-tag"
[label]="tab.labelTag"
[backgroundColor]="this.getBackgroundColor(i)"
[labelColor]="this.getLabelColor(i)"
></ht-label-tag>
</ng-container>
</div>
<div class="ink-bar" [ngClass]="{ active: activeTabIndex === i }"></div>
</ng-template>
Expand All @@ -31,4 +37,12 @@ export class TabGroupComponent {
public tabs!: QueryList<TabComponent>;

public activeTabIndex: number = 0;

public getBackgroundColor(index: number): Color {
return this.activeTabIndex === index ? Color.Gray9 : Color.Gray2;
}

public getLabelColor(index: number): Color {
return this.activeTabIndex === index ? Color.White : Color.Gray5;
}
}
3 changes: 2 additions & 1 deletion projects/components/src/tabs/content/tab.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { MatTabsModule } from '@angular/material/tabs';
import { RouterModule } from '@angular/router';
import { LabelTagModule } from '../../label-tag/label-tag.module';
import { TabGroupComponent } from './tab-group.component';
import { TabComponent } from './tab/tab.component';

@NgModule({
declarations: [TabGroupComponent, TabComponent],
exports: [TabGroupComponent, TabComponent],
imports: [MatTabsModule, CommonModule, RouterModule]
imports: [MatTabsModule, CommonModule, RouterModule, LabelTagModule]
})
export class TabModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export class TabComponent extends ContentHolder {
public label!: string;

@Input()
public badge?: string;
public labelTag?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
padding-bottom: 6px;
}

.tab-label-tag {
margin-left: 4px;
}

.ink-bar {
height: 2px; // plus tab-link is 48
border-radius: 1px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AfterContentInit, ChangeDetectionStrategy, Component, ContentChildren, QueryList } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { FeatureState, NavigationParams, NavigationParamsType, NavigationService } from '@hypertrace/common';
import { Color, FeatureState, NavigationParams, NavigationParamsType, NavigationService } from '@hypertrace/common';
import { merge, Observable } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { NavigableTabComponent } from './navigable-tab.component';
Expand All @@ -22,6 +22,14 @@ import { NavigableTabComponent } from './navigable-tab.component';
class="tab-link"
>
<ng-container *ngTemplateOutlet="tab.content"></ng-container>
<ng-container *ngIf="tab.labelTag">
<ht-label-tag
class="tab-label-tag"
[label]="tab.labelTag"
[backgroundColor]="this.getBackgroundColor(activeTab, tab)"
[labelColor]="this.getLabelColor(activeTab, tab)"
></ht-label-tag>
</ng-container>
<span *ngIf="featureState === '${FeatureState.Preview}'" class="soon-container">
<span class="soon">SOON</span>
</span>
Expand Down Expand Up @@ -60,6 +68,14 @@ export class NavigableTabGroupComponent implements AfterContentInit {
replaceCurrentHistory: tab.replaceHistory
});

public getBackgroundColor(activeTab: NavigableTabComponent | undefined, tab: NavigableTabComponent): Color {
return activeTab === tab ? Color.Gray9 : Color.Gray2;
}

public getLabelColor(activeTab: NavigableTabComponent | undefined, tab: NavigableTabComponent): Color {
return activeTab === tab ? Color.White : Color.Gray5;
}

private findActiveTab(): NavigableTabComponent | undefined {
return this.tabs.find(tab => this.navigationService.isRelativePathActive([tab.path], this.activatedRoute));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export class NavigableTabComponent extends ContentHolder {
@Input()
public hidden: boolean = false;

@Input()
public labelTag?: string;

@Input()
public replaceHistory?: boolean;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MatTabsModule } from '@angular/material/tabs';
import { RouterModule } from '@angular/router';
import { MemoizeModule } from '@hypertrace/common';
import { FeatureConfigCheckModule } from '../../feature-check/feature-config-check.module';
import { LabelTagModule } from '../../label-tag/label-tag.module';
import { LetAsyncModule } from '../../let-async/let-async.module';
import { LinkModule } from '../../link/link.module';
import { NavigableTabGroupComponent } from './navigable-tab-group.component';
Expand All @@ -19,7 +20,8 @@ import { NavigableTabComponent } from './navigable-tab.component';
LetAsyncModule,
FeatureConfigCheckModule,
MemoizeModule,
LinkModule
LinkModule,
LabelTagModule
]
})
export class NavigableTabModule {}
1 change: 1 addition & 0 deletions projects/components/src/tabs/navigable/navigable-tab.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface NavigableTab {
path: string;
label: string;
labelTag?: string;
hidden?: boolean;
features?: string[];
replaceHistory?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { SpanDetailLayoutStyle } from './span-detail-layout-style';
<ht-tab label="Exit Calls" *ngIf="this.showExitCallsTab">
<ht-span-exit-calls [exitCalls]="this.spanData.exitCallsBreakup"></ht-span-exit-calls>
</ht-tab>
<ht-tab *ngIf="this.showLogEventstab" label="Logs" [badge]="this.totalLogEvents">
<ht-tab *ngIf="this.showLogEventstab" label="Logs" [labelTag]="this.totalLogEvents">
<ht-log-events-table
[logEvents]="this.spanData?.logEvents"
[spanStartTime]="this.spanData?.startTime"
Expand Down