diff --git a/projects/dxc-ngx-cdk-site/src/app/components/examples/button/properties/button-table-properties/button-table-properties.component.html b/projects/dxc-ngx-cdk-site/src/app/components/examples/button/properties/button-table-properties/button-table-properties.component.html index d060a8ae4..a97fb1aa5 100644 --- a/projects/dxc-ngx-cdk-site/src/app/components/examples/button/properties/button-table-properties/button-table-properties.component.html +++ b/projects/dxc-ngx-cdk-site/src/app/components/examples/button/properties/button-table-properties/button-table-properties.component.html @@ -11,7 +11,7 @@ Description - mode: string ('primary' | 'secondary' | 'text') + mode: 'primary' | 'secondary' | 'text' 'primary' @@ -20,7 +20,7 @@ label: string - Text to be placed next to the button. + Text to be placed inside the button. iconSrc: string @@ -31,7 +31,7 @@ - iconPosition: string ('before' | 'after') + iconPosition: 'before' | 'after' 'before' @@ -44,11 +44,6 @@ If true, the component will be disabled. - - tabIndexValue: number - 0 - Value of the tabindex. - onClick: EventEmitter @@ -58,7 +53,7 @@ - margin: any (string | object) + margin: string | object Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | @@ -68,11 +63,16 @@ - size: any (string | object) - + size: string + 'fitContent' Size of the component ('small' | 'medium' | 'large' | 'fillParent' | 'fitContent'). + + tabIndexValue: number + 0 + Value of the tabindex. + diff --git a/projects/dxc-ngx-cdk/src/lib/dxc-button/README.md b/projects/dxc-ngx-cdk/src/lib/dxc-button/README.md index ea508ed40..d4835fc65 100644 --- a/projects/dxc-ngx-cdk/src/lib/dxc-button/README.md +++ b/projects/dxc-ngx-cdk/src/lib/dxc-button/README.md @@ -42,7 +42,7 @@ The API properties are the following: Description - @Input
mode: string ('primary' | 'secondary' | 'text') + @Input
'primary' | 'secondary' | 'text' 'primary' @@ -51,7 +51,7 @@ The API properties are the following: @Input
label: string - Text to be placed next to the button. + Text to be placed inside the button. @Input
iconSrc: string @@ -59,7 +59,7 @@ The API properties are the following: URL of the icon that will be placed next to the button label. - @Input
iconPosition: string ('before' | 'after') + @Input
iconPosition: 'before' | 'after' 'before' @@ -81,7 +81,7 @@ The API properties are the following: - @Input
margin: any (string | object) + @Input
margin: string | object Size of the margin to be applied to the component ('xxsmall' | @@ -91,7 +91,7 @@ The API properties are the following: - @Input
size: any (string | object) + @Input
size: string | object Size of the component ('small' | 'medium' | 'large' | 'fillParent' | diff --git a/projects/dxc-ngx-cdk/src/lib/dxc-button/dxc-button.component.ts b/projects/dxc-ngx-cdk/src/lib/dxc-button/dxc-button.component.ts index 0694657ca..4eae43767 100644 --- a/projects/dxc-ngx-cdk/src/lib/dxc-button/dxc-button.component.ts +++ b/projects/dxc-ngx-cdk/src/lib/dxc-button/dxc-button.component.ts @@ -20,13 +20,35 @@ import { import { DxcButtonIconComponent } from "./dxc-button-icon/dxc-button-icon.component"; import { BackgroundProviderService } from "../background-provider/service/background-provider.service"; +type Size = "small" | "medium" | "large" | "fillParent" | "fitContent"; +type Space = + | "xxsmall" + | "xsmall" + | "small" + | "medium" + | "large" + | "xlarge" + | "xxlarge"; +type Margin = { + top?: Space; + bottom?: Space; + left?: Space; + right?: Space; +}; + @Component({ selector: "dxc-button", templateUrl: "./dxc-button.component.html", providers: [CssUtils], }) export class DxcButtonComponent { - @Input() mode: string; + /** + * Uses one of the available button modes. + */ + @Input() mode: "primary" | "secondary" | "text" = "primary"; + /** + * If true, the component will be disabled. + */ @Input() get disabled(): boolean { return this._disabled; @@ -34,12 +56,31 @@ export class DxcButtonComponent { set disabled(value: boolean) { this._disabled = coerceBooleanProperty(value); } - private _disabled; + private _disabled = false; + /** + * Text to be placed inside the button. + */ @Input() label: string; + /** + * @deprecated URL of the icon that will be placed next to the button label. + */ @Input() iconSrc: string; - @Input() iconPosition: string; - @Input() margin: any; - @Input() size: string; + /** + * Whether the icon should appear after or before the label. + */ + @Input() iconPosition: "before" | "after" = "before"; + /** + * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge'). + * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes. + */ + @Input() margin: Space | Margin; + /** + * Size of the component. + */ + @Input() size: Size = "fitContent"; + /** + * Value of the tabindex attribute. + */ @Input() get tabIndexValue(): number { return this._tabIndexValue; @@ -47,9 +88,12 @@ export class DxcButtonComponent { set tabIndexValue(value: number) { this._tabIndexValue = coerceNumberProperty(value); } - private _tabIndexValue; + private _tabIndexValue = 0; - @Output() onClick = new EventEmitter(); + /** + * This function will be called when the user clicks the button. + */ + @Output() onClick: EventEmitter = new EventEmitter(); @HostBinding("class") className;