1
- import { Component , HostBinding , Input } from '@angular/core' ;
1
+ import { Component , computed , input , InputSignal } from '@angular/core' ;
2
2
import { NgClass } from '@angular/common' ;
3
3
4
4
import { Positions } from '../../coreui.types' ;
@@ -9,42 +9,42 @@ type Container = boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'fluid';
9
9
selector : 'c-header, [c-header]' ,
10
10
templateUrl : './header.component.html' ,
11
11
standalone : true ,
12
- imports : [ NgClass ]
12
+ imports : [ NgClass ] ,
13
+ host : { '[attr.role]' : 'role()' , '[class]' : 'hostClasses()' }
13
14
} )
14
15
export class HeaderComponent {
15
16
/**
16
17
* Defines optional container wrapping children elements.
17
18
*/
18
- @ Input ( ) container ?: Container ;
19
+ readonly container = input < Container > ( ) ;
19
20
/**
20
21
* Place header in non-static positions.
21
22
*/
22
- @ Input ( ) position ?: Positions ;
23
+ readonly position = input < Positions > ( ) ;
23
24
/**
24
25
* Default role for header. [docs]
25
26
* @type string
26
27
* @default 'banner'
27
28
*/
28
- @HostBinding ( 'attr.role' )
29
- @Input ( )
30
- role = 'banner' ;
29
+ readonly role : InputSignal < string > = input ( 'banner' ) ;
31
30
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
+ } ) ;
36
34
37
- get headerClasses ( ) : any {
35
+ readonly headerClasses = computed ( ( ) => {
36
+ const position = this . position ( ) ;
38
37
return {
39
38
header : true ,
40
- [ `header-${ this . position } ` ] : ! ! this . position
41
- } ;
42
- }
39
+ [ `header-${ position } ` ] : ! ! position
40
+ } as Record < string , boolean > ;
41
+ } ) ;
43
42
44
- get containerClasses ( ) : any {
43
+ readonly containerClasses = computed ( ( ) => {
44
+ const container = this . container ( ) ;
45
45
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
+ } ) ;
50
50
}
0 commit comments