From ecb6eb17a4450eb6434365db7c451799fefe3d27 Mon Sep 17 00:00:00 2001 From: Jialecl Date: Tue, 5 Apr 2022 13:54:28 +0200 Subject: [PATCH] Adding type file to accordion --- .../dxc-accordion/dxc-accordion.component.ts | 32 ++++--------------- .../lib/dxc-accordion/dxc-accordion.types.ts | 25 +++++++++++++++ 2 files changed, 32 insertions(+), 25 deletions(-) create mode 100644 projects/dxc-ngx-cdk/src/lib/dxc-accordion/dxc-accordion.types.ts diff --git a/projects/dxc-ngx-cdk/src/lib/dxc-accordion/dxc-accordion.component.ts b/projects/dxc-ngx-cdk/src/lib/dxc-accordion/dxc-accordion.component.ts index 087038bd1..66eac8d4b 100644 --- a/projects/dxc-ngx-cdk/src/lib/dxc-accordion/dxc-accordion.component.ts +++ b/projects/dxc-ngx-cdk/src/lib/dxc-accordion/dxc-accordion.component.ts @@ -21,29 +21,8 @@ import { import { DxcAccordionIconComponent } from "./dxc-accordion-icon/dxc-accordion-icon.component"; import { QueryList, ChangeDetectorRef, ElementRef } from "@angular/core"; import { BackgroundProviderComponent } from "../background-provider/background-provider.component"; +import { AccordionProperties, Space, Spacing } from "./dxc-accordion.types"; -type Space = - | "xxsmall" - | "xsmall" - | "small" - | "medium" - | "large" - | "xlarge" - | "xxlarge"; - -type Margin = { - top?: Space; - bottom?: Space; - left?: Space; - right?: Space; -}; - -type Padding = { - top?: Space; - bottom?: Space; - left?: Space; - right?: Space; -}; @Component({ selector: "dxc-accordion", @@ -84,12 +63,12 @@ export class DxcAccordionComponent implements OnInit, OnChanges, AfterViewInit { * 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 padding to be applied to the custom area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge'). * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes. */ - @Input() padding: Space | Padding; + @Input() padding: Space | Spacing; /** * Represents the state of the panel. When true, the component will be * expanded. If undefined, the component will be uncontrolled and its @@ -126,7 +105,10 @@ export class DxcAccordionComponent implements OnInit, OnChanges, AfterViewInit { @ContentChildren(DxcAccordionIconComponent) dxcAccordionIcon: QueryList; - defaultInputs = new BehaviorSubject({ + defaultInputs = new BehaviorSubject({ + label: "", + assistiveText: "", + isExpanded: false, margin: null, padding: null, disabled: false, diff --git a/projects/dxc-ngx-cdk/src/lib/dxc-accordion/dxc-accordion.types.ts b/projects/dxc-ngx-cdk/src/lib/dxc-accordion/dxc-accordion.types.ts new file mode 100644 index 000000000..09662bf1d --- /dev/null +++ b/projects/dxc-ngx-cdk/src/lib/dxc-accordion/dxc-accordion.types.ts @@ -0,0 +1,25 @@ +export type Space = + | "xxsmall" + | "xsmall" + | "small" + | "medium" + | "large" + | "xlarge" + | "xxlarge"; + +export type Spacing = { + top?: Space; + bottom?: Space; + left?: Space; + right?: Space; +}; + +export interface AccordionProperties { + label: string; + assistiveText?: string; + disabled: boolean; + isExpanded: boolean; + margin?: Space | Spacing; + padding?: Space | Spacing; + tabIndexValue?: number; +}