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 8deeabf

Browse filesBrowse files
committed
refactor(alert): dismissible getter for backward compatibility
1 parent 2fa6d83 commit 8deeabf
Copy full SHA for 8deeabf

File tree

Expand file treeCollapse file tree

2 files changed

+27
-11
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+27
-11
lines changed

‎projects/coreui-angular/src/lib/alert/alert.component.html

Copy file name to clipboardExpand all lines: projects/coreui-angular/src/lib/alert/alert.component.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@if (visible || !hide()) {
2-
@if (dismissible()) {
2+
@if (dismissible) {
33
<ng-container *ngTemplateOutlet="templates()?.['alertButtonCloseTemplate'] || defaultAlertButtonCloseTemplate" />
44
}
55
<ng-content />

‎projects/coreui-angular/src/lib/alert/alert.component.ts

Copy file name to clipboardExpand all lines: projects/coreui-angular/src/lib/alert/alert.component.ts
+26-10Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {
33
Component,
44
computed,
55
contentChildren,
6-
effect,
76
input,
7+
linkedSignal,
88
output,
99
signal,
1010
TemplateRef
@@ -70,7 +70,22 @@ export class AlertComponent {
7070
* @return boolean
7171
* @default false
7272
*/
73-
readonly dismissible = input(false, { transform: booleanAttribute });
73+
readonly dismissibleInput = input(false, { transform: booleanAttribute, alias: 'dismissible' });
74+
75+
readonly #dismissible = linkedSignal({
76+
source: () => this.dismissibleInput(),
77+
computation: (value) => {
78+
return value;
79+
}
80+
});
81+
82+
set dismissible(value: boolean) {
83+
this.#dismissible.set(value);
84+
}
85+
86+
get dismissible() {
87+
return this.#dismissible();
88+
}
7489

7590
/**
7691
* Adds animation for dismissible alert.
@@ -84,23 +99,24 @@ export class AlertComponent {
8499
*/
85100
readonly visibleInput = input(true, { transform: booleanAttribute, alias: 'visible' });
86101

87-
readonly #visibleInputEffect = effect(() => {
88-
this.visible = this.visibleInput();
102+
readonly #visible = linkedSignal({
103+
source: () => this.visibleInput(),
104+
computation: (value) => {
105+
return value;
106+
}
89107
});
90108

91109
set visible(value: boolean) {
92-
if (this.#visible !== value) {
93-
this.#visible = value;
110+
if (this.#visible() !== value) {
111+
this.#visible.set(value);
94112
this.visibleChange.emit(value);
95113
}
96114
}
97115

98116
get visible() {
99-
return this.#visible;
117+
return this.#visible();
100118
}
101119

102-
#visible: boolean = true;
103-
104120
readonly hide = signal<boolean>(false);
105121

106122
/**
@@ -129,7 +145,7 @@ export class AlertComponent {
129145
const variant = this.variant();
130146
return {
131147
alert: true,
132-
'alert-dismissible': this.dismissible(),
148+
'alert-dismissible': this.dismissible,
133149
fade: this.fade(),
134150
show: !this.hide(),
135151
[`alert-${color}`]: !!color && variant !== 'solid',

0 commit comments

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