Skip to content

Added types file in switch #779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions projects/dxc-ngx-cdk/src/lib/dxc-switch/dxc-switch.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,7 @@ import {
coerceNumberProperty,
} from "@angular/cdk/coercion";
import { BackgroundProviderService } from "../background-provider/service/background-provider.service";

type Space =
| "xxsmall"
| "xsmall"
| "small"
| "medium"
| "large"
| "xlarge"
| "xxlarge";

type Margin = {
top?: Space;
bottom?: Space;
left?: Space;
right?: Space;
};
import { Space, Spacing, SwitchProperties } from "./dxc-switch.types";

@Component({
selector: "dxc-switch",
Expand Down Expand Up @@ -94,11 +79,12 @@ export class DxcSwitchComponent implements OnChanges {
* 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;
@Input() margin: Space | Spacing;
/**
* Size of the component.
*/
@Input() size: "small" | "medium" | "large" | "fillParent" | "fitContent" = "fitContent";
@Input() size: "small" | "medium" | "large" | "fillParent" | "fitContent" =
"fitContent";
/**
* Value of the tabindex.
*/
Expand All @@ -111,14 +97,14 @@ export class DxcSwitchComponent implements OnChanges {
}
private _tabIndexValue = 0;
/**
* This event will be emitted when the user changes the state of the switch.
* This event will be emitted when the user changes the state of the switch.
* The new value of the checked property will be passed as a parameter.
*/
@Output() onChange: EventEmitter<boolean>;

renderedChecked: boolean;

defaultInputs = new BehaviorSubject<any>({
defaultInputs = new BehaviorSubject<SwitchProperties>({
value: null,
checked: false,
disabled: false,
Expand Down
28 changes: 28 additions & 0 deletions projects/dxc-ngx-cdk/src/lib/dxc-switch/dxc-switch.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export interface SwitchProperties {
margin?: Space | Spacing;
checked?: boolean;
value?: string;
disabled?: boolean;
required?: boolean;
label?: string;
name?: string;
labelPosition?: "before" | "after";
size?: "small" | "medium" | "large" | "fillParent" | "fitContent";
tabIndexValue?: number;
}

export type Space =
| "xxsmall"
| "xsmall"
| "small"
| "medium"
| "large"
| "xlarge"
| "xxlarge";

export type Spacing = {
top?: Space;
bottom?: Space;
left?: Space;
right?: Space;
};