Skip to content

Commit 5bc25df

Browse files
committed
refactor: add dialog content
1 parent 60291fc commit 5bc25df

File tree

3 files changed

+41
-15
lines changed

3 files changed

+41
-15
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { ChangeDetectionStrategy, Component } from '@angular/core';
2+
3+
// NOTE : this is just the dialog content, you need to implement dialog logic
4+
5+
@Component({
6+
standalone: true,
7+
template: `
8+
<div role="alert" class="rounded-xl border border-gray-100 bg-white p-5">
9+
<h3 class="block text-xl font-medium text-red-600">
10+
You have unsaved information!
11+
</h3>
12+
13+
<p class="mt-1 text-gray-700">Do you want to continue and lose them?</p>
14+
15+
<div class="mt-4 flex gap-2">
16+
<button
17+
class="inline-flex items-center gap-2 rounded-lg bg-red-600 px-4 py-2 text-white hover:bg-red-700">
18+
Yes continue
19+
</button>
20+
21+
<button
22+
class="block rounded-lg px-4 py-2 text-gray-700 transition hover:bg-gray-50">
23+
Stay on page
24+
</button>
25+
</div>
26+
</div>
27+
`,
28+
changeDetection: ChangeDetectionStrategy.OnPush,
29+
})
30+
export class AlertDialogComponent {}

apps/angular/dialog-alert-form/src/app/ui/nav.component.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ import { RouterLink, RouterLinkActive } from '@angular/router';
77
imports: [RouterLink, RouterLinkActive],
88
template: `
99
<nav
10-
class="inline-flex -space-x-px overflow-hidden rounded-md border bg-white shadow-sm">
10+
class="inline-flex overflow-hidden rounded-md border bg-white shadow-sm">
1111
<a
1212
routerLink="/form"
13-
routerLinkActive="bg-gray-900 text-gray-50 hover:bg-none"
14-
class="inline-block px-4 py-2 text-sm font-medium text-gray-700 focus:relative">
13+
routerLinkActive="bg-gray-300 hover:bg-gray-300"
14+
class="inline-block px-4 py-2 text-sm font-medium text-gray-900 hover:bg-gray-100 focus:relative">
1515
Form
1616
</a>
1717
<a
1818
routerLink="/page-1"
19-
routerLinkActive="bg-gray-900 text-gray-50 hover:bg-none"
20-
class="inline-block px-4 py-2 text-sm font-medium text-gray-700 focus:relative">
19+
routerLinkActive="bg-gray-300 hover:bg-gray-300"
20+
class="inline-block px-4 py-2 text-sm font-medium text-gray-900 hover:bg-gray-100 focus:relative">
2121
Page 1
2222
</a>
2323
<a
2424
routerLink="/page-2"
25-
routerLinkActive="bg-gray-900 text-gray-50 hover:bg-none"
26-
class="inline-block px-4 py-2 text-sm font-medium text-gray-700 focus:relative">
25+
routerLinkActive="bg-gray-300 hover:bg-gray-300"
26+
class="inline-block px-4 py-2 text-sm font-medium text-gray-900 hover:bg-gray-100 focus:relative">
2727
Page 2
2828
</a>
2929
</nav>

docs/src/content/docs/challenges/angular/48-dialog-alert-form.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,13 @@ Here's the feature expressed as a user story (functional expectation)
3232
- If the input text has been pre-filled, then an alert dialog box opens.
3333
- Otherwise, the user navigates normally.
3434

35-
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:
36-
37-
- Continue without saving
38-
- Stay on page
39-
35+
2. The content of dialog.component.ts must be use for your dialog box content
4036
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/)
4137
4. Maximize the use of the new concepts and syntax in the latest version of Angular.
42-
5. (Bonus) : Try to adopt a declarative approach (for dialog opening, for example).
4338

4439
<details>
4540
<summary>Tips 🤫 (if you really need it and after careful consideration)</summary>
46-
Use the Material CDK Dialog - https://material.angular.io/cdk/dialog/overview
47-
Use the CanDeactivate guard - https://angular.io/api/router/CanDeactivate (use new functionnal approach).
41+
- 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)
42+
<br>
43+
- Use the CanDeactivate guard - https://angular.io/api/router/CanDeactivate (use new functionnal approach).
4844
</details>

0 commit comments

Comments
 (0)