Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c7c4035

Browse filesBrowse files
committed
refactor(sidebar-brand): signal inputs, host bindings, cleanup
1 parent 65ff325 commit c7c4035
Copy full SHA for c7c4035

File tree

Expand file treeCollapse file tree

2 files changed

+17
-22
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-22
lines changed

‎projects/coreui-angular/src/lib/sidebar/sidebar-brand/sidebar-brand.component.html

Copy file name to clipboardExpand all lines: projects/coreui-angular/src/lib/sidebar/sidebar-brand/sidebar-brand.component.html
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
@if (brandImg) {
2-
<a [routerLink]="routerLink">
3-
@if (brandFull) {
4-
<img [cHtmlAttr]="brandFull" [ngClass]="'sidebar-brand-full'">
1+
@if (brandImg()) {
2+
<a [routerLink]="routerLink()">
3+
@if (brandFull()) {
4+
<img [cHtmlAttr]="brandFull()" [ngClass]="'sidebar-brand-full'">
55
}
6-
@if (brandNarrow) {
7-
<img [cHtmlAttr]="brandNarrow" [ngClass]="'sidebar-brand-narrow'">
6+
@if (brandNarrow()) {
7+
<img [cHtmlAttr]="brandNarrow()" [ngClass]="'sidebar-brand-narrow'">
88
}
99
</a>
1010
} @else {
+11-16Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
import { Component, HostBinding, Input, OnInit } from '@angular/core';
1+
import { Component, computed, input } from '@angular/core';
22
import { NgClass } from '@angular/common';
3-
import { RouterLink } from '@angular/router';
3+
import { RouterLink, type UrlTree } from '@angular/router';
44

55
import { HtmlAttributesDirective } from '../../shared';
66

77
@Component({
8-
selector: 'c-sidebar-brand',
9-
templateUrl: './sidebar-brand.component.html',
10-
imports: [RouterLink, HtmlAttributesDirective, NgClass]
8+
selector: 'c-sidebar-brand',
9+
templateUrl: './sidebar-brand.component.html',
10+
imports: [RouterLink, HtmlAttributesDirective, NgClass],
11+
host: { class: 'sidebar-brand' }
1112
})
12-
export class SidebarBrandComponent implements OnInit {
13+
export class SidebarBrandComponent {
14+
readonly brandFull = input<any>();
15+
readonly brandNarrow = input<any>();
1316

14-
@Input() brandFull?: any;
15-
@Input() brandNarrow?: any;
16-
@Input() routerLink?: any[] | string;
17+
readonly routerLink = input<string | any[] | UrlTree | null | undefined>();
1718

18-
@HostBinding('class.sidebar-brand') sidebarBrandClass = true;
19-
20-
brandImg = false;
21-
22-
ngOnInit(): void {
23-
this.brandImg = Boolean(this.brandFull || this.brandNarrow);
24-
}
19+
readonly brandImg = computed(() => Boolean(this.brandFull() || this.brandNarrow()));
2520
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.