Skip to content

Commit

Permalink
refactor: add dialog content
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaidio committed Apr 10, 2024
1 parent 60291fc commit 610a56f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
30 changes: 30 additions & 0 deletions apps/angular/dialog-alert-form/src/app/ui/dialog.component.ts
Original file line number Diff line number Diff line change
@@ -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: `
<div role="alert" class="rounded-xl border border-gray-100 bg-white p-5">
<h3 class="block text-xl font-medium text-red-600">
You have unsaved information!
</h3>
<p class="mt-1 text-gray-700">Do you want to continue and lose them?</p>
<div class="mt-4 flex gap-2">
<button
class="inline-flex items-center gap-2 rounded-lg bg-red-600 px-4 py-2 text-white hover:bg-red-700">
Yes continue
</button>
<button
class="block rounded-lg px-4 py-2 text-gray-700 transition hover:bg-gray-50">
Stay on page
</button>
</div>
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AlertDialogComponent {}
12 changes: 4 additions & 8 deletions docs/src/content/docs/challenges/angular/48-dialog-alert-form.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

<details>
<summary>Tips 🤫 (if you really need it and after careful consideration)</summary>
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)
<br>
- Use the CanDeactivate guard - https://angular.io/api/router/CanDeactivate (use new functionnal approach).
</details>

0 comments on commit 610a56f

Please sign in to comment.