Skip to content

Commit d742a5e

Browse files
authored
Merge pull request #785 from dxc-technology/jcheng-buttonType
adding type file to button component
2 parents 8edd7bb + c0add2e commit d742a5e

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

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

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,7 @@ import {
1919
} from "@angular/cdk/coercion";
2020
import { DxcButtonIconComponent } from "./dxc-button-icon/dxc-button-icon.component";
2121
import { BackgroundProviderService } from "../background-provider/service/background-provider.service";
22-
23-
type Size = "small" | "medium" | "large" | "fillParent" | "fitContent";
24-
type Space =
25-
| "xxsmall"
26-
| "xsmall"
27-
| "small"
28-
| "medium"
29-
| "large"
30-
| "xlarge"
31-
| "xxlarge";
32-
type Margin = {
33-
top?: Space;
34-
bottom?: Space;
35-
left?: Space;
36-
right?: Space;
37-
};
22+
import { Space, Spacing, ButtonProperties } from "./dxc-button.types";
3823

3924
@Component({
4025
selector: "dxc-button",
@@ -73,11 +58,11 @@ export class DxcButtonComponent {
7358
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
7459
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
7560
*/
76-
@Input() margin: Space | Margin;
61+
@Input() margin: Space | Spacing;
7762
/**
7863
* Size of the component.
7964
*/
80-
@Input() size: Size = "fitContent";
65+
@Input() size: "small" | "medium" | "large" | "fillParent" | "fitContent" = "fitContent";
8166
/**
8267
* This prop corresponds to the 'type' prop of the button in html.
8368
*/
@@ -107,7 +92,7 @@ export class DxcButtonComponent {
10792
lightBackground: boolean = true;
10893
darkBackground: boolean = false;
10994

110-
defaultInputs = new BehaviorSubject<any>({
95+
defaultInputs = new BehaviorSubject<ButtonProperties>({
11196
mode: "primary",
11297
disabled: false,
11398
label: null,
@@ -116,6 +101,7 @@ export class DxcButtonComponent {
116101
margin: null,
117102
size: "fitContent",
118103
tabIndexValue: 0,
104+
type: "button"
119105
});
120106

121107
constructor(
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export type Space =
2+
| "xxsmall"
3+
| "xsmall"
4+
| "small"
5+
| "medium"
6+
| "large"
7+
| "xlarge"
8+
| "xxlarge";
9+
10+
export type Spacing = {
11+
top?: Space;
12+
bottom?: Space;
13+
left?: Space;
14+
right?: Space;
15+
};
16+
17+
export interface ButtonProperties {
18+
mode: "primary" | "secondary" | "text";
19+
label: string;
20+
disabled: boolean;
21+
iconSrc: string;
22+
iconPosition: "before" | "after";
23+
margin: Space | Spacing;
24+
size: "small" | "medium" | "large" | "fillParent" | "fitContent";
25+
type: "reset" | "submit" | "button";
26+
tabIndexValue: number;
27+
}

0 commit comments

Comments
 (0)