feat(challenge33): add new challenge about decoupling

This commit is contained in:
thomas
2023-09-01 15:37:32 +02:00
parent e434137a1a
commit 5f84762e41
55 changed files with 1030 additions and 4 deletions

View File

@@ -0,0 +1,4 @@
export {
BtnDisabledDirective,
ButtonState,
} from './lib/button-disabled.directive';

View File

@@ -0,0 +1,20 @@
/* eslint-disable @angular-eslint/directive-selector */
/* eslint-disable @angular-eslint/no-host-metadata-property */
import { Directive, WritableSignal, signal } from '@angular/core';
export type ButtonState = 'enabled' | 'disabled';
@Directive({
selector: 'button[btnDisabled]',
standalone: true,
host: {
'(click)': 'toggleState()',
},
})
export class BtnDisabledDirective {
state: WritableSignal<ButtonState> = signal('enabled');
toggleState() {
this.state.set(this.state() === 'enabled' ? 'disabled' : 'enabled');
}
}

View File

@@ -0,0 +1,8 @@
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
globalThis.ngJest = {
testEnvironmentOptions: {
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
},
};
import 'jest-preset-angular/setup-jest';