Skip to content

Commit 1419be9

Browse files
Merge pull request #31 from klippa-app/extract-button-variants-to-types
refactor: extract button variants into type for reuse and full exposure
2 parents 23ae0b0 + a4fa8e1 commit 1419be9

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

projects/klippa/ngx-enhancy-forms/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@klippa/ngx-enhancy-forms",
3-
"version": "14.7.1",
3+
"version": "14.7.2",
44
"publishConfig": {
55
"access": "public"
66
},

projects/klippa/ngx-enhancy-forms/src/lib/elements/button/button.component.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import { Component, HostBinding, Input } from '@angular/core';
22
import {isValueSet} from "../../util/values";
33

4-
@Component({
5-
selector: 'klp-form-button',
6-
templateUrl: './button.component.html',
7-
styleUrls: ['./button.component.scss'],
8-
})
9-
export class ButtonComponent {
10-
@Input() variant:
11-
| 'white'
4+
export type ButtonVariant = 'white'
125
| 'greenFilled'
136
| 'greenOutlined'
147
| 'greenLink'
158
| 'contextMenuItem'
169
| 'redFilled'
1710
| 'redOutlined'
18-
| 'orangeFilled' = 'white';
11+
| 'orangeFilled';
12+
13+
@Component({
14+
selector: 'klp-form-button',
15+
templateUrl: './button.component.html',
16+
styleUrls: ['./button.component.scss'],
17+
})
18+
export class ButtonComponent {
19+
@Input() variant: ButtonVariant = 'white';
1920
@Input() size: 'small' | 'medium' | 'large' = 'medium';
2021
@Input() fullWidth = false;
2122
@Input() hasBorder = true;

projects/klippa/ngx-enhancy-forms/src/lib/form/form-submit-button/form-submit-button.component.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { Component, Host, HostBinding, Input, Optional } from '@angular/core';
22
import {FormComponent, invalidFieldsSymbol} from '../form.component';
33
import {isNullOrUndefined} from '../../util/values';
4+
import { ButtonVariant } from '../../elements/button/button.component';
5+
6+
export type SubmitButtonVariant = Extract<ButtonVariant,
7+
| 'greenFilled'
8+
| 'redFilled'
9+
| 'greenOutlined'
10+
| 'white'
11+
>;
412

513
@Component({
614
selector: 'klp-form-submit-button',
@@ -10,7 +18,7 @@ import {isNullOrUndefined} from '../../util/values';
1018
export class FormSubmitButtonComponent {
1119
@Input() public isLoading = false;
1220
@Input() fullWidth = false;
13-
@Input() variant: 'greenFilled' | 'redFilled' | 'greenOutlined' = 'greenFilled';
21+
@Input() variant: SubmitButtonVariant = 'greenFilled';
1422
@Input() public before: () => Promise<any> = () => Promise.resolve();
1523
@Input() public after: () => Promise<any> = () => Promise.resolve();
1624
@Input() public submitCallback: (renderedAndEnabledValues: object, renderedButDisabledValues: object) => Promise<any>;

0 commit comments

Comments
 (0)