All files / toast-notification/si-toast-notification-drawer si-toast-notification-drawer.component.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 0/0
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51                                                                                      1x 9x 9x 9x   9x    
/**
 * Copyright (c) Siemens 2016 - 2025
 * SPDX-License-Identifier: MIT
 */
import { animate, style, transition, trigger } from '@angular/animations';
import { AsyncPipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';
import { areAnimationsDisabled } from '@siemens/element-ng/common';
import { Observable } from 'rxjs';
 
import { SiToastNotificationComponent } from '../si-toast-notification/si-toast-notification.component';
import { SiToast } from '../si-toast.model';
 
@Component({
  selector: 'si-toast-notification-drawer',
  imports: [AsyncPipe, SiToastNotificationComponent],
  templateUrl: './si-toast-notification-drawer.component.html',
  // workaround for cdk-overlay not supporting the order of overlays
  styles: `
    ::ng-deep .cdk-global-overlay-wrapper:has(si-toast-notification-drawer) {
      z-index: 2000;
    }
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
  host: {
    'aria-live': 'polite'
  },
  animations: [
    trigger('toastTrigger', [
      transition(':enter', [
        style({ opacity: 0, transform: 'translateY(100%)' }),
        animate(
          '500ms cubic-bezier(0.175, 0.885, 0.32, 1.275)',
          style({ opacity: 1, transform: 'translateY(0%)' })
        )
      ]),
      transition(':leave', [
        style({ 'opacity': 1, 'inset-inline-end': '0%' }),
        animate('300ms', style({ 'opacity': 0, 'inset-inline-end': '-100%' }))
      ])
    ])
  ]
})
export class SiToastNotificationDrawerComponent {
  readonly toasts = input<Observable<SiToast[]>>();
  readonly paused = output<SiToast>();
  readonly resumed = output<SiToast>();
 
  protected animationsDisabled = areAnimationsDisabled();
}