All files / application-header/launchpad si-launchpad-app.component.ts

93.33% Statements 14/15
100% Branches 0/0
66.66% Functions 2/3
92.85% Lines 13/14

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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66                                                                        1x   15x   15x   15x   15x   15x 15x 15x   15x   15x       1x 1x 1x              
/**
 * Copyright (c) Siemens 2016 - 2025
 * SPDX-License-Identifier: MIT
 */
import {
  booleanAttribute,
  ChangeDetectionStrategy,
  Component,
  HostListener,
  inject,
  input,
  model
} from '@angular/core';
import {
  addIcons,
  elementExport,
  elementFavorites,
  elementFavoritesFilled,
  SiIconComponent
} from '@siemens/element-ng/icon';
 
import { SiApplicationHeaderComponent } from '../si-application-header.component';
 
@Component({
  // eslint-disable-next-line @angular-eslint/component-selector
  selector: 'a[si-launchpad-app]',
  imports: [SiIconComponent],
  templateUrl: './si-launchpad-app.component.html',
  styleUrl: './si-launchpad-app.component.scss',
  changeDetection: ChangeDetectionStrategy.OnPush,
  host: {
    class: 'focus-inside',
    '[class.active]': 'active()',
    '[class.action]': 'action()'
  }
})
export class SiLaunchpadAppComponent {
  /** @defaultValue false */
  readonly external = input(false, { transform: booleanAttribute });
  /** @defaultValue false */
  readonly active = input(false, { transform: booleanAttribute });
  /** @defaultValue false */
  readonly enableFavoriteToggle = input(false, { transform: booleanAttribute });
  /** @defaultValue false */
  readonly favorite = model(false);
  /** @defaultValue false */
  readonly action = input(false, { transform: booleanAttribute });
  readonly iconUrl = input<string>();
  readonly iconClass = input<string>();
 
  protected readonly icons = addIcons({ elementExport, elementFavorites, elementFavoritesFilled });
 
  private header = inject(SiApplicationHeaderComponent);
 
  @HostListener('keydown.space', ['$event'])
  protected favoriteClicked(event: Event): void {
    event.stopPropagation();
    event.preventDefault();
    this.favorite.update(old => !old);
  }
 
  @HostListener('click') protected click(): void {
    this.header.closeLaunchpad();
  }
}