Skip to content

Commit 23fe32b

Browse files
committed
refactor(callout): input signals, host bindings
1 parent a59b89a commit 23fe32b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import { Component, HostBinding, Input } from '@angular/core';
1+
import { Component, computed, input } from '@angular/core';
22
import { Colors } from '../coreui.types';
33

44
@Component({
55
selector: 'c-callout, [cCallout]',
66
template: '<ng-content />',
77
styleUrls: ['./callout.component.scss'],
88
standalone: true,
9-
host: { class: 'callout' }
9+
host: { class: 'callout', '[class]': 'hostClasses()' }
1010
})
1111
export class CalloutComponent {
1212
/**
1313
* Sets the color context of the component to one of CoreUI’s themed colors.
1414
* @type Colors
1515
*/
16-
@Input() color?: Colors;
16+
readonly color = input<Colors>();
1717

18-
@HostBinding('class')
19-
get hostClasses(): any {
18+
readonly hostClasses = computed(() => {
19+
const color = this.color();
2020
return {
2121
callout: true,
22-
[`callout-${this.color}`]: !!this.color
23-
};
24-
}
22+
[`callout-${color}`]: !!color
23+
} as Record<string, boolean>;
24+
});
2525
}

0 commit comments

Comments
 (0)