1- import { Component , HostBinding , Input } from '@angular/core' ;
1+ import { Component , computed , input , InputSignal } from '@angular/core' ;
22import { NgClass } from '@angular/common' ;
33
44import { Positions } from '../../coreui.types' ;
@@ -9,42 +9,42 @@ type Container = boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'fluid';
99 selector : 'c-header, [c-header]' ,
1010 templateUrl : './header.component.html' ,
1111 standalone : true ,
12- imports : [ NgClass ]
12+ imports : [ NgClass ] ,
13+ host : { '[attr.role]' : 'role()' , '[class]' : 'hostClasses()' }
1314} )
1415export class HeaderComponent {
1516 /**
1617 * Defines optional container wrapping children elements.
1718 */
18- @ Input ( ) container ?: Container ;
19+ readonly container = input < Container > ( ) ;
1920 /**
2021 * Place header in non-static positions.
2122 */
22- @ Input ( ) position ?: Positions ;
23+ readonly position = input < Positions > ( ) ;
2324 /**
2425 * Default role for header. [docs]
2526 * @type string
2627 * @default 'banner'
2728 */
28- @HostBinding ( 'attr.role' )
29- @Input ( )
30- role = 'banner' ;
29+ readonly role : InputSignal < string > = input ( 'banner' ) ;
3130
32- @HostBinding ( 'class' )
33- get getClasses ( ) : any {
34- return ! ! this . container ? this . containerClasses : this . headerClasses ;
35- }
31+ readonly hostClasses = computed ( ( ) => {
32+ return ! ! this . container ( ) ? this . containerClasses ( ) : this . headerClasses ( ) ;
33+ } ) ;
3634
37- get headerClasses ( ) : any {
35+ readonly headerClasses = computed ( ( ) => {
36+ const position = this . position ( ) ;
3837 return {
3938 header : true ,
40- [ `header-${ this . position } ` ] : ! ! this . position
41- } ;
42- }
39+ [ `header-${ position } ` ] : ! ! position
40+ } as Record < string , boolean > ;
41+ } ) ;
4342
44- get containerClasses ( ) : any {
43+ readonly containerClasses = computed ( ( ) => {
44+ const container = this . container ( ) ;
4545 return {
46- container : this . container === true ,
47- [ `container-${ this . container } ` ] : typeof this . container === 'string'
48- } ;
49- }
46+ container : container === true ,
47+ [ `container-${ container } ` ] : typeof container === 'string'
48+ } as Record < string , boolean > ;
49+ } ) ;
5050}
0 commit comments