All files / navigator navigator.component.ts

50% Statements 6/12
0% Branches 0/7
50% Functions 3/6
54.54% Lines 6/11

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                  1x 3x   3x   3x     1x       1x                                  
import { ChangeDetectionStrategy, Component, EventEmitter, HostListener, Output, signal } from '@angular/core';
 
@Component({
  selector: 'app-navigator',
  templateUrl: './navigator.component.html',
  styleUrls: ['./navigator.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
  standalone: false,
})
export class AppNavigatorComponent {
  public showSearch = signal(false);
 
  @Output() public readonly nagivateBack = new EventEmitter<void>();
 
  @Output() public readonly nagivateForward = new EventEmitter<void>();
 
  public back(): void {
    this.nagivateBack.emit();
  }
 
  public forward(): void {
    this.nagivateForward.emit();
  }
 
  public toggleSearch() {
    this.showSearch.update(value => !value);
  }
 
  @HostListener('window:keydown', ['$event'])
  public keyDown(event: KeyboardEvent): void {
    if (event.ctrlKey && event.shiftKey && event.key === '~') {
      this.toggleSearch();
    }
    if (event.key === 'Escape') {
      this.showSearch.set(false);
    }
  }
}