Skip to content

Commit 5d76257

Browse files
committed
refactor(text-color): input signals
1 parent 19179d7 commit 5d76257

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import { TestBed } from '@angular/core/testing';
12
import { TextColorDirective } from './text-color.directive';
23

34
describe('TextColorDirective', () => {
45
it('should create an instance', () => {
5-
const directive = new TextColorDirective();
6-
expect(directive).toBeTruthy();
6+
TestBed.runInInjectionContext(() => {
7+
const directive = new TextColorDirective();
8+
expect(directive).toBeTruthy();
9+
});
710
});
811
});
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
import { Directive, HostBinding, Input } from '@angular/core';
1+
import { Directive, HostBinding, input, InputSignal } from '@angular/core';
22
import { TextColors } from '../coreui.types';
33

44
@Directive({
55
selector: '[cTextColor]',
66
standalone: true
77
})
88
export class TextColorDirective {
9-
109
/**
1110
* Set text-color of element
1211
* @type TextColors
1312
*/
14-
@Input('cTextColor') color: TextColors = '';
13+
readonly color: InputSignal<TextColors> = input('', { alias: 'cTextColor' });
1514

1615
@HostBinding('class')
1716
get hostClasses(): any {
18-
const color = this.color;
17+
const color = this.color();
1918
return {
2019
[`text-${color}`]: !!color
2120
};
2221
}
23-
2422
}

0 commit comments

Comments
 (0)