diff --git a/apps/router-testing/src/app/app.component.ts b/apps/router-testing/src/app/app.component.ts index f863360..3b420a8 100644 --- a/apps/router-testing/src/app/app.component.ts +++ b/apps/router-testing/src/app/app.component.ts @@ -1,10 +1,42 @@ import { Component } from '@angular/core'; -import { RouterOutlet } from '@angular/router'; +import { RouterLink, RouterOutlet } from '@angular/router'; @Component({ standalone: true, - imports: [RouterOutlet], + imports: [RouterOutlet, RouterLink], selector: 'app-root', - template: ` `, + styles: [ + ` + h1 { + margin-bottom: 0; + } + nav a { + padding: 1rem; + text-decoration: none; + margin-top: 10px; + display: inline-block; + background-color: #e8e8e8; + color: #3d3d3d; + border-radius: 4px; + margin-bottom: 10px; + } + nav a:hover { + color: white; + background-color: #42545c; + } + nav a.active { + background-color: black; + } + `, + ], + template: ` +

Library

+ + + + + `, }) export class AppComponent {} diff --git a/apps/router-testing/src/app/app.routes.ts b/apps/router-testing/src/app/app.routes.ts index 91cbd91..e4e15aa 100644 --- a/apps/router-testing/src/app/app.routes.ts +++ b/apps/router-testing/src/app/app.routes.ts @@ -3,7 +3,7 @@ import { bookGuard } from './book.guard'; export const appRoutes: Route[] = [ { - path: '', + path: 'search', loadComponent: () => import('./search.component'), }, { diff --git a/apps/router-testing/src/app/no-book-search.component.ts b/apps/router-testing/src/app/no-book-search.component.ts index 6485f79..ed41f51 100644 --- a/apps/router-testing/src/app/no-book-search.component.ts +++ b/apps/router-testing/src/app/no-book-search.component.ts @@ -1,13 +1,8 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; -import { RouterLink } from '@angular/router'; @Component({ standalone: true, - imports: [RouterLink], - template: ` -
No book found for this search
- - `, + template: `
No book found for this search
`, changeDetection: ChangeDetectionStrategy.OnPush, }) export default class ShelfComponent {} diff --git a/apps/router-testing/src/app/search.component.ts b/apps/router-testing/src/app/search.component.ts index b4fdc2a..0aa7bc5 100644 --- a/apps/router-testing/src/app/search.component.ts +++ b/apps/router-testing/src/app/search.component.ts @@ -7,28 +7,55 @@ import { availableBooks } from './book.model'; @Component({ standalone: true, imports: [ReactiveFormsModule, RouterLink, NgFor, NgIf], + styles: [ + ` + :host { + display: flex; + flex-direction: column; + gap: 10px; + } + + .error { + color: red; + } + + button { + width: 300px; + padding: 5px; + border-radius: 5px; + } + + .search label { + margin-right: 15px; + } + `, + ], template: ` -
- + -
Search criteria is required!
-
List of books available:
-
    -
  • {{ book.name }} by {{ book.author }}
  • -
+
+

List of books available:

+
    +
  • {{ book.name }} by {{ book.author }}
  • +
+
`, changeDetection: ChangeDetectionStrategy.OnPush, }) diff --git a/apps/router-testing/src/app/shelf.component.ts b/apps/router-testing/src/app/shelf.component.ts index da1d2a4..bb4fd5d 100644 --- a/apps/router-testing/src/app/shelf.component.ts +++ b/apps/router-testing/src/app/shelf.component.ts @@ -1,20 +1,19 @@ import { AsyncPipe, JsonPipe, NgFor } from '@angular/common'; import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; -import { ActivatedRoute, RouterLink } from '@angular/router'; +import { ActivatedRoute } from '@angular/router'; import { map } from 'rxjs'; import { availableBooks } from './book.model'; @Component({ selector: 'app-shelf', standalone: true, - imports: [AsyncPipe, JsonPipe, RouterLink, NgFor], + imports: [AsyncPipe, JsonPipe, NgFor], template: `
  • - Book: {{ book.name }} by {{ book.author }} + Borrowed Book: {{ book.name }} by {{ book.author }}
- `, styles: [], changeDetection: ChangeDetectionStrategy.OnPush, diff --git a/package-lock.json b/package-lock.json index d9c60a2..b910ac1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,6 +85,7 @@ "postcss-preset-env": "~7.5.0", "postcss-url": "~10.1.3", "prettier": "^2.6.2", + "testing-library-selector": "^0.2.1", "ts-jest": "29.0.5", "ts-node": "10.9.1", "typescript": "4.9.5" @@ -27893,6 +27894,18 @@ "node": "*" } }, + "node_modules/testing-library-selector": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/testing-library-selector/-/testing-library-selector-0.2.1.tgz", + "integrity": "sha512-cTC9X3w3KAz04Q23vKN9FQdnBeB06C1Cr1tEmy10KNyx1BiVyoYz5i3iojmSGbPPndSPhiUauQWn3tDvrrBMeQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@testing-library/dom": "^8.2.0" + } + }, "node_modules/text-extensions": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.9.0.tgz", diff --git a/package.json b/package.json index fa5f099..09220bc 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,7 @@ "postcss-preset-env": "~7.5.0", "postcss-url": "~10.1.3", "prettier": "^2.6.2", + "testing-library-selector": "^0.2.1", "ts-jest": "29.0.5", "ts-node": "10.9.1", "typescript": "4.9.5"