Skip to content

Commit a2ac2c6

Browse files
authored
Merge pull request #641 from dxc-technology/aida-progressar-types
[Patch] Types for Progress bar component
2 parents 2d75544 + 17f2531 commit a2ac2c6

File tree

2 files changed

+59
-8
lines changed

2 files changed

+59
-8
lines changed

projects/dxc-ngx-cdk-site/src/app/components/examples/progressbar/properties/progressbar-table-properties.component.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
<dxc-heading [level]="4" weight="normal" text="Properties" [margin]="{bottom:'small'}"></dxc-heading>
1+
<dxc-heading
2+
[level]="4"
3+
weight="normal"
4+
text="Properties"
5+
[margin]="{ bottom: 'small' }"
6+
></dxc-heading>
27
<dxc-table>
38
<tr>
49
<th>Name</th>
@@ -10,6 +15,11 @@
1015
<td></td>
1116
<td>Text to be placed above the progress bar.</td>
1217
</tr>
18+
<tr>
19+
<td>helperText: string</td>
20+
<td></td>
21+
<td>Helper text to be placed under the progress bar.</td>
22+
</tr>
1323
<tr>
1424
<td>overlay: boolean</td>
1525
<td>
@@ -33,7 +43,7 @@
3343
<td>If true, the value is displayed above the progress bar.</td>
3444
</tr>
3545
<tr>
36-
<td>margin: any (string | object)</td>
46+
<td>margin: string | object</td>
3747
<td></td>
3848
<td>
3949
Size of the margin to be applied to the component ('xxsmall' | 'xsmall' |

projects/dxc-ngx-cdk/src/lib/dxc-progressbar/dxc-progressbar.component.ts

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,59 @@ import { BehaviorSubject } from "rxjs";
44
import { CssUtils } from "../utils";
55
import { coerceBooleanProperty } from "@angular/cdk/coercion";
66

7+
type Space =
8+
| "xxsmall"
9+
| "xsmall"
10+
| "small"
11+
| "medium"
12+
| "large"
13+
| "xlarge"
14+
| "xxlarge";
15+
16+
type Margin = {
17+
top?: Space;
18+
bottom?: Space;
19+
left?: Space;
20+
right?: Space;
21+
};
22+
723
@Component({
824
selector: "dxc-progressbar",
925
templateUrl: "./dxc-progressbar.component.html",
1026
providers: [CssUtils],
1127
})
1228
export class DxcProgressbarComponent {
13-
mode: string = "indeterminate";
29+
30+
/**
31+
* The value of the progress indicator. If it's received the component is determinate otherwise is indeterminate.
32+
*/
1433
@Input() value: number;
34+
35+
/**
36+
* Text to be placed above the progress bar.
37+
*/
1538
@Input() label: string;
39+
40+
/**
41+
* Helper text to be placed under the progress bar.
42+
*/
1643
@Input() helperText: string;
44+
45+
/**
46+
* If true, the value is displayed above the progress bar.
47+
*/
1748
@Input()
1849
get showValue(): boolean {
1950
return this._showValue;
2051
}
2152
set showValue(value: boolean) {
2253
this._showValue = coerceBooleanProperty(value);
2354
}
24-
private _showValue;
55+
private _showValue = false;
56+
57+
/**
58+
* If true, the progress bar will be displayed as a modal.
59+
*/
2560
@Input()
2661
get overlay(): boolean {
2762
return this._overlay;
@@ -30,14 +65,19 @@ export class DxcProgressbarComponent {
3065
this._overlay = coerceBooleanProperty(value);
3166
}
3267
private _overlay = false;
33-
@Input() margin: any;
68+
69+
/**
70+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
71+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
72+
*/
73+
@Input() margin: Space | Margin;
3474

3575
@HostBinding("class") className;
3676
@HostBinding("class.absolute") isAbsolute: boolean = false;
3777

78+
mode: string = "indeterminate";
79+
3880
defaultInputs = new BehaviorSubject<any>({
39-
showValue: false,
40-
mode: "large",
4181
overlay: false,
4282
});
4383

@@ -82,6 +122,7 @@ export class DxcProgressbarComponent {
82122
this.mode = "determinate";
83123
}
84124
}
125+
85126
getDynamicStyle(inputs) {
86127
return css`
87128
${this.utils.getMargins(inputs.margin)}
@@ -145,7 +186,7 @@ export class DxcProgressbarComponent {
145186
fill: transparent;
146187
}
147188
}
148-
.helperText{
189+
.helperText {
149190
font-family: var(--progressBar-helperTextFontFamily);
150191
font-size: var(--progressBar-helperTextFontSize);
151192
font-style: var(--progressBar-helperTextFontStyle);

0 commit comments

Comments
 (0)