From a7b6e511992bff52b42f2563ef3bf1de5675029b Mon Sep 17 00:00:00 2001 From: splincode Date: Mon, 4 Dec 2023 11:04:46 +0300 Subject: [PATCH] chore: update --- apps/demo/project.json | 2 +- apps/demo/src/app/app.component.html | 157 +----------------- apps/demo/src/app/app.component.ts | 92 +--------- apps/demo/src/app/app.config.ts | 6 + apps/demo/src/app/app.routes.ts | 10 ++ apps/demo/src/app/home/home.component.html | 156 +++++++++++++++++ .../home.component.less} | 0 apps/demo/src/app/home/home.component.ts | 92 ++++++++++ 8 files changed, 271 insertions(+), 244 deletions(-) create mode 100644 apps/demo/src/app/app.routes.ts create mode 100644 apps/demo/src/app/home/home.component.html rename apps/demo/src/app/{app.component.less => home/home.component.less} (100%) create mode 100644 apps/demo/src/app/home/home.component.ts diff --git a/apps/demo/project.json b/apps/demo/project.json index b56a7f69..a5406a51 100644 --- a/apps/demo/project.json +++ b/apps/demo/project.json @@ -26,7 +26,7 @@ "scripts": [], "server": "apps/demo/src/main.server.ts", "prerender": { - "discoverRoutes": false, + "discoverRoutes": true, "routesFile": "apps/demo/src/routes.txt" }, "ssr": { diff --git a/apps/demo/src/app/app.component.html b/apps/demo/src/app/app.component.html index 4a369846..c0862f40 100644 --- a/apps/demo/src/app/app.component.html +++ b/apps/demo/src/app/app.component.html @@ -1,160 +1,5 @@ -

- Dozens of -
- components -

- - - - - - -
-
- - Choose date - - -
-
- - {{ label }} - -
-
- - -
- - - -
-
-
- - -
-
- author -

Aleksandr Inkin

-
- -
- - -
-
-
- - - - I have a bad feeling about this... - - - + diff --git a/apps/demo/src/app/app.component.ts b/apps/demo/src/app/app.component.ts index 9fb908bf..a20ba18d 100644 --- a/apps/demo/src/app/app.component.ts +++ b/apps/demo/src/app/app.component.ts @@ -1,95 +1,13 @@ -import {NgForOf} from '@angular/common'; -import { - ChangeDetectionStrategy, - ChangeDetectorRef, - Component, - inject, - SecurityContext, - TemplateRef, - ViewEncapsulation, -} from '@angular/core'; -import {FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {TuiDay} from '@taiga-ui/cdk'; -import { - TuiButtonModule, - TuiCalendarModule, - TuiDialogService, - TuiDropdownModule, - TuiHintModule, - TuiLinkModule, - TuiRootModule, - TuiSvgModule, - TuiTextfieldControllerModule, -} from '@taiga-ui/core'; -import { - TuiCheckboxLabeledModule, - TuiInputDateModule, - TuiInputTagModule, - TuiPushModule, - TuiSliderModule, - TuiToggleModule, -} from '@taiga-ui/kit'; -import {NgDompurifyModule, NgDompurifySanitizer} from '@tinkoff/ng-dompurify'; +import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core'; +import {RouterOutlet} from '@angular/router'; +import {TuiRootModule} from '@taiga-ui/core'; @Component({ standalone: true, selector: 'app', - imports: [ - TuiRootModule, - NgForOf, - ReactiveFormsModule, - FormsModule, - TuiInputTagModule, - TuiToggleModule, - TuiCalendarModule, - TuiTextfieldControllerModule, - TuiInputDateModule, - TuiCheckboxLabeledModule, - TuiButtonModule, - TuiHintModule, - TuiSliderModule, - TuiSvgModule, - TuiPushModule, - TuiLinkModule, - TuiDropdownModule, - NgDompurifyModule, - ], + imports: [TuiRootModule, RouterOutlet], templateUrl: './app.component.html', - styleUrls: ['./app.component.less'], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, }) -export class AppComponent { - private readonly dompurifySanitizer = inject(NgDompurifySanitizer); - private readonly dialogs = inject(TuiDialogService); - private readonly cd = inject(ChangeDetectorRef); - - readonly labels = ['New', 'Read', 'Archived', 'Junk']; - tags = ['Angular', 'Open source']; - date: TuiDay | null = null; - notification = false; - slider = 80; - - onDay(date: TuiDay): void { - this.date = date; - } - - call(content: TemplateRef): void { - this.dialogs - .open(content, { - appearance: 'call', - closeable: false, - dismissible: false, - }) - .subscribe(); - } - - toggle(open: boolean): void { - this.notification = open; - this.cd.detectChanges(); - } - - purify(value: string): string { - return this.dompurifySanitizer.sanitize(SecurityContext.HTML, value); - } -} +export class AppComponent {} diff --git a/apps/demo/src/app/app.config.ts b/apps/demo/src/app/app.config.ts index cafcb914..417f3206 100644 --- a/apps/demo/src/app/app.config.ts +++ b/apps/demo/src/app/app.config.ts @@ -1,12 +1,18 @@ import {ApplicationConfig, importProvidersFrom, Sanitizer} from '@angular/core'; +import {provideClientHydration} from '@angular/platform-browser'; import {provideAnimations} from '@angular/platform-browser/animations'; +import {provideRouter} from '@angular/router'; import {TuiDialogModule, TuiRootModule} from '@taiga-ui/core'; import {TuiPushModule} from '@taiga-ui/kit'; import {NgDompurifySanitizer} from '@tinkoff/ng-dompurify'; +import {routes} from './app.routes'; + export const appConfig: ApplicationConfig = { providers: [ provideAnimations(), + provideRouter(routes), + provideClientHydration(), importProvidersFrom(TuiRootModule, TuiDialogModule, TuiPushModule), { provide: Sanitizer, diff --git a/apps/demo/src/app/app.routes.ts b/apps/demo/src/app/app.routes.ts new file mode 100644 index 00000000..242524b2 --- /dev/null +++ b/apps/demo/src/app/app.routes.ts @@ -0,0 +1,10 @@ +import {Routes} from '@angular/router'; + +export const routes: Routes = [ + { + path: ``, + pathMatch: `full`, + loadComponent: async (): Promise => + import(`./home/home.component`).then(module => module.HomeComponent), + }, +]; diff --git a/apps/demo/src/app/home/home.component.html b/apps/demo/src/app/home/home.component.html new file mode 100644 index 00000000..1165f04d --- /dev/null +++ b/apps/demo/src/app/home/home.component.html @@ -0,0 +1,156 @@ +

+ Dozens of +
+ components +

+ + + + + + +
+
+ + Choose date + + +
+
+ + {{ label }} + +
+
+ + +
+ + + +
+
+
+ + +
+
+ author +

Aleksandr Inkin

+
+ +
+ + +
+
+
+ + + + I have a bad feeling about this... + + + diff --git a/apps/demo/src/app/app.component.less b/apps/demo/src/app/home/home.component.less similarity index 100% rename from apps/demo/src/app/app.component.less rename to apps/demo/src/app/home/home.component.less diff --git a/apps/demo/src/app/home/home.component.ts b/apps/demo/src/app/home/home.component.ts new file mode 100644 index 00000000..203c4e29 --- /dev/null +++ b/apps/demo/src/app/home/home.component.ts @@ -0,0 +1,92 @@ +import {CommonModule} from '@angular/common'; +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + inject, + SecurityContext, + TemplateRef, + ViewEncapsulation, +} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {TuiDay} from '@taiga-ui/cdk'; +import { + TuiButtonModule, + TuiCalendarModule, + TuiDialogService, + TuiDropdownModule, + TuiHintModule, + TuiLinkModule, + TuiSvgModule, + TuiTextfieldControllerModule, +} from '@taiga-ui/core'; +import { + TuiCheckboxLabeledModule, + TuiInputDateModule, + TuiInputTagModule, + TuiPushModule, + TuiSliderModule, + TuiToggleModule, +} from '@taiga-ui/kit'; +import {NgDompurifyModule, NgDompurifySanitizer} from '@tinkoff/ng-dompurify'; + +@Component({ + standalone: true, + selector: 'home', + imports: [ + CommonModule, + FormsModule, + TuiInputTagModule, + TuiToggleModule, + TuiCalendarModule, + TuiTextfieldControllerModule, + TuiInputDateModule, + TuiCheckboxLabeledModule, + TuiButtonModule, + TuiHintModule, + TuiSliderModule, + TuiSvgModule, + TuiPushModule, + TuiLinkModule, + TuiDropdownModule, + NgDompurifyModule, + ], + templateUrl: './home.component.html', + styleUrls: ['./home.component.less'], + encapsulation: ViewEncapsulation.None, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class HomeComponent { + private readonly dompurifySanitizer = inject(NgDompurifySanitizer); + private readonly dialogs = inject(TuiDialogService); + private readonly cd = inject(ChangeDetectorRef); + + readonly labels = ['New', 'Read', 'Archived', 'Junk']; + tags = ['Angular', 'Open source']; + date: TuiDay | null = null; + notification = false; + slider = 80; + + onDay(date: TuiDay): void { + this.date = date; + } + + call(content: TemplateRef): void { + this.dialogs + .open(content, { + appearance: 'call', + closeable: false, + dismissible: false, + }) + .subscribe(); + } + + toggle(open: boolean): void { + this.notification = open; + this.cd.detectChanges(); + } + + purify(value: string): string { + return this.dompurifySanitizer.sanitize(SecurityContext.HTML, value); + } +}