From fa8b14fed20d76cab95877f2cfe5758706c5538c Mon Sep 17 00:00:00 2001 From: Daniel Kimmich Date: Fri, 26 Jan 2024 18:42:08 +0100 Subject: [PATCH] docs: refactor docs app --- .gitignore | 1 + .../src/app/app-routing.module.ts | 25 ------- .../src/app/app.component.ts | 6 +- .../angular-intl-demo/src/app/app.routes.ts | 18 +++++ .../src/app/pipes/pipes-routing.module.ts | 68 ------------------- .../src/app/pipes/pipes.component.ts | 11 +-- .../src/app/pipes/pipes.module.ts | 45 ------------ .../src/app/pipes/pipes.routes.ts | 56 +++++++++++++++ projects/angular-intl-demo/src/main.ts | 23 ++----- 9 files changed, 87 insertions(+), 166 deletions(-) delete mode 100644 projects/angular-intl-demo/src/app/app-routing.module.ts create mode 100644 projects/angular-intl-demo/src/app/app.routes.ts delete mode 100644 projects/angular-intl-demo/src/app/pipes/pipes-routing.module.ts delete mode 100644 projects/angular-intl-demo/src/app/pipes/pipes.module.ts create mode 100644 projects/angular-intl-demo/src/app/pipes/pipes.routes.ts diff --git a/.gitignore b/.gitignore index 2cdda19f..b4953cdb 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ yarn-error.log /libpeerconnection.log testem.log /typings +/.nx # System files .DS_Store diff --git a/projects/angular-intl-demo/src/app/app-routing.module.ts b/projects/angular-intl-demo/src/app/app-routing.module.ts deleted file mode 100644 index 0b765a8c..00000000 --- a/projects/angular-intl-demo/src/app/app-routing.module.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { GettingStartedComponent } from './getting-started/getting-started.component'; - -const routes: Routes = [ - { - path: '', - component: GettingStartedComponent, - }, - { - path: 'pipes', - loadChildren: () => - import('./pipes/pipes.module').then((mod) => mod.PipesModule), - }, - { - path: '**', - redirectTo: '/', - }, -]; - -@NgModule({ - imports: [RouterModule.forRoot(routes, { useHash: true })], - exports: [RouterModule], -}) -export class AppRoutingModule {} diff --git a/projects/angular-intl-demo/src/app/app.component.ts b/projects/angular-intl-demo/src/app/app.component.ts index cb9e6098..f149d2c2 100644 --- a/projects/angular-intl-demo/src/app/app.component.ts +++ b/projects/angular-intl-demo/src/app/app.component.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core'; -import { MatButtonModule } from '@angular/material/button'; -import { MatToolbarModule } from '@angular/material/toolbar'; +import { MatButton } from '@angular/material/button'; +import { MatToolbar } from '@angular/material/toolbar'; import { RouterLink, RouterOutlet } from '@angular/router'; @Component({ @@ -8,6 +8,6 @@ import { RouterLink, RouterOutlet } from '@angular/router'; templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], standalone: true, - imports: [MatToolbarModule, MatButtonModule, RouterLink, RouterOutlet], + imports: [RouterLink, RouterOutlet, MatToolbar, MatButton], }) export class AppComponent {} diff --git a/projects/angular-intl-demo/src/app/app.routes.ts b/projects/angular-intl-demo/src/app/app.routes.ts new file mode 100644 index 00000000..2e3d31a5 --- /dev/null +++ b/projects/angular-intl-demo/src/app/app.routes.ts @@ -0,0 +1,18 @@ +import { Routes } from '@angular/router'; +import { GettingStartedComponent } from './getting-started/getting-started.component'; + +export const routes: Routes = [ + { + path: '', + component: GettingStartedComponent, + }, + { + path: 'pipes', + loadComponent: () => import('./pipes/pipes.component'), + loadChildren: () => import('./pipes/pipes.routes'), + }, + { + path: '**', + redirectTo: '/', + }, +]; diff --git a/projects/angular-intl-demo/src/app/pipes/pipes-routing.module.ts b/projects/angular-intl-demo/src/app/pipes/pipes-routing.module.ts deleted file mode 100644 index 84f696c8..00000000 --- a/projects/angular-intl-demo/src/app/pipes/pipes-routing.module.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { CountryComponent } from './country/country.component'; -import { CurrencyComponent } from './currency/currency.component'; -import { DateComponent } from './date/date.component'; -import { DecimalComponent } from './decimal/decimal.component'; -import { LanguageComponent } from './language/language.component'; -import { ListComponent } from './list/list.component'; -import { PercentComponent } from './percent/percent.component'; -import { PipesComponent } from './pipes.component'; -import { RelativeTimeComponent } from './relative-time/relative-time.component'; -import { UnitComponent } from './unit/unit.component'; - -const routes: Routes = [ - { - path: '', - component: PipesComponent, - children: [ - { - path: 'date', - component: DateComponent, - }, - { - path: 'decimal', - component: DecimalComponent, - }, - { - path: 'percent', - component: PercentComponent, - }, - { - path: 'currency', - component: CurrencyComponent, - }, - { - path: 'unit', - component: UnitComponent, - }, - { - path: 'language', - component: LanguageComponent, - }, - { - path: 'country', - component: CountryComponent, - }, - { - path: 'list', - component: ListComponent, - }, - { - path: 'relative-time', - component: RelativeTimeComponent, - }, - { - path: '', - redirectTo: 'date', - pathMatch: 'full', - }, - ], - }, -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule], -}) -export class PipesRoutingModule {} diff --git a/projects/angular-intl-demo/src/app/pipes/pipes.component.ts b/projects/angular-intl-demo/src/app/pipes/pipes.component.ts index 8c706af3..d1ee6d99 100644 --- a/projects/angular-intl-demo/src/app/pipes/pipes.component.ts +++ b/projects/angular-intl-demo/src/app/pipes/pipes.component.ts @@ -1,11 +1,6 @@ import { Component } from '@angular/core'; import { MatTabsModule } from '@angular/material/tabs'; -import { - ActivatedRoute, - RouterLink, - RouterLinkActive, - RouterOutlet, -} from '@angular/router'; +import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router'; @Component({ selector: 'app-pipes', @@ -14,6 +9,4 @@ import { standalone: true, imports: [MatTabsModule, RouterLink, RouterLinkActive, RouterOutlet], }) -export class PipesComponent { - constructor(readonly route: ActivatedRoute) {} -} +export default class PipesComponent {} diff --git a/projects/angular-intl-demo/src/app/pipes/pipes.module.ts b/projects/angular-intl-demo/src/app/pipes/pipes.module.ts deleted file mode 100644 index 0604c658..00000000 --- a/projects/angular-intl-demo/src/app/pipes/pipes.module.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { MatButtonModule } from '@angular/material/button'; -import { MatIconModule } from '@angular/material/icon'; -import { MatInputModule } from '@angular/material/input'; -import { MatSelectModule } from '@angular/material/select'; -import { MatTabsModule } from '@angular/material/tabs'; -import { IntlModule } from 'projects/angular-ecmascript-intl/src/lib/intl.module'; -import { CountryComponent } from './country/country.component'; -import { CurrencyComponent } from './currency/currency.component'; -import { DateComponent } from './date/date.component'; -import { DecimalComponent } from './decimal/decimal.component'; -import { LanguageComponent } from './language/language.component'; -import { ListComponent } from './list/list.component'; -import { PercentComponent } from './percent/percent.component'; -import { PipesRoutingModule } from './pipes-routing.module'; -import { PipesComponent } from './pipes.component'; -import { RelativeTimeComponent } from './relative-time/relative-time.component'; -import { UnitComponent } from './unit/unit.component'; - -@NgModule({ - imports: [ - CommonModule, - PipesRoutingModule, - MatTabsModule, - IntlModule, - MatSelectModule, - FormsModule, - MatInputModule, - MatButtonModule, - MatIconModule, - DateComponent, - LanguageComponent, - DecimalComponent, - PercentComponent, - CurrencyComponent, - PipesComponent, - CountryComponent, - UnitComponent, - ListComponent, - RelativeTimeComponent, - ], -}) -export class PipesModule {} diff --git a/projects/angular-intl-demo/src/app/pipes/pipes.routes.ts b/projects/angular-intl-demo/src/app/pipes/pipes.routes.ts new file mode 100644 index 00000000..aded520c --- /dev/null +++ b/projects/angular-intl-demo/src/app/pipes/pipes.routes.ts @@ -0,0 +1,56 @@ +import { Routes } from '@angular/router'; +import { CountryComponent } from './country/country.component'; +import { CurrencyComponent } from './currency/currency.component'; +import { DateComponent } from './date/date.component'; +import { DecimalComponent } from './decimal/decimal.component'; +import { LanguageComponent } from './language/language.component'; +import { ListComponent } from './list/list.component'; +import { PercentComponent } from './percent/percent.component'; +import { RelativeTimeComponent } from './relative-time/relative-time.component'; +import { UnitComponent } from './unit/unit.component'; + +const routes: Routes = [ + { + path: 'date', + component: DateComponent, + }, + { + path: 'decimal', + component: DecimalComponent, + }, + { + path: 'percent', + component: PercentComponent, + }, + { + path: 'currency', + component: CurrencyComponent, + }, + { + path: 'unit', + component: UnitComponent, + }, + { + path: 'language', + component: LanguageComponent, + }, + { + path: 'country', + component: CountryComponent, + }, + { + path: 'list', + component: ListComponent, + }, + { + path: 'relative-time', + component: RelativeTimeComponent, + }, + { + path: '', + redirectTo: 'date', + pathMatch: 'full', + }, +]; + +export default routes; diff --git a/projects/angular-intl-demo/src/main.ts b/projects/angular-intl-demo/src/main.ts index 286431e9..ccf42794 100644 --- a/projects/angular-intl-demo/src/main.ts +++ b/projects/angular-intl-demo/src/main.ts @@ -1,26 +1,16 @@ -import { - provideHttpClient, - withInterceptorsFromDi, -} from '@angular/common/http'; +import { provideHttpClient } from '@angular/common/http'; import { importProvidersFrom } from '@angular/core'; -import { MatButtonModule } from '@angular/material/button'; import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field'; -import { MatToolbarModule } from '@angular/material/toolbar'; -import { BrowserModule, bootstrapApplication } from '@angular/platform-browser'; +import { bootstrapApplication } from '@angular/platform-browser'; import { provideAnimations } from '@angular/platform-browser/animations'; +import { provideRouter } from '@angular/router'; import { MarkdownModule } from 'ngx-markdown'; -import { AppRoutingModule } from './app/app-routing.module'; import { AppComponent } from './app/app.component'; +import { routes } from './app/app.routes'; bootstrapApplication(AppComponent, { providers: [ - importProvidersFrom( - BrowserModule, - AppRoutingModule, - MarkdownModule.forRoot(), - MatToolbarModule, - MatButtonModule, - ), + importProvidersFrom(MarkdownModule.forRoot()), { provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { @@ -28,7 +18,8 @@ bootstrapApplication(AppComponent, { }, }, provideAnimations(), - provideHttpClient(withInterceptorsFromDi()), + provideHttpClient(), + provideRouter(routes), ], }).catch((err) => { console.error(err);