Skip to content

Commit 3133274

Browse files
authored
Merge pull request #759 from alcaidio/feat/challenge-48
feat: create challenge 48 without solution
2 parents 94171ad + 230de0c commit 3133274

35 files changed

+3105
-6369
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ If you would like to propose a challenge, this project is open source, so feel f
2424
2525
## Challenges
2626

27-
Check [all 47 challenges](https://angular-challenges.vercel.app/)
27+
Check [all 48 challenges](https://angular-challenges.vercel.app/)
2828

2929
## Contributors ✨
3030

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"extends": ["../../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts"],
7+
"extends": [
8+
"plugin:@nx/angular",
9+
"plugin:@angular-eslint/template/process-inline-templates"
10+
],
11+
"rules": {
12+
"@angular-eslint/directive-selector": [
13+
"error",
14+
{
15+
"type": "attribute",
16+
"prefix": "app",
17+
"style": "camelCase"
18+
}
19+
],
20+
"@angular-eslint/component-selector": [
21+
"error",
22+
{
23+
"type": "element",
24+
"prefix": "app",
25+
"style": "kebab-case"
26+
}
27+
]
28+
}
29+
},
30+
{
31+
"files": ["*.html"],
32+
"extends": ["plugin:@nx/angular-template"],
33+
"rules": {}
34+
}
35+
]
36+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Avoid losing form data
2+
3+
> author: [Timothy Alcaide](https://github.com/alcaidio)
4+
5+
### Run Application
6+
7+
```bash
8+
npx nx serve form-dialog-alert
9+
```
10+
11+
Challenge documentation is [here](https://angular-challenges.vercel.app/challenges/forms/48-form-dialog-alert/).
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"name": "form-dialog-alert",
3+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
4+
"projectType": "application",
5+
"prefix": "app",
6+
"sourceRoot": "apps/forms/form-dialog-alert/src",
7+
"tags": [],
8+
"targets": {
9+
"build": {
10+
"executor": "@angular-devkit/build-angular:application",
11+
"outputs": ["{options.outputPath}"],
12+
"options": {
13+
"outputPath": "dist/apps/forms/form-dialog-alert",
14+
"index": "apps/forms/form-dialog-alert/src/index.html",
15+
"browser": "apps/forms/form-dialog-alert/src/main.ts",
16+
"polyfills": ["zone.js"],
17+
"tsConfig": "apps/forms/form-dialog-alert/tsconfig.app.json",
18+
"inlineStyleLanguage": "scss",
19+
"assets": [
20+
"apps/forms/form-dialog-alert/src/favicon.ico",
21+
"apps/forms/form-dialog-alert/src/assets"
22+
],
23+
"styles": ["apps/forms/form-dialog-alert/src/styles.scss"],
24+
"scripts": []
25+
},
26+
"configurations": {
27+
"production": {
28+
"budgets": [
29+
{
30+
"type": "initial",
31+
"maximumWarning": "500kb",
32+
"maximumError": "1mb"
33+
},
34+
{
35+
"type": "anyComponentStyle",
36+
"maximumWarning": "2kb",
37+
"maximumError": "4kb"
38+
}
39+
],
40+
"outputHashing": "all"
41+
},
42+
"development": {
43+
"optimization": false,
44+
"extractLicenses": false,
45+
"sourceMap": true
46+
}
47+
},
48+
"defaultConfiguration": "production"
49+
},
50+
"serve": {
51+
"executor": "@angular-devkit/build-angular:dev-server",
52+
"configurations": {
53+
"production": {
54+
"buildTarget": "form-dialog-alert:build:production"
55+
},
56+
"development": {
57+
"buildTarget": "form-dialog-alert:build:development"
58+
}
59+
},
60+
"defaultConfiguration": "development"
61+
},
62+
"extract-i18n": {
63+
"executor": "@angular-devkit/build-angular:extract-i18n",
64+
"options": {
65+
"buildTarget": "form-dialog-alert:build"
66+
}
67+
},
68+
"lint": {
69+
"executor": "@nx/eslint:lint"
70+
}
71+
}
72+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Component } from '@angular/core';
2+
import { RouterOutlet } from '@angular/router';
3+
import { NavComponent } from './ui/nav.component';
4+
5+
@Component({
6+
standalone: true,
7+
imports: [RouterOutlet, NavComponent],
8+
selector: 'app-root',
9+
template: `
10+
<div class="h-screen bg-gray-50">
11+
<app-nav
12+
class="mx-auto flex w-full items-center justify-center pb-2 pt-8" />
13+
14+
<main class="px-4 py-16 sm:px-6 lg:px-8">
15+
<router-outlet></router-outlet>
16+
</main>
17+
</div>
18+
`,
19+
})
20+
export class AppComponent {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { ApplicationConfig } from '@angular/core';
2+
import { provideRouter, withComponentInputBinding } from '@angular/router';
3+
import { appRoutes } from './app.routes';
4+
5+
export const appConfig: ApplicationConfig = {
6+
providers: [provideRouter(appRoutes, withComponentInputBinding())],
7+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Route } from '@angular/router';
2+
import { JoinComponent } from './pages/join.component';
3+
import { PageComponent } from './pages/page.component';
4+
5+
export const appRoutes: Route[] = [
6+
{
7+
path: '',
8+
pathMatch: 'full',
9+
redirectTo: 'form',
10+
},
11+
{
12+
path: 'form',
13+
loadComponent: () => JoinComponent,
14+
},
15+
{
16+
path: 'page-1',
17+
data: {
18+
title: 'Page 1',
19+
},
20+
loadComponent: () => PageComponent,
21+
},
22+
{
23+
path: 'page-2',
24+
data: {
25+
title: 'Page 2',
26+
},
27+
loadComponent: () => PageComponent,
28+
},
29+
];
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ChangeDetectionStrategy, Component } from '@angular/core';
2+
import { FormComponent } from '../ui/form.component';
3+
4+
@Component({
5+
standalone: true,
6+
imports: [FormComponent],
7+
template: `
8+
<section class="mx-auto max-w-screen-sm">
9+
<div class="rounded-lg bg-white p-8 shadow-lg lg:p-12">
10+
<app-form />
11+
</div>
12+
</section>
13+
`,
14+
changeDetection: ChangeDetectionStrategy.OnPush,
15+
})
16+
export class JoinComponent {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
2+
3+
@Component({
4+
standalone: true,
5+
template: `
6+
<section>
7+
<h1>{{ title() }}</h1>
8+
</section>
9+
`,
10+
changeDetection: ChangeDetectionStrategy.OnPush,
11+
})
12+
export class PageComponent {
13+
title = input.required<string>();
14+
}
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 {}

0 commit comments

Comments
 (0)