Skip to content

Commit

Permalink
feat(demo): Adds Confirm Dialog Demo component
Browse files Browse the repository at this point in the history
  • Loading branch information
pavankjadda committed Jan 2, 2024
1 parent 86aa44e commit c14e751
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions projects/ngxsmart-demo/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ <h1 style="display: flex; justify-content: center; align-items: center; margin-t
<ul>
<li><a routerLink="/autocomplete-demo">Auto Complete Demo</a></li>
<li><a routerLink="/alert-demo">Alert Demo</a></li>
<li><a routerLink="/confirm-dialog-demo">Confirm Dialog Demo</a></li>
<li><a routerLink="/edit-svg-icon-demo">Edit Svg Icon Demo</a></li>
<li><a routerLink="/buttons-demo">Buttons Demo</a></li>
<li><a routerLink="/directives-demo">Directives Demo</a></li>
Expand Down
2 changes: 2 additions & 0 deletions projects/ngxsmart-demo/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { ButtonsDemoComponent } from './buttons-demo/buttons-demo.component';
import { DirectivesDemoComponent } from './directives-demo/directives-demo.component';
import { EditSvgIconDemoComponent } from './edit-svg-icon-demo/edit-svg-icon-demo.component';
import { SnackBarDemoComponent } from './snack-bar-demo/snack-bar-demo.component';
import { ConfirmDialogDemoComponent } from './confirm-dialog-demo/confirm-dialog-demo.component.html-demo.component';

export const routes: Route[] = [
{ path: 'autocomplete-demo', component: AutocompleteDemoComponent },
{ path: 'alert-demo', component: AlertDemoComponent },
{ path: 'confirm-dialog-demo', component: ConfirmDialogDemoComponent },
{ path: 'edit-svg-icon-demo', component: EditSvgIconDemoComponent },
{ path: 'buttons-demo', component: ButtonsDemoComponent },
{ path: 'directives-demo', component: DirectivesDemoComponent },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="m-5">
<primary-button label="Click to Confirm" (click)="confirm()"></primary-button>

<br />
<br />
<section>
<h3 class="mat-h3">
<b class="m-2">Confirm Status:</b>{{confirmStatus()}}
</h3>
</section>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Component, inject, signal } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ConfirmDialogComponent, PrimaryButtonComponent } from '@js-smart/ngxsmart';

@Component({
selector: 'ngxsmart-confirm-dialog-demo',
standalone: true,
templateUrl: './confirm-dialog-demo.component.html',
styles: [``],
imports: [ConfirmDialogComponent, PrimaryButtonComponent],
})
export class ConfirmDialogDemoComponent {
dialog = inject(MatDialog);
confirmStatus = signal('');
confirm() {
const ref = this.dialog.open(ConfirmDialogComponent, {
data: {
title: 'Confirm',
message: 'Are you sure you want to do this?',
},
});

// Listen for confirmation result
ref.afterClosed().subscribe((status: boolean) => {
if (status) {
this.confirmStatus.set('Confirmed');
} else {
this.confirmStatus.set('Canceled');
}
});
}
}

0 comments on commit c14e751

Please sign in to comment.