Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8b336fe

Browse files
committedAug 27, 2024
refactor(footer): input signals, host bindings
1 parent 54be221 commit 8b336fe

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed
 
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
import { Component, HostBinding, Input } from '@angular/core';
1+
import { Component, computed, input, InputSignal } from '@angular/core';
22

33
import { Positions } from '../coreui.types';
44

55
@Component({
66
selector: 'c-footer, [cFooter]',
77
template: '<ng-content />',
88
standalone: true,
9-
host: { class: 'footer' }
9+
host: {
10+
class: 'footer',
11+
'[class]': 'hostClasses()',
12+
'[attr.role]': 'role()'
13+
}
1014
})
1115
export class FooterComponent {
1216
/**
1317
* Place footer in non-static positions. [docs]
1418
* @type Positions
1519
*/
16-
@Input() position?: Positions;
20+
readonly position: InputSignal<Positions | undefined> = input();
1721

1822
/**
1923
* Default role for footer. [docs]
2024
* @type string
2125
* @default 'contentinfo'
2226
*/
23-
@HostBinding('attr.role')
24-
@Input()
25-
role = 'contentinfo';
27+
readonly role: InputSignal<string> = input('contentinfo');
2628

27-
@HostBinding('class')
28-
get getClasses(): any {
29+
readonly hostClasses = computed(() => {
2930
return {
3031
footer: true,
31-
[`footer-${this.position}`]: !!this.position
32-
};
33-
}
32+
[`footer-${this.position()}`]: !!this.position()
33+
} as Record<string, boolean>;
34+
});
3435
}

0 commit comments

Comments
 (0)
Please sign in to comment.