From 0090c073a7260c4685f58acb5b74811e6444e919 Mon Sep 17 00:00:00 2001 From: David LJ Date: Wed, 27 Nov 2024 12:30:51 +0100 Subject: [PATCH] refactor: migrate to signal-based inputs & queries + output fns (#865) * refactor: migrate to signal-based inputs & queries + output fns * refactor: revert not-so-easy-to-migrate components * test: fix unit tests with mocked components or missing inputs * chore: use the navigation tabs makeSut arg around --- .../common/simple-icon/simple-icon.component.ts | 2 ++ src/app/common/test-id.directive.ts | 6 +++--- .../navigation-tabs.component.html | 2 +- .../navigation-tabs.component.spec.ts | 16 ++++++++-------- .../navigation-tabs/navigation-tabs.component.ts | 4 ++-- src/app/header/tab/tab.component.spec.ts | 4 ++-- src/app/header/tabs/tabs.component.ts | 2 ++ .../toolbar-button/toolbar-button.component.html | 2 +- .../toolbar-button.component.spec.ts | 2 +- .../toolbar-button/toolbar-button.component.ts | 5 +++-- .../attribute/attribute.component.html | 2 +- .../attribute/attribute.component.spec.ts | 2 +- .../resume-page/attribute/attribute.component.ts | 4 ++-- .../card-header-image.component.html | 2 +- .../card-header-image.component.spec.ts | 5 ++--- .../card-header-image.component.ts | 6 +++--- src/app/resume-page/chip/chip.component.spec.ts | 10 +++++----- src/app/resume-page/chip/chip.component.ts | 9 ++++----- .../chipped-content.component.spec.ts | 10 +++++----- .../date-range/date-range.component.html | 6 +++--- .../date-range/date-range.component.spec.ts | 2 +- .../date-range/date-range.component.ts | 4 ++-- .../education-item/education-item.component.ts | 2 ++ .../experience-item/experience-item.component.ts | 2 ++ .../language-item/language-item.component.html | 10 +++++----- .../language-item.component.spec.ts | 2 +- .../language-item/language-item.component.ts | 4 ++-- .../language-tag/language-tag.component.ts | 2 ++ src/app/resume-page/link/link.component.html | 4 ++-- src/app/resume-page/link/link.component.spec.ts | 5 +++-- src/app/resume-page/link/link.component.ts | 4 ++-- .../project-item/project-item.component.ts | 2 ++ .../technology/technology.component.ts | 2 ++ 33 files changed, 80 insertions(+), 66 deletions(-) diff --git a/src/app/common/simple-icon/simple-icon.component.ts b/src/app/common/simple-icon/simple-icon.component.ts index 63eba2c8..012f3a29 100644 --- a/src/app/common/simple-icon/simple-icon.component.ts +++ b/src/app/common/simple-icon/simple-icon.component.ts @@ -24,6 +24,8 @@ export class SimpleIconComponent { protected _fillColor?: string + // TODO: Skipped for migration because: + // Accessor inputs cannot be migrated as they are too complex. @Input({ required: true }) set icon(icon: SimpleIcon) { this.loader(icon.slug) .pipe( diff --git a/src/app/common/test-id.directive.ts b/src/app/common/test-id.directive.ts index 1f258c72..e5109f67 100644 --- a/src/app/common/test-id.directive.ts +++ b/src/app/common/test-id.directive.ts @@ -1,17 +1,17 @@ -import { Directive, ElementRef, Input, OnChanges } from '@angular/core' +import { Directive, ElementRef, OnChanges, input } from '@angular/core' @Directive({ selector: '[appTestId]', standalone: true, }) export class TestIdDirective implements OnChanges { - @Input() public appTestId!: string + public readonly appTestId = input.required() constructor(private el: ElementRef) {} ngOnChanges(): void { if (isDevMode) { - this.el.nativeElement.setAttribute(TEST_ID_ATTRIBUTE, this.appTestId) + this.el.nativeElement.setAttribute(TEST_ID_ATTRIBUTE, this.appTestId()) } } } diff --git a/src/app/header/navigation-tabs/navigation-tabs.component.html b/src/app/header/navigation-tabs/navigation-tabs.component.html index 96913f44..b8a4ccb3 100644 --- a/src/app/header/navigation-tabs/navigation-tabs.component.html +++ b/src/app/header/navigation-tabs/navigation-tabs.component.html @@ -1,6 +1,6 @@