diff --git a/projects/ngxpert/hot-toast/src/lib/components/animated-icon/animated-icon.component.html b/projects/ngxpert/hot-toast/src/lib/components/animated-icon/animated-icon.component.html index ee912ad..76836f6 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/animated-icon/animated-icon.component.html +++ b/projects/ngxpert/hot-toast/src/lib/components/animated-icon/animated-icon.component.html @@ -1,3 +1,3 @@ -
+
diff --git a/projects/ngxpert/hot-toast/src/lib/components/animated-icon/animated-icon.component.ts b/projects/ngxpert/hot-toast/src/lib/components/animated-icon/animated-icon.component.ts index a8054e5..cf16ba2 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/animated-icon/animated-icon.component.ts +++ b/projects/ngxpert/hot-toast/src/lib/components/animated-icon/animated-icon.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, input } from '@angular/core'; import { IconTheme } from '../../hot-toast.model'; @Component({ @@ -8,5 +8,5 @@ import { IconTheme } from '../../hot-toast.model'; standalone: true, }) export class AnimatedIconComponent { - @Input() iconTheme: IconTheme; + iconTheme = input(); } diff --git a/projects/ngxpert/hot-toast/src/lib/components/hot-toast-container/hot-toast-container.component.ts b/projects/ngxpert/hot-toast/src/lib/components/hot-toast-container/hot-toast-container.component.ts index 45e9414..b065c8c 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/hot-toast-container/hot-toast-container.component.ts +++ b/projects/ngxpert/hot-toast/src/lib/components/hot-toast-container/hot-toast-container.component.ts @@ -1,4 +1,4 @@ -import { Component, ChangeDetectionStrategy, ChangeDetectorRef, Input, QueryList, ViewChildren } from '@angular/core'; +import { Component, ChangeDetectionStrategy, ChangeDetectorRef, QueryList, ViewChildren, Input } from '@angular/core'; import { Subject } from 'rxjs'; import { HotToastClose, @@ -66,18 +66,19 @@ export class HotToastContainerComponent { const visibleToasts = this.getVisibleToasts(position); const index = visibleToasts.findIndex((toast) => toast.id === toastId); const offset = - index !== -1 - ? visibleToasts.slice(...(this.defaultConfig.reverseOrder ? [index + 1] : [0, index])).reduce((acc, t, i) => { - const toastsAfter = visibleToasts.length - 1 - i; - return this.defaultConfig.visibleToasts !== 0 && i < visibleToasts.length - this.defaultConfig.visibleToasts - ? 0 - : acc + - (this.defaultConfig.stacking === 'vertical' || this.isShowingAllToasts - ? t.height || 0 - : toastsAfter * HOT_TOAST_DEPTH_SCALE + HOT_TOAST_DEPTH_SCALE_ADD) + - HOT_TOAST_MARGIN; - }, 0) - : 0; + index !== -1 + ? visibleToasts.slice(...(this.defaultConfig.reverseOrder ? [index + 1] : [0, index])).reduce((acc, t, i) => { + const toastsAfter = visibleToasts.length - 1 - i; + return this.defaultConfig.visibleToasts !== 0 && + i < visibleToasts.length - this.defaultConfig.visibleToasts + ? 0 + : acc + + (this.defaultConfig.stacking === 'vertical' || this.isShowingAllToasts + ? t.height || 0 + : toastsAfter * HOT_TOAST_DEPTH_SCALE + HOT_TOAST_DEPTH_SCALE_ADD) + + HOT_TOAST_MARGIN; + }, 0) + : 0; return offset; } @@ -189,7 +190,7 @@ export class HotToastContainerComponent { closeToast(id?: string) { if (id) { - const comp = this.hotToastComponentList.find((item) => item.toast.id === id); + const comp = this.hotToastComponentList.find((item) => item.toast().id === id); if (comp) { comp.close(); this.cdr.markForCheck(); diff --git a/projects/ngxpert/hot-toast/src/lib/components/hot-toast-group-item/hot-toast-group-item.component.html b/projects/ngxpert/hot-toast/src/lib/components/hot-toast-group-item/hot-toast-group-item.component.html index 24954d2..7e5b9d0 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/hot-toast-group-item/hot-toast-group-item.component.html +++ b/projects/ngxpert/hot-toast/src/lib/components/hot-toast-group-item/hot-toast-group-item.component.html @@ -1,7 +1,7 @@
@@ -10,34 +10,34 @@ class="hot-toast-bar-base" #hotToastBarBase [ngStyle]="toastBarBaseStylesSignal()" - [ngClass]="toast.className" + [ngClass]="toast().className" [style.--hot-toast-animation-state]="isManualClose ? 'running' : 'paused'" - [style.--hot-toast-exit-animation-state]="isShowingAllToasts ? 'paused' : 'running'" + [style.--hot-toast-exit-animation-state]="isShowingAllToasts() ? 'paused' : 'running'" [style.--hot-toast-exit-animation-delay]="exitAnimationDelay" - [attr.aria-live]="toast.ariaLive" - [attr.role]="toast.role" + [attr.aria-live]="toast().ariaLive" + [attr.role]="toast().role" >
- +
- @if (toast.dismissible) { + @if (toast().dismissible) { }
diff --git a/projects/ngxpert/hot-toast/src/lib/components/hot-toast-group-item/hot-toast-group-item.component.ts b/projects/ngxpert/hot-toast/src/lib/components/hot-toast-group-item/hot-toast-group-item.component.ts index 688a7cc..031aaa0 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/hot-toast-group-item/hot-toast-group-item.component.ts +++ b/projects/ngxpert/hot-toast/src/lib/components/hot-toast-group-item/hot-toast-group-item.component.ts @@ -2,11 +2,8 @@ import { ChangeDetectionStrategy, Component, ElementRef, - EventEmitter, Injector, - Input, NgZone, - Output, Renderer2, SimpleChanges, ViewChild, @@ -16,6 +13,9 @@ import { OnDestroy, signal, ChangeDetectorRef, + input, + output, + effect, } from '@angular/core'; import { NgClass, NgStyle } from '@angular/common'; import { AnimatedIconComponent } from '../animated-icon/animated-icon.component'; @@ -34,40 +34,17 @@ import { animate } from '../../utils'; imports: [NgClass, NgStyle, AnimatedIconComponent, IndicatorComponent, DynamicViewDirective], }) export class HotToastGroupItemComponent implements OnChanges, OnInit, AfterViewInit, OnDestroy { - private _toast: Toast; - @Input() - set toast(value: Toast) { - this._toast = value; - const top = value.position.includes('top'); - const enterAnimation = `hotToastEnterAnimation${ - top ? 'Negative' : 'Positive' - } ${ENTER_ANIMATION_DURATION}ms cubic-bezier(0.21, 1.02, 0.73, 1) forwards`; - - this.toastBarBaseStylesSignal.set({ ...value.style, animation: enterAnimation }); - } - get toast() { - return this._toast; - } - @Input() offset = 0; - @Input() defaultConfig: ToastConfig; - @Input() toastRef: CreateHotToastRef; - - private _toastsAfter = 0; - get toastsAfter() { - return this._toastsAfter; - } - @Input() - set toastsAfter(value) { - this._toastsAfter = value; - } - - @Input() isShowingAllToasts = false; - - @Output() height = new EventEmitter(); - @Output() beforeClosed = new EventEmitter(); - @Output() afterClosed = new EventEmitter(); - @Output() showAllToasts = new EventEmitter(); - @Output() toggleGroup = new EventEmitter(); + toast = input>(); + toastsAfter = input(0); + offset = input(0); + defaultConfig = input(); + toastRef = input>(); + isShowingAllToasts = input(false); + height = output(); + beforeClosed = output(); + afterClosed = output(); + showAllToasts = output(); + toggleGroup = output(); @ViewChild('hotToastBarBase', { static: true }) protected toastBarBase: ElementRef; @@ -84,43 +61,52 @@ export class HotToastGroupItemComponent implements OnChanges, OnInit, AfterViewI protected renderer: Renderer2, protected ngZone: NgZone, private cdr: ChangeDetectorRef - ) {} + ) { + + effect(() => { + const {position,style} = this.toast(); + const top = position.includes('top'); + const enterAnimation = `hotToastEnterAnimation${top ? 'Negative' : 'Positive' + } ${ENTER_ANIMATION_DURATION}ms cubic-bezier(0.21, 1.02, 0.73, 1) forwards`; + this.toastBarBaseStylesSignal.set({ ...style, animation: enterAnimation }); + }); + } get toastBarBaseHeight() { return this.toastBarBase.nativeElement.offsetHeight; } get scale() { - return this.defaultConfig.stacking !== 'vertical' && !this.isShowingAllToasts - ? this.toastsAfter * -HOT_TOAST_DEPTH_SCALE + 1 + return this.defaultConfig().stacking !== 'vertical' && !this.isShowingAllToasts() + ? this.toastsAfter() * -HOT_TOAST_DEPTH_SCALE + 1 : 1; } get translateY() { - return this.offset * (this.top ? 1 : -1) + 'px'; + return this.offset() * (this.top ? 1 : -1) + 'px'; } get exitAnimationDelay() { - return this.toast.duration + 'ms'; + return this.toast().duration + 'ms'; } get top() { - return this.toast.position.includes('top'); + return this.toast().position.includes('top'); } get containerPositionStyle() { const verticalStyle = this.top ? { top: 0 } : { bottom: 0 }; const transform = `translateY(var(--hot-toast-translate-y)) scale(var(--hot-toast-scale))`; - const horizontalStyle = this.toast.position.includes('left') - ? { - left: 0, - } - : this.toast.position.includes('right') + const horizontalStyle = this.toast().position.includes('left') ? { + left: 0, + } + : this.toast().position.includes('right') + ? { right: 0, } - : { + : { left: 0, right: 0, justifyContent: 'center', @@ -133,14 +119,14 @@ export class HotToastGroupItemComponent implements OnChanges, OnInit, AfterViewI } get isIconString() { - return typeof this.toast.icon === 'string'; + return typeof this.toast().icon === 'string'; } get groupChildrenToastRefs() { - return this.toastRef.groupRefs; + return this.toastRef().groupRefs; } set groupChildrenToastRefs(value: CreateHotToastRef[]) { - (this.toastRef as { groupRefs: CreateHotToastRef[] }).groupRefs = value; + (this.toastRef() as { groupRefs: CreateHotToastRef[] }).groupRefs = value; } get groupChildrenToasts() { @@ -152,7 +138,7 @@ export class HotToastGroupItemComponent implements OnChanges, OnInit, AfterViewI } get isExpanded() { - return this.toastRef.groupExpanded; + return this.toastRef().groupExpanded; } ngOnChanges(changes: SimpleChanges): void { @@ -164,18 +150,18 @@ export class HotToastGroupItemComponent implements OnChanges, OnInit, AfterViewI } ngOnInit() { - if (isTemplateRef(this.toast.message)) { - this.context = { $implicit: this.toastRef }; + if (isTemplateRef(this.toast().message)) { + this.context = { $implicit: this.toastRef() }; } - if (isComponent(this.toast.message)) { + if (isComponent(this.toast().message)) { this.toastComponentInjector = Injector.create({ providers: [ { provide: HotToastRef, - useValue: this.toastRef, + useValue: this.toastRef(), }, ], - parent: this.toast.injector || this.injector, + parent: this.toast().injector || this.injector, }); } @@ -199,16 +185,15 @@ export class HotToastGroupItemComponent implements OnChanges, OnInit, AfterViewI this.renderer.listen(nativeElement, 'animationend', (event: AnimationEvent) => { if (this.isEnterAnimation(event)) { this.ngZone.run(() => { - if (this.toast.autoClose) { - const exitAnimation = `hotToastExitAnimation${ - this.top ? 'Negative' : 'Positive' - } ${EXIT_ANIMATION_DURATION}ms forwards cubic-bezier(0.06, 0.71, 0.55, 1) var(--hot-toast-exit-animation-delay) var(--hot-toast-exit-animation-state)`; - this.toastBarBaseStylesSignal.set({ ...this.toast.style, animation: exitAnimation }); + if (this.toast().autoClose) { + const exitAnimation = `hotToastExitAnimation${this.top ? 'Negative' : 'Positive' + } ${EXIT_ANIMATION_DURATION}ms forwards cubic-bezier(0.06, 0.71, 0.55, 1) var(--hot-toast-exit-animation-delay) var(--hot-toast-exit-animation-state)`; + this.toastBarBaseStylesSignal.set({ ...this.toast().style, animation: exitAnimation }); } }); } if (this.isExitAnimation(event)) { - this.ngZone.run(() => this.afterClosed.emit({ dismissedByAction: this.isManualClose, id: this.toast.id })); + this.ngZone.run(() => this.afterClosed.emit({ dismissedByAction: this.isManualClose, id: this.toast().id })); } }) ); @@ -227,9 +212,8 @@ export class HotToastGroupItemComponent implements OnChanges, OnInit, AfterViewI } softClose() { - const exitAnimation = `hotToastExitSoftAnimation${ - this.top ? 'Negative' : 'Positive' - } ${EXIT_ANIMATION_DURATION}ms forwards cubic-bezier(0.06, 0.71, 0.55, 1)`; + const exitAnimation = `hotToastExitSoftAnimation${this.top ? 'Negative' : 'Positive' + } ${EXIT_ANIMATION_DURATION}ms forwards cubic-bezier(0.06, 0.71, 0.55, 1)`; const nativeElement = this.toastBarBase.nativeElement; @@ -237,9 +221,8 @@ export class HotToastGroupItemComponent implements OnChanges, OnInit, AfterViewI this.softClosed = true; } softOpen() { - const softEnterAnimation = `hotToastEnterSoftAnimation${ - top ? 'Negative' : 'Positive' - } ${ENTER_ANIMATION_DURATION}ms cubic-bezier(0.21, 1.02, 0.73, 1) forwards`; + const softEnterAnimation = `hotToastEnterSoftAnimation${top ? 'Negative' : 'Positive' + } ${ENTER_ANIMATION_DURATION}ms cubic-bezier(0.21, 1.02, 0.73, 1) forwards`; const nativeElement = this.toastBarBase.nativeElement; @@ -251,10 +234,9 @@ export class HotToastGroupItemComponent implements OnChanges, OnInit, AfterViewI this.isManualClose = true; this.cdr.markForCheck(); - const exitAnimation = `hotToastExitAnimation${ - this.top ? 'Negative' : 'Positive' - } ${EXIT_ANIMATION_DURATION}ms forwards cubic-bezier(0.06, 0.71, 0.55, 1)`; - this.toastBarBaseStylesSignal.set({ ...this.toast.style, animation: exitAnimation }); + const exitAnimation = `hotToastExitAnimation${this.top ? 'Negative' : 'Positive' + } ${EXIT_ANIMATION_DURATION}ms forwards cubic-bezier(0.06, 0.71, 0.55, 1)`; + this.toastBarBaseStylesSignal.set({ ...this.toast().style, animation: exitAnimation }); } handleMouseEnter() { @@ -280,7 +262,7 @@ export class HotToastGroupItemComponent implements OnChanges, OnInit, AfterViewI } private setToastAttributes() { - const toastAttributes: Record = this.toast.attributes; + const toastAttributes: Record = this.toast().attributes; for (const [key, value] of Object.entries(toastAttributes)) { this.renderer.setAttribute(this.toastBarBase.nativeElement, key, value); } diff --git a/projects/ngxpert/hot-toast/src/lib/components/hot-toast/hot-toast.component.html b/projects/ngxpert/hot-toast/src/lib/components/hot-toast/hot-toast.component.html index df8911b..01ad1c4 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/hot-toast/hot-toast.component.html +++ b/projects/ngxpert/hot-toast/src/lib/components/hot-toast/hot-toast.component.html @@ -1,7 +1,7 @@
@@ -15,45 +15,45 @@ class="hot-toast-bar-base" #hotToastBarBase [ngStyle]="toastBarBaseStylesSignal()" - [ngClass]="toast.className" + [ngClass]="toast().className" [style.--hot-toast-animation-state]="isManualClose ? 'running' : 'paused'" - [style.--hot-toast-exit-animation-state]="isShowingAllToasts ? 'paused' : 'running'" + [style.--hot-toast-exit-animation-state]="isShowingAllToasts() ? 'paused' : 'running'" [style.--hot-toast-exit-animation-delay]="exitAnimationDelay" - [attr.aria-live]="toast.ariaLive" - [attr.role]="toast.role" + [attr.aria-live]="toast().ariaLive" + [attr.role]="toast().role" >
- +
- @if (toast.group?.expandAndCollapsible && toast.group?.children && visibleToasts.length > 0) { + @if (toast().group?.expandAndCollapsible && toast().group?.children && visibleToasts.length > 0) { - } @if (toast.dismissible) { + } @if (toast().dismissible) { }
@@ -61,17 +61,17 @@
@for (item of groupChildrenToasts; track item.id) { ; - @Input() - set toast(value: Toast) { - this._toast = value; - const top = value.position.includes('top'); - const enterAnimation = `hotToastEnterAnimation${ - top ? 'Negative' : 'Positive' - } ${ENTER_ANIMATION_DURATION}ms cubic-bezier(0.21, 1.02, 0.73, 1) forwards`; - - this.toastBarBaseStylesSignal.set({ ...value.style, animation: enterAnimation }); - } - get toast() { - return this._toast; - } - @Input() offset = 0; - @Input() defaultConfig: ToastConfig; - @Input() toastRef: CreateHotToastRef; - - private _toastsAfter = 0; - get toastsAfter() { - return this._toastsAfter; - } - @Input() - set toastsAfter(value) { - this._toastsAfter = value; - if (this.defaultConfig?.visibleToasts > 0) { - if (this.toast.autoClose) { - // if (value >= this.defaultConfig?.visibleToasts) { - // this.close(); - // } - } else { - if (value >= this.defaultConfig?.visibleToasts) { - this.softClose(); - } else if (this.softClosed) { - this.softOpen(); - } - } - } - } - - @Input() isShowingAllToasts = false; - - @Output() height = new EventEmitter(); - @Output() beforeClosed = new EventEmitter(); - @Output() afterClosed = new EventEmitter(); - @Output() showAllToasts = new EventEmitter(); - @Output() toggleGroup = new EventEmitter(); + toast = input>(); + offset = input(0); + toastsAfter = input(0); + defaultConfig = input(); + toastRef = input>(); + isShowingAllToasts = input(false); + + height = output(); + beforeClosed = output(); + afterClosed = output(); + showAllToasts = output(); + toggleGroup = output(); @ViewChild('hotToastBarBase', { static: true }) private toastBarBase: ElementRef; @@ -102,43 +68,71 @@ export class HotToastComponent implements OnInit, AfterViewInit, OnDestroy, OnCh private renderer: Renderer2, private ngZone: NgZone, private cdr: ChangeDetectorRef - ) {} + ) { + effect(() => { + const {position,style} = this.toast(); + const top = position.includes('top'); + const enterAnimation = `hotToastEnterAnimation${top ? 'Negative' : 'Positive' + } ${ENTER_ANIMATION_DURATION}ms cubic-bezier(0.21, 1.02, 0.73, 1) forwards`; + + this.toastBarBaseStylesSignal.set({ ...style, animation: enterAnimation }); + }); + + effect(() => { + const toastsAfter = this.toastsAfter() + const defaultConfig = untracked(this.defaultConfig); + const toast = untracked(this.toast); + if (defaultConfig?.visibleToasts > 0) { + if (toast.autoClose) { + // if (value >= this.defaultConfig?.visibleToasts) { + // this.close(); + // } + } else { + if (toastsAfter >= defaultConfig?.visibleToasts) { + this.softClose(); + } else if (this.softClosed) { + this.softOpen(); + } + } + } + }) + } get toastBarBaseHeight() { return this.toastBarBase.nativeElement.offsetHeight; } get scale() { - return this.defaultConfig.stacking !== 'vertical' && !this.isShowingAllToasts - ? this.toastsAfter * -HOT_TOAST_DEPTH_SCALE + 1 + return this.defaultConfig().stacking !== 'vertical' && !this.isShowingAllToasts() + ? this.toastsAfter() * -HOT_TOAST_DEPTH_SCALE + 1 : 1; } get translateY() { - return this.offset * (this.top ? 1 : -1) + 'px'; + return this.offset() * (this.top ? 1 : -1) + 'px'; } get exitAnimationDelay() { - return this.toast.duration + 'ms'; + return this.toast().duration + 'ms'; } get top() { - return this.toast.position.includes('top'); + return this.toast().position.includes('top'); } get containerPositionStyle() { const verticalStyle = this.top ? { top: 0 } : { bottom: 0 }; const transform = `translateY(var(--hot-toast-translate-y)) scale(var(--hot-toast-scale))`; - const horizontalStyle = this.toast.position.includes('left') - ? { - left: 0, - } - : this.toast.position.includes('right') + const horizontalStyle = this.toast().position.includes('left') ? { + left: 0, + } + : this.toast().position.includes('right') + ? { right: 0, } - : { + : { left: 0, right: 0, justifyContent: 'center', @@ -151,7 +145,7 @@ export class HotToastComponent implements OnInit, AfterViewInit, OnDestroy, OnCh } get isIconString() { - return typeof this.toast.icon === 'string'; + return typeof this.toast().icon === 'string'; } get groupChildrenToastRefs() { @@ -161,7 +155,7 @@ export class HotToastComponent implements OnInit, AfterViewInit, OnDestroy, OnCh this.groupRefs = value; // maybe below will prevent execution in ngDoCheck? - (this.toastRef as { groupRefs: CreateHotToastRef[] }).groupRefs = value; + (this.toastRef() as { groupRefs: CreateHotToastRef[] }).groupRefs = value; } get groupChildrenToasts() { @@ -170,7 +164,7 @@ export class HotToastComponent implements OnInit, AfterViewInit, OnDestroy, OnCh get groupHeight() { return this.visibleToasts - .slice(-this.defaultConfig.visibleToasts) + .slice(-this.defaultConfig().visibleToasts) .map((t) => t.height) .reduce((prev, curr) => prev + curr, 0); } @@ -180,14 +174,14 @@ export class HotToastComponent implements OnInit, AfterViewInit, OnDestroy, OnCh } ngDoCheck() { - if (this.toastRef.groupRefs.length !== this.groupRefs.length) { - this.groupRefs = this.toastRef.groupRefs.slice(); + if (this.toastRef().groupRefs.length !== this.groupRefs.length) { + this.groupRefs = this.toastRef().groupRefs.slice(); this.cdr.markForCheck(); this.emiHeightWithGroup(this.isExpanded); } - if (this.toastRef.groupExpanded !== this.isExpanded) { - this.isExpanded = this.toastRef.groupExpanded; + if (this.toastRef().groupExpanded !== this.isExpanded) { + this.isExpanded = this.toastRef().groupExpanded; this.cdr.markForCheck(); this.emiHeightWithGroup(this.isExpanded); @@ -201,18 +195,18 @@ export class HotToastComponent implements OnInit, AfterViewInit, OnDestroy, OnCh } ngOnInit() { - if (isTemplateRef(this.toast.message)) { - this.context = { $implicit: this.toastRef }; + if (isTemplateRef(this.toast().message)) { + this.context = { $implicit: this.toastRef() }; } - if (isComponent(this.toast.message)) { + if (isComponent(this.toast().message)) { this.toastComponentInjector = Injector.create({ providers: [ { provide: HotToastRef, - useValue: this.toastRef, + useValue: this.toastRef(), }, ], - parent: this.toast.injector || this.injector, + parent: this.toast().injector || this.injector, }); } @@ -236,16 +230,15 @@ export class HotToastComponent implements OnInit, AfterViewInit, OnDestroy, OnCh this.renderer.listen(nativeElement, 'animationend', (event: AnimationEvent) => { if (this.isEnterAnimation(event)) { this.ngZone.run(() => { - if (this.toast.autoClose) { - const exitAnimation = `hotToastExitAnimation${ - this.top ? 'Negative' : 'Positive' - } ${EXIT_ANIMATION_DURATION}ms forwards cubic-bezier(0.06, 0.71, 0.55, 1) var(--hot-toast-exit-animation-delay) var(--hot-toast-exit-animation-state)`; - this.toastBarBaseStylesSignal.set({ ...this.toast.style, animation: exitAnimation }); + if (this.toast().autoClose) { + const exitAnimation = `hotToastExitAnimation${this.top ? 'Negative' : 'Positive' + } ${EXIT_ANIMATION_DURATION}ms forwards cubic-bezier(0.06, 0.71, 0.55, 1) var(--hot-toast-exit-animation-delay) var(--hot-toast-exit-animation-state)`; + this.toastBarBaseStylesSignal.set({ ...this.toast().style, animation: exitAnimation }); } }); } if (this.isExitAnimation(event)) { - this.ngZone.run(() => this.afterClosed.emit({ dismissedByAction: this.isManualClose, id: this.toast.id })); + this.ngZone.run(() => this.afterClosed.emit({ dismissedByAction: this.isManualClose, id: this.toast().id })); } }) ); @@ -264,9 +257,8 @@ export class HotToastComponent implements OnInit, AfterViewInit, OnDestroy, OnCh } softClose() { - const exitAnimation = `hotToastExitSoftAnimation${ - this.top ? 'Negative' : 'Positive' - } ${EXIT_ANIMATION_DURATION}ms forwards cubic-bezier(0.06, 0.71, 0.55, 1)`; + const exitAnimation = `hotToastExitSoftAnimation${this.top ? 'Negative' : 'Positive' + } ${EXIT_ANIMATION_DURATION}ms forwards cubic-bezier(0.06, 0.71, 0.55, 1)`; const nativeElement = this.toastBarBase.nativeElement; @@ -279,9 +271,8 @@ export class HotToastComponent implements OnInit, AfterViewInit, OnDestroy, OnCh } softOpen() { - const softEnterAnimation = `hotToastEnterSoftAnimation${ - top ? 'Negative' : 'Positive' - } ${ENTER_ANIMATION_DURATION}ms cubic-bezier(0.21, 1.02, 0.73, 1) forwards`; + const softEnterAnimation = `hotToastEnterSoftAnimation${top ? 'Negative' : 'Positive' + } ${ENTER_ANIMATION_DURATION}ms cubic-bezier(0.21, 1.02, 0.73, 1) forwards`; const nativeElement = this.toastBarBase.nativeElement; @@ -293,11 +284,10 @@ export class HotToastComponent implements OnInit, AfterViewInit, OnDestroy, OnCh this.isManualClose = true; this.cdr.markForCheck(); - const exitAnimation = `hotToastExitAnimation${ - this.top ? 'Negative' : 'Positive' - } ${EXIT_ANIMATION_DURATION}ms forwards cubic-bezier(0.06, 0.71, 0.55, 1)`; + const exitAnimation = `hotToastExitAnimation${this.top ? 'Negative' : 'Positive' + } ${EXIT_ANIMATION_DURATION}ms forwards cubic-bezier(0.06, 0.71, 0.55, 1)`; - this.toastBarBaseStylesSignal.set({ ...this.toast.style, animation: exitAnimation }); + this.toastBarBaseStylesSignal.set({ ...this.toast().style, animation: exitAnimation }); } handleMouseEnter() { @@ -323,7 +313,7 @@ export class HotToastComponent implements OnInit, AfterViewInit, OnDestroy, OnCh } private setToastAttributes() { - const toastAttributes: Record = this.toast.attributes; + const toastAttributes: Record = this.toast().attributes; for (const [key, value] of Object.entries(toastAttributes)) { this.renderer.setAttribute(this.toastBarBase.nativeElement, key, value); } @@ -334,11 +324,12 @@ export class HotToastComponent implements OnInit, AfterViewInit, OnDestroy, OnCh const index = visibleToasts.findIndex((toast) => toast.id === toastId); const offset = index !== -1 - ? visibleToasts.slice(...(this.defaultConfig.reverseOrder ? [index + 1] : [0, index])).reduce((acc, t, i) => { - return this.defaultConfig.visibleToasts !== 0 && i < visibleToasts.length - this.defaultConfig.visibleToasts - ? 0 - : acc + (t.height || 0); - }, 0) + ? visibleToasts.slice(...(this.defaultConfig().reverseOrder ? [index + 1] : [0, index])).reduce((acc, t, i) => { + return this.defaultConfig().visibleToasts !== 0 && + i < visibleToasts.length - this.defaultConfig().visibleToasts + ? 0 + : acc + (t.height || 0); + }, 0) : 0; return offset; } @@ -371,7 +362,7 @@ export class HotToastComponent implements OnInit, AfterViewInit, OnDestroy, OnCh this.toggleGroup.emit({ byAction: true, event, - id: this.toast.id, + id: this.toast().id, }); this.emiHeightWithGroup(event === 'expand'); } diff --git a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/checkmark/checkmark.component.html b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/checkmark/checkmark.component.html index 211b6e5..7026eed 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/checkmark/checkmark.component.html +++ b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/checkmark/checkmark.component.html @@ -1,5 +1,5 @@
diff --git a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/checkmark/checkmark.component.ts b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/checkmark/checkmark.component.ts index 3e66369..adc12b4 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/checkmark/checkmark.component.ts +++ b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/checkmark/checkmark.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, input } from '@angular/core'; import { IconTheme } from '../../../../hot-toast.model'; @Component({ @@ -8,5 +8,5 @@ import { IconTheme } from '../../../../hot-toast.model'; standalone: true, }) export class CheckMarkComponent { - @Input() theme: IconTheme; + theme = input(); } diff --git a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/error/error.component.html b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/error/error.component.html index 93a00cd..ddd3ffa 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/error/error.component.html +++ b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/error/error.component.html @@ -1,5 +1,5 @@
diff --git a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/error/error.component.ts b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/error/error.component.ts index e40168a..c3473da 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/error/error.component.ts +++ b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/error/error.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, input } from '@angular/core'; import { IconTheme } from '../../../../hot-toast.model'; @Component({ @@ -8,5 +8,5 @@ import { IconTheme } from '../../../../hot-toast.model'; standalone: true, }) export class ErrorComponent { - @Input() theme: IconTheme; + theme = input(); } diff --git a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/info/info.component.html b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/info/info.component.html index 6f26b44..8f84815 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/info/info.component.html +++ b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/info/info.component.html @@ -1,5 +1,5 @@
diff --git a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/info/info.component.ts b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/info/info.component.ts index cd83de9..dcfe195 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/info/info.component.ts +++ b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/info/info.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, input } from '@angular/core'; import { IconTheme } from '../../../../hot-toast.model'; @Component({ @@ -8,5 +8,5 @@ import { IconTheme } from '../../../../hot-toast.model'; standalone: true, }) export class InfoComponent { - @Input() theme: IconTheme; + theme = input(); } diff --git a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/loader/loader.component.html b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/loader/loader.component.html index 7954708..7d94a11 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/loader/loader.component.html +++ b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/loader/loader.component.html @@ -1,4 +1,4 @@
diff --git a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/loader/loader.component.ts b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/loader/loader.component.ts index 583efd0..ac89aad 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/loader/loader.component.ts +++ b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/loader/loader.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, input } from '@angular/core'; import { CommonModule } from '@angular/common'; import { IconTheme } from '../../../../hot-toast.model'; @@ -11,5 +11,5 @@ import { IconTheme } from '../../../../hot-toast.model'; imports: [CommonModule], }) export class LoaderComponent { - @Input() theme: IconTheme; + theme = input(); } diff --git a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/warning/warning.component.html b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/warning/warning.component.html index bc92a1a..efbf992 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/warning/warning.component.html +++ b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/warning/warning.component.html @@ -1,5 +1,5 @@
diff --git a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/warning/warning.component.ts b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/warning/warning.component.ts index 3ea61e6..f1ef63d 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/warning/warning.component.ts +++ b/projects/ngxpert/hot-toast/src/lib/components/indicator/icons/warning/warning.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, input } from '@angular/core'; import { IconTheme } from '../../../../hot-toast.model'; @Component({ @@ -8,5 +8,5 @@ import { IconTheme } from '../../../../hot-toast.model'; standalone: true, }) export class WarningComponent { - @Input() theme: IconTheme; + theme = input(); } diff --git a/projects/ngxpert/hot-toast/src/lib/components/indicator/indicator.component.html b/projects/ngxpert/hot-toast/src/lib/components/indicator/indicator.component.html index bfa1c22..2298f2f 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/indicator/indicator.component.html +++ b/projects/ngxpert/hot-toast/src/lib/components/indicator/indicator.component.html @@ -1,25 +1,25 @@ -@if (type !== 'blank') { +@if (type() !== 'blank') {
- @if (type === 'loading') { - - } @if (type !== 'loading') { + @if (type() === 'loading') { + + } @if (type() !== 'loading') {
- @switch (type) { @case ('error') { + @switch (type()) { @case ('error') {
- +
} @case ('success') {
- +
} @case ('warning') {
- +
} @case ('info') {
- +
} }
diff --git a/projects/ngxpert/hot-toast/src/lib/components/indicator/indicator.component.ts b/projects/ngxpert/hot-toast/src/lib/components/indicator/indicator.component.ts index ea1c42c..6556ae1 100644 --- a/projects/ngxpert/hot-toast/src/lib/components/indicator/indicator.component.ts +++ b/projects/ngxpert/hot-toast/src/lib/components/indicator/indicator.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, input } from '@angular/core'; import { IconTheme, ToastType } from '../../hot-toast.model'; import { LoaderComponent } from './icons/loader/loader.component'; @@ -15,6 +15,6 @@ import { InfoComponent } from './icons/info/info.component'; imports: [LoaderComponent, ErrorComponent, CheckMarkComponent, WarningComponent, InfoComponent], }) export class IndicatorComponent { - @Input() theme: IconTheme; - @Input() type: ToastType; + theme = input(); + type = input(); } diff --git a/src/app/shared/components/button-group/button-group.component.html b/src/app/shared/components/button-group/button-group.component.html index 5a29603..20dc3a5 100644 --- a/src/app/shared/components/button-group/button-group.component.html +++ b/src/app/shared/components/button-group/button-group.component.html @@ -1,5 +1,5 @@
- @for (button of buttons; track button; let isFirst = $first; let isLast = $last) { + @for (button of buttons(); track button; let isFirst = $first; let isLast = $last) {