Skip to content

Commit 45c2f74

Browse files
committed
refactor(widget-stat-b): input signals
1 parent 5d76257 commit 45c2f74

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<c-card-body>
2-
@if (!!value) {
3-
<div class="fs-4 fw-semibold">{{ value }}</div>
2+
@if (!!value()) {
3+
<div class="fs-4 fw-semibold">{{ value() }}</div>
44
}
5-
@if (!!title) {
6-
<div>{{ title }}</div>
5+
@if (!!title()) {
6+
<div>{{ title() }}</div>
77
}
88
<ng-content />
9-
@if (text) {
10-
<small [ngClass]="inverse ? 'text-white text-opacity-75' : 'text-body-secondary'">
11-
{{ text }}
9+
@if (text()) {
10+
<small [ngClass]="inverse() ? 'text-white text-opacity-75' : 'text-body-secondary'">
11+
{{ text() }}
1212
</small>
1313
}
1414
</c-card-body>
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { booleanAttribute, Component, HostBinding, Input } from '@angular/core';
1+
import { booleanAttribute, Component, HostBinding, input, InputSignal, InputSignalWithTransform } from '@angular/core';
22
import { NgClass } from '@angular/common';
33

4-
import { Colors, TextColors } from '../../coreui.types';
54
import { CardBodyComponent, CardComponent } from '../../card';
65

76
@Component({
@@ -12,51 +11,54 @@ import { CardBodyComponent, CardComponent } from '../../card';
1211
imports: [CardBodyComponent, NgClass]
1312
})
1413
export class WidgetStatBComponent extends CardComponent {
15-
1614
constructor() {
1715
super();
1816
}
1917

2018
/**
21-
* Sets the color context of the component to one of CoreUI’s themed colors.
19+
* Sets the color context of the component to one of CoreUI themed colors.
2220
* @type Colors
2321
*/
24-
@Input() override color?: Colors;
22+
// override readonly color: InputSignal<Colors | undefined> = input();
23+
2524
/**
26-
* Sets the text-color context of the component to one of CoreUI’s themed colors.
27-
* @type Colors
25+
* Sets the text-color context of the component to one of CoreUI themed colors.
26+
* via TextColorDirective
27+
* @type TextColors
2828
*/
29-
@Input() override textColor?: TextColors;
29+
// override readonly textColor: InputSignal<TextColors | undefined> = input();
30+
3031
/**
3132
* Title of the widget to display
3233
* @type string
3334
*/
34-
@Input() title?: string;
35+
readonly title: InputSignal<string | undefined> = input();
36+
3537
/**
3638
* Helper text for your widget.
3739
* @type string
3840
*/
39-
@Input() text?: string;
41+
readonly text: InputSignal<string | undefined> = input();
42+
4043
/**
4144
* Value for your widget to display
4245
* @type string
4346
*/
44-
@Input() value?: string;
47+
readonly value: InputSignal<string | undefined> = input();
4548

4649
/**
4750
* Invert colors from their default dark shade.
4851
* @type boolean
4952
*/
50-
@Input({ transform: booleanAttribute }) inverse: string | boolean = false;
53+
readonly inverse: InputSignalWithTransform<boolean, unknown> = input(false, { transform: booleanAttribute });
5154

5255
@HostBinding('class')
5356
override get hostClasses() {
5457
return {
55-
'card': true,
56-
[`bg-${this.color}`]: !!this.color,
57-
[`text-${this.textColor}`]: !!this.textColor,
58-
'text-white': !!this.inverse
58+
card: true,
59+
[`bg-${this.color()}`]: !!this.color(),
60+
[`text-${this.textColor()}`]: !!this.textColor(),
61+
'text-white': this.inverse()
5962
};
6063
}
61-
6264
}

0 commit comments

Comments
 (0)