Skip to content

Commit 19179d7

Browse files
committed
refactor(text-bg-color): input signals
1 parent 864c050 commit 19179d7

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
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 { TextBgColorDirective } from './text-bg-color.directive';
23

34
describe('TextBgColorDirective', () => {
45
it('should create an instance', () => {
5-
const directive = new TextBgColorDirective();
6-
expect(directive).toBeTruthy();
6+
TestBed.runInInjectionContext(() => {
7+
const directive = new TextBgColorDirective();
8+
expect(directive).toBeTruthy();
9+
});
710
});
811
});

projects/coreui-angular/src/lib/utilities/text-bg-color.directive.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
import { Directive, HostBinding, Input } from '@angular/core';
1+
import { Directive, HostBinding, input, InputSignal } from '@angular/core';
22
import { Colors } from '../coreui.types';
33

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

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

0 commit comments

Comments
 (0)