From b00ce237926a25a75433c4031835b32436aa0db8 Mon Sep 17 00:00:00 2001 From: Timothy Alcaide Date: Wed, 10 Apr 2024 14:29:39 +0200 Subject: [PATCH] refactor: add dialog content --- .../src/app/ui/dialog.component.ts | 30 +++++++++++++++++++ .../src/app/ui/nav.component.ts | 14 ++++----- .../angular/48-dialog-alert-form.md | 12 +++----- 3 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 apps/angular/dialog-alert-form/src/app/ui/dialog.component.ts diff --git a/apps/angular/dialog-alert-form/src/app/ui/dialog.component.ts b/apps/angular/dialog-alert-form/src/app/ui/dialog.component.ts new file mode 100644 index 0000000..661da9b --- /dev/null +++ b/apps/angular/dialog-alert-form/src/app/ui/dialog.component.ts @@ -0,0 +1,30 @@ +import { ChangeDetectionStrategy, Component } from '@angular/core'; + +// NOTE : this is just the dialog content, you need to implement dialog logic + +@Component({ + standalone: true, + template: ` + + `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class AlertDialogComponent {} diff --git a/apps/angular/dialog-alert-form/src/app/ui/nav.component.ts b/apps/angular/dialog-alert-form/src/app/ui/nav.component.ts index 39c0d76..491aeca 100644 --- a/apps/angular/dialog-alert-form/src/app/ui/nav.component.ts +++ b/apps/angular/dialog-alert-form/src/app/ui/nav.component.ts @@ -7,23 +7,23 @@ import { RouterLink, RouterLinkActive } from '@angular/router'; imports: [RouterLink, RouterLinkActive], template: ` diff --git a/docs/src/content/docs/challenges/angular/48-dialog-alert-form.md b/docs/src/content/docs/challenges/angular/48-dialog-alert-form.md index 8a66b90..ec8ab85 100644 --- a/docs/src/content/docs/challenges/angular/48-dialog-alert-form.md +++ b/docs/src/content/docs/challenges/angular/48-dialog-alert-form.md @@ -32,17 +32,13 @@ Here's the feature expressed as a user story (functional expectation) - If the input text has been pre-filled, then an alert dialog box opens. - Otherwise, the user navigates normally. -2. The alert dialog box must be clear and concise, stating: "Caution! You have unsaved information. Do you want to continue and lose them?" with the following button labels: - -- Continue without saving -- Stay on page - +2. The content of dialog.component.ts must be use for your dialog box content 3. The appearance and behavior of the alert dialog box must comply with W3C conventions, see [alert dialog pattern](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/) 4. Maximize the use of the new concepts and syntax in the latest version of Angular. -5. (Bonus) : Try to adopt a declarative approach (for dialog opening, for example).
Tips 🤫 (if you really need it and after careful consideration) - Use the Material CDK Dialog - https://material.angular.io/cdk/dialog/overview - Use the CanDeactivate guard - https://angular.io/api/router/CanDeactivate (use new functionnal approach). + - Use the Material CDK Dialog or Overlay - https://material.angular.io/cdk/ (dont forget to add @import '@angular/cdk/overlay-prebuilt.css' in style.sccss) +
+ - Use the CanDeactivate guard - https://angular.io/api/router/CanDeactivate (use new functionnal approach).