Skip to content

Commit ba2ed52

Browse files
palbizuPatricio Albizu
andauthored
feat: Adding unlimited value (#1014)
* feat: Adding unlimited value * feat: Adding uts Co-authored-by: Patricio Albizu <[email protected]>
1 parent 9de0d0e commit ba2ed52

File tree

3 files changed

+62
-4
lines changed

3 files changed

+62
-4
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
@include subtitle-1($gray-9);
1313
padding-bottom: 8px;
1414

15+
.unlimited-symbol {
16+
position: relative;
17+
top: 3px;
18+
font-size: 28px;
19+
line-height: 0px;
20+
}
21+
1522
.units {
1623
@include body-small($gray-5);
1724
}
@@ -22,13 +29,21 @@
2229
display: flex;
2330
flex-direction: row;
2431
justify-content: space-between;
32+
padding: 0px 2px;
2533

2634
.title {
2735
@include body-2-medium($gray-7);
2836
}
2937

3038
.count {
3139
@include body-2-regular($gray-5);
40+
41+
.unlimited-symbol {
42+
font-size: 18px;
43+
position: relative;
44+
top: 2px;
45+
line-height: 0px;
46+
}
3247
}
3348
}
3449
}
@@ -42,7 +57,7 @@
4257
height: 100%;
4358
width: 100%;
4459
background: $gray-2;
45-
border-radius: 4px;
60+
border-radius: 16px;
4661
overflow: hidden;
4762

4863
&.over-max-value {

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

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ describe('Bar Gauge component', () => {
5353
title="Test Title"
5454
[segments]="segments"
5555
[maxValue]="maxValue"
56+
[isUnlimited]="isUnlimited"
5657
></ht-bar-gauge>
5758
`
5859
});
@@ -72,7 +73,8 @@ describe('Bar Gauge component', () => {
7273
label: 'test-segment-yellow'
7374
}
7475
],
75-
maxValue: 100
76+
maxValue: 100,
77+
isUnlimited: false
7678
}
7779
});
7880
spectator.tick();
@@ -94,6 +96,7 @@ describe('Bar Gauge component', () => {
9496
value: 33
9597
}
9698
]);
99+
expect(spectator.component.isUnlimited).toEqual(false);
97100
}));
98101

99102
test('assigns correct values when near full', fakeAsync(() => {
@@ -215,5 +218,38 @@ describe('Bar Gauge component', () => {
215218
value: 33
216219
}
217220
]);
221+
expect(spectator.query('.unlimited-symbol')).not.toExist();
222+
}));
223+
224+
test('should display unlimited value', fakeAsync(() => {
225+
spectator = createHost(undefined, {
226+
providers: [
227+
MockProvider(DomElementMeasurerService, {
228+
measureHtmlElement: setMeasureHtmlElement(100)
229+
})
230+
],
231+
hostProps: {
232+
segments: [
233+
{
234+
value: 100,
235+
color: 'red',
236+
label: 'test-segment-red'
237+
}
238+
],
239+
maxValue: 100,
240+
isUnlimited: true
241+
}
242+
});
243+
spectator.tick();
244+
expect(spectator.component.totalValue).toEqual(100);
245+
expect(spectator.component.barSegments).toEqual([
246+
{
247+
value: 100,
248+
color: 'red',
249+
percentage: 100,
250+
label: 'test-segment-red'
251+
}
252+
]);
253+
expect(spectator.query('.unlimited-symbol')).toExist();
218254
}));
219255
});

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ import {
2727
<div class="header-data" [ngClass]="this.display">
2828
<div *ngIf="this.title" class="title">{{ this.title | htDisplayTitle }}</div>
2929
<div class="count">
30-
{{ this.totalValue | number }} / {{ this.maxValue | number }}
31-
<span class="units" *ngIf="this.units">{{ this.units }}</span>
30+
<span>{{ this.totalValue | number }}</span>
31+
<span class="units" *ngIf="this.units && this.isUnlimited"> {{ this.units }}</span>
32+
<span> / </span>
33+
<span *ngIf="!this.isUnlimited">{{ this.maxValue | number }}</span>
34+
<span class="unlimited-symbol" *ngIf="this.isUnlimited">&#8734;</span>
35+
<span class="units" *ngIf="this.units && !this.isUnlimited"> {{ this.units }}</span>
3236
</div>
3337
</div>
3438
<div class="bar">
@@ -84,6 +88,9 @@ export class BarGaugeComponent implements OnChanges, AfterViewInit {
8488
@Input()
8589
public display: BarGaugeStyle = BarGaugeStyle.Regular;
8690

91+
@Input()
92+
public isUnlimited: boolean = false;
93+
8794
public barSegments: BarSegment[] = [];
8895
public totalValue: number = 0;
8996
public overMaxValue: boolean = false;

0 commit comments

Comments
 (0)