Skip to content

Commit 6ab1d2d

Browse files
Fix dialog footer and buttons
1 parent 352a2a2 commit 6ab1d2d

File tree

8 files changed

+37
-7
lines changed

8 files changed

+37
-7
lines changed

projects/ngsuite/src/lib/core/interfaces/Config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { InjectionToken } from '@angular/core';
22
import { NGSuiteComponent } from './Component';
3+
import { ButtonTheme } from '../../form';
34

45
export interface NGSuiteConfig {
56

@@ -22,6 +23,20 @@ export interface NGSuiteConfig {
2223
*/
2324
sectionLoadingAnimation?: NGSuiteComponent;
2425

26+
/**
27+
* Default alert button theme
28+
*
29+
* If this is `undefined`, it defaults to `primary`
30+
*/
31+
defaultAlertButtonTheme?: ButtonTheme;
32+
33+
/**
34+
* Default confirm dialog button theme
35+
*
36+
* If this is `undefined`, it defaults to `primary`
37+
*/
38+
defaultConfirmButtonTheme?: ButtonTheme;
39+
2540
[key: string]: any;
2641
}
2742

projects/ngsuite/src/lib/dialog/popup/alert/alert.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h1 ngs-dialog-title>{{ title }}</h1>
99
</ngs-dialog-body>
1010

1111
<ngs-dialog-footer>
12-
<ngs-button primary (click)="accept()">
12+
<ngs-button [theme]="defaultBtnTheme" (click)="accept()">
1313
<span>Okay</span>
1414
</ngs-button>
1515
</ngs-dialog-footer>

projects/ngsuite/src/lib/dialog/popup/alert/alert.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from "../../components";
1212

1313
import { NGSuiteDialogConfirmComponent } from "../confirm/confirm.component";
14+
import { NGS_CONFIG } from "../../../core";
1415

1516

1617
@Component({
@@ -29,6 +30,9 @@ export class NGSuiteDialogAlertComponent {
2930

3031
private readonly dialogRef = inject(NGSuiteDialogRef<NGSuiteDialogConfirmComponent>);
3132
private readonly data = inject(NGS_DIALOG_DATA);
33+
private readonly config = inject(NGS_CONFIG);
34+
35+
readonly defaultBtnTheme = this.config.defaultAlertButtonTheme || 'primary';
3236

3337
get title() { return this.data.title; }
3438
get message() { return this.data.message; }

projects/ngsuite/src/lib/dialog/popup/confirm/confirm.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h1 ngs-dialog-title>{{ title }}</h1>
1313
<span>Cancel</span>
1414
</ngs-button>
1515

16-
<ngs-button primary (click)="accept()">
16+
<ngs-button [theme]="defaultBtnTheme" (click)="accept()">
1717
<span>Okay</span>
1818
</ngs-button>
1919
</ngs-dialog-footer>

projects/ngsuite/src/lib/dialog/popup/confirm/confirm.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
NGSuiteDialogFooterComponent,
1010
NGSuiteDialogHeaderComponent,
1111
} from "../../components";
12+
import { NGS_CONFIG } from "../../../core";
1213

1314
@Component({
1415
selector: 'ngs-dialog-confirm',
@@ -26,6 +27,9 @@ export class NGSuiteDialogConfirmComponent {
2627

2728
private readonly dialogRef = inject(NGSuiteDialogRef<NGSuiteDialogConfirmComponent>);
2829
private readonly data = inject(NGS_DIALOG_DATA);
30+
private readonly config = inject(NGS_CONFIG);
31+
32+
readonly defaultBtnTheme = this.config.defaultAlertButtonTheme || 'primary';
2933

3034
get title() { return this.data.title; }
3135
get message() { return this.data.message; }

projects/ngsuite/src/lib/form/components/button/button.component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { Component, computed, ElementRef, HostBinding, inject, input, Input } from "@angular/core";
1+
import { Component, computed, ElementRef, HostBinding, inject, input } from "@angular/core";
22
import { Icon, NGSuiteIconComponent } from "../../../core";
33
import { NgClass } from "@angular/common";
44

5-
type ButtonDirection = 'normal' | 'reversed';
6-
type ButtonTheme = 'default' | 'primary' | 'secondary' | 'error' | 'danger' | 'success' | 'warning' | 'info' | 'light' | 'dark';
7-
type ButtonType = 'submit' | 'button' | 'reset' | 'menu';
8-
type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
5+
import {
6+
ButtonDirection,
7+
ButtonSize,
8+
ButtonTheme,
9+
ButtonType,
10+
} from "../../interfaces";
911

1012
@Component({
1113
selector: 'ngs-button',
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export type ButtonDirection = 'normal' | 'reversed';
2+
export type ButtonTheme = 'default' | 'primary' | 'secondary' | 'error' | 'danger' | 'success' | 'warning' | 'info' | 'light' | 'dark';
3+
export type ButtonType = 'submit' | 'button' | 'reset' | 'menu';
4+
export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './Form';
2+
export * from './Button';
23
export * from './Select';

0 commit comments

Comments
 (0)