mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 04:43:03 -05:00
feat: create challenge 48 without solution
This commit is contained in:
36
apps/angular/dialog-alert-form/.eslintrc.json
Normal file
36
apps/angular/dialog-alert-form/.eslintrc.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"extends": ["../../../.eslintrc.json"],
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts"],
|
||||
"extends": [
|
||||
"plugin:@nx/angular",
|
||||
"plugin:@angular-eslint/template/process-inline-templates"
|
||||
],
|
||||
"rules": {
|
||||
"@angular-eslint/directive-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "attribute",
|
||||
"prefix": "app",
|
||||
"style": "camelCase"
|
||||
}
|
||||
],
|
||||
"@angular-eslint/component-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "element",
|
||||
"prefix": "app",
|
||||
"style": "kebab-case"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["*.html"],
|
||||
"extends": ["plugin:@nx/angular-template"],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
11
apps/angular/dialog-alert-form/README.md
Normal file
11
apps/angular/dialog-alert-form/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Save your form's bacon: with the navigation alert
|
||||
|
||||
> author: [Timothy Alcaide](https://github.com/alcaidio)
|
||||
|
||||
### Run Application
|
||||
|
||||
```bash
|
||||
npx nx serve angular-dialog-alert-form
|
||||
```
|
||||
|
||||
Challenge documentation is [here](https://angular-challenges.vercel.app/challenges/angular/48-dialog-alert-form/).
|
||||
72
apps/angular/dialog-alert-form/project.json
Normal file
72
apps/angular/dialog-alert-form/project.json
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"name": "angular-dialog-alert-form",
|
||||
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
||||
"projectType": "application",
|
||||
"prefix": "app",
|
||||
"sourceRoot": "apps/angular/dialog-alert-form/src",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@angular-devkit/build-angular:application",
|
||||
"outputs": ["{options.outputPath}"],
|
||||
"options": {
|
||||
"outputPath": "dist/apps/angular/dialog-alert-form",
|
||||
"index": "apps/angular/dialog-alert-form/src/index.html",
|
||||
"browser": "apps/angular/dialog-alert-form/src/main.ts",
|
||||
"polyfills": ["zone.js"],
|
||||
"tsConfig": "apps/angular/dialog-alert-form/tsconfig.app.json",
|
||||
"inlineStyleLanguage": "scss",
|
||||
"assets": [
|
||||
"apps/angular/dialog-alert-form/src/favicon.ico",
|
||||
"apps/angular/dialog-alert-form/src/assets"
|
||||
],
|
||||
"styles": ["apps/angular/dialog-alert-form/src/styles.scss"],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "500kb",
|
||||
"maximumError": "1mb"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "2kb",
|
||||
"maximumError": "4kb"
|
||||
}
|
||||
],
|
||||
"outputHashing": "all"
|
||||
},
|
||||
"development": {
|
||||
"optimization": false,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"serve": {
|
||||
"executor": "@angular-devkit/build-angular:dev-server",
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "angular-dialog-alert-form:build:production"
|
||||
},
|
||||
"development": {
|
||||
"buildTarget": "angular-dialog-alert-form:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"executor": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"buildTarget": "angular-dialog-alert-form:build"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint"
|
||||
}
|
||||
}
|
||||
}
|
||||
20
apps/angular/dialog-alert-form/src/app/app.component.ts
Normal file
20
apps/angular/dialog-alert-form/src/app/app.component.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { RouterOutlet } from '@angular/router';
|
||||
import { NavComponent } from './ui/nav.component';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [RouterOutlet, NavComponent],
|
||||
selector: 'app-root',
|
||||
template: `
|
||||
<div class="h-screen bg-gray-50">
|
||||
<app-nav
|
||||
class="mx-auto flex w-full items-center justify-center pb-2 pt-8" />
|
||||
|
||||
<main class="px-4 py-16 sm:px-6 lg:px-8">
|
||||
<router-outlet></router-outlet>
|
||||
</main>
|
||||
</div>
|
||||
`,
|
||||
})
|
||||
export class AppComponent {}
|
||||
7
apps/angular/dialog-alert-form/src/app/app.config.ts
Normal file
7
apps/angular/dialog-alert-form/src/app/app.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { ApplicationConfig } from '@angular/core';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { appRoutes } from './app.routes';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [provideRouter(appRoutes)],
|
||||
};
|
||||
29
apps/angular/dialog-alert-form/src/app/app.routes.ts
Normal file
29
apps/angular/dialog-alert-form/src/app/app.routes.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Route } from '@angular/router';
|
||||
import { JoinComponent } from './pages/join.component';
|
||||
import { PageComponent } from './pages/page.component';
|
||||
|
||||
export const appRoutes: Route[] = [
|
||||
{
|
||||
path: '',
|
||||
pathMatch: 'full',
|
||||
redirectTo: 'form',
|
||||
},
|
||||
{
|
||||
path: 'form',
|
||||
loadComponent: () => JoinComponent,
|
||||
},
|
||||
{
|
||||
path: 'page-1',
|
||||
data: {
|
||||
title: 'Page 1',
|
||||
},
|
||||
loadComponent: () => PageComponent,
|
||||
},
|
||||
{
|
||||
path: 'page-2',
|
||||
data: {
|
||||
title: 'Page 2',
|
||||
},
|
||||
loadComponent: () => PageComponent,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,16 @@
|
||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
import { FormComponent } from '../ui/form.component';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [FormComponent],
|
||||
template: `
|
||||
<section class="mx-auto max-w-screen-sm">
|
||||
<div class="rounded-lg bg-white p-8 shadow-lg lg:p-12">
|
||||
<app-form />
|
||||
</div>
|
||||
</section>
|
||||
`,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class JoinComponent {}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { map } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
template: `
|
||||
<section>
|
||||
<h1>{{ title() }}</h1>
|
||||
</section>
|
||||
`,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class PageComponent {
|
||||
title = toSignal(inject(ActivatedRoute).data.pipe(map((d) => d['title'])));
|
||||
}
|
||||
62
apps/angular/dialog-alert-form/src/app/ui/form.component.ts
Normal file
62
apps/angular/dialog-alert-form/src/app/ui/form.component.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-form',
|
||||
standalone: true,
|
||||
template: `
|
||||
<form class="space-y-4">
|
||||
<div>
|
||||
<label class="sr-only" for="name">Name</label>
|
||||
<input
|
||||
class="w-full rounded-lg border-gray-200 p-3 text-sm"
|
||||
placeholder="Name"
|
||||
type="text"
|
||||
name="name"
|
||||
id="name" />
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<label class="sr-only" for="email">Email</label>
|
||||
<input
|
||||
class="w-full rounded-lg border-gray-200 p-3 text-sm"
|
||||
placeholder="Email address"
|
||||
type="email"
|
||||
name="email"
|
||||
id="email" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="sr-only" for="phone">Phone</label>
|
||||
<input
|
||||
class="w-full rounded-lg border-gray-200 p-3 text-sm"
|
||||
placeholder="Phone Number"
|
||||
type="tel"
|
||||
name="phone"
|
||||
id="phone" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="sr-only" for="message">Message</label>
|
||||
|
||||
<textarea
|
||||
class="w-full rounded-lg border-gray-200 p-3 text-sm"
|
||||
placeholder="Message"
|
||||
rows="8"
|
||||
name="message"
|
||||
id="message"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<button
|
||||
type="submit"
|
||||
class="inline-block w-full rounded-lg border bg-gray-50 px-5 py-3 font-medium text-gray-900 sm:w-auto">
|
||||
Submit
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
`,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class FormComponent {}
|
||||
33
apps/angular/dialog-alert-form/src/app/ui/nav.component.ts
Normal file
33
apps/angular/dialog-alert-form/src/app/ui/nav.component.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
import { RouterLink, RouterLinkActive } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-nav',
|
||||
standalone: true,
|
||||
imports: [RouterLink, RouterLinkActive],
|
||||
template: `
|
||||
<nav
|
||||
class="inline-flex -space-x-px overflow-hidden rounded-md border bg-white shadow-sm">
|
||||
<a
|
||||
routerLink="/form"
|
||||
routerLinkActive="bg-gray-900 text-gray-50 hover:bg-none"
|
||||
class="inline-block px-4 py-2 text-sm font-medium text-gray-700 focus:relative">
|
||||
Form
|
||||
</a>
|
||||
<a
|
||||
routerLink="/page-1"
|
||||
routerLinkActive="bg-gray-900 text-gray-50 hover:bg-none"
|
||||
class="inline-block px-4 py-2 text-sm font-medium text-gray-700 focus:relative">
|
||||
Page 1
|
||||
</a>
|
||||
<a
|
||||
routerLink="/page-2"
|
||||
routerLinkActive="bg-gray-900 text-gray-50 hover:bg-none"
|
||||
class="inline-block px-4 py-2 text-sm font-medium text-gray-700 focus:relative">
|
||||
Page 2
|
||||
</a>
|
||||
</nav>
|
||||
`,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class NavComponent {}
|
||||
0
apps/angular/dialog-alert-form/src/assets/.gitkeep
Normal file
0
apps/angular/dialog-alert-form/src/assets/.gitkeep
Normal file
BIN
apps/angular/dialog-alert-form/src/favicon.ico
Normal file
BIN
apps/angular/dialog-alert-form/src/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
13
apps/angular/dialog-alert-form/src/index.html
Normal file
13
apps/angular/dialog-alert-form/src/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>angular-dialog-alert-form</title>
|
||||
<base href="/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
||||
7
apps/angular/dialog-alert-form/src/main.ts
Normal file
7
apps/angular/dialog-alert-form/src/main.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { AppComponent } from './app/app.component';
|
||||
import { appConfig } from './app/app.config';
|
||||
|
||||
bootstrapApplication(AppComponent, appConfig).catch((err) =>
|
||||
console.error(err),
|
||||
);
|
||||
5
apps/angular/dialog-alert-form/src/styles.scss
Normal file
5
apps/angular/dialog-alert-form/src/styles.scss
Normal file
@@ -0,0 +1,5 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
16
apps/angular/dialog-alert-form/tailwind.config.js
Normal file
16
apps/angular/dialog-alert-form/tailwind.config.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const { createGlobPatternsForDependencies } = require('@nx/angular/tailwind');
|
||||
const { join } = require('path');
|
||||
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
content: [
|
||||
join(__dirname, 'src/**/!(*.stories|*.spec).{ts,html}'),
|
||||
...createGlobPatternsForDependencies(__dirname),
|
||||
],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [
|
||||
require('@tailwindcss/forms'),
|
||||
],
|
||||
};
|
||||
10
apps/angular/dialog-alert-form/tsconfig.app.json
Normal file
10
apps/angular/dialog-alert-form/tsconfig.app.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../../dist/out-tsc",
|
||||
"types": []
|
||||
},
|
||||
"files": ["src/main.ts"],
|
||||
"include": ["src/**/*.d.ts"],
|
||||
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
|
||||
}
|
||||
6
apps/angular/dialog-alert-form/tsconfig.editor.json
Normal file
6
apps/angular/dialog-alert-form/tsconfig.editor.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["src/**/*.ts"],
|
||||
"compilerOptions": {},
|
||||
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
|
||||
}
|
||||
30
apps/angular/dialog-alert-form/tsconfig.json
Normal file
30
apps/angular/dialog-alert-form/tsconfig.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"useDefineForClassFields": false,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.editor.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.app.json"
|
||||
}
|
||||
],
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user