Skip to content

Commit 03f0001

Browse files
palbizuPatricio Albizu
andauthored
feat: adding compact style (#961)
* feat: adding compact style * feat: changing naming from standard to regular Co-authored-by: Patricio Albizu <patricioalbizu@Patricios-MacBook-Pro.local>
1 parent 8206517 commit 03f0001

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

projects/observability/src/shared/components/bar-gauge/bar-gauge.component.scss

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
@import 'mixins';
22

33
.bar-gauge {
4-
.title {
5-
@include overline($gray-7);
6-
padding-bottom: 24px;
7-
}
4+
.header-data {
5+
&.regular {
6+
.title {
7+
@include overline($gray-7);
8+
padding-bottom: 24px;
9+
}
810

9-
.count {
10-
@include subtitle-1($gray-9);
11-
padding-bottom: 8px;
11+
.count {
12+
@include subtitle-1($gray-9);
13+
padding-bottom: 8px;
1214

13-
.units {
14-
@include body-small($gray-5);
15+
.units {
16+
@include body-small($gray-5);
17+
}
18+
}
19+
}
20+
21+
&.compact {
22+
display: flex;
23+
flex-direction: row;
24+
justify-content: space-between;
25+
26+
.title {
27+
@include body-2-medium($gray-7);
28+
}
29+
30+
.count {
31+
@include body-2-regular($gray-5);
32+
}
1533
}
1634
}
1735

projects/observability/src/shared/components/bar-gauge/bar-gauge.component.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ import {
2424
changeDetection: ChangeDetectionStrategy.OnPush,
2525
template: `
2626
<div class="bar-gauge" (htLayoutChange)="this.checkNearMaxValue()">
27-
<div *ngIf="this.title" class="title">{{ this.title | htDisplayTitle }}</div>
28-
<div class="count">
29-
{{ this.totalValue | number }} / {{ this.maxValue | number }}
30-
<span class="units" *ngIf="this.units">{{ this.units }}</span>
27+
<div class="header-data" [ngClass]="this.display">
28+
<div *ngIf="this.title" class="title">{{ this.title | htDisplayTitle }}</div>
29+
<div class="count">
30+
{{ this.totalValue | number }} / {{ this.maxValue | number }}
31+
<span class="units" *ngIf="this.units">{{ this.units }}</span>
32+
</div>
3133
</div>
3234
<div class="bar">
3335
<div #maxValueBar class="max-value-bar" [ngClass]="{ 'over-max-value': this.overMaxValue }">
@@ -45,7 +47,7 @@ import {
4547
</div>
4648
</div>
4749
</div>
48-
<div class="legend">
50+
<div *ngIf="this.display === '${BarGaugeStyle.Regular}'" class="legend">
4951
<div class="legend-item" *ngFor="let segment of this.barSegments">
5052
<span class="legend-symbol" [style.backgroundColor]="segment.color"></span>
5153
<span class="legend-value" *ngIf="this.barSegments.length > 1">{{ segment.value | number }}</span>
@@ -79,6 +81,9 @@ export class BarGaugeComponent implements OnChanges, AfterViewInit {
7981
@Input()
8082
public segments?: Segment[] = [];
8183

84+
@Input()
85+
public display: BarGaugeStyle = BarGaugeStyle.Regular;
86+
8287
public barSegments: BarSegment[] = [];
8388
public totalValue: number = 0;
8489
public overMaxValue: boolean = false;
@@ -148,3 +153,8 @@ export interface Segment {
148153
interface BarSegment extends Segment {
149154
percentage: number;
150155
}
156+
157+
export const enum BarGaugeStyle {
158+
Regular = 'regular',
159+
Compact = 'compact'
160+
}

0 commit comments

Comments
 (0)