/*
 * Copyright (C) 2018 Robert Bosch GmbH Copyright (C) 2018 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { Directive, EventEmitter, HostBinding, HostListener, Input, Output } from '@angular/core';

@Directive({
  selector: `[bciToggleButton]`,
})
export class ToggleButtonDirective {
  @HostBinding('class.commandbar-button-active')
  @Input()
  active = false;

  @Output() toggle = new EventEmitter<boolean>();

  @HostListener('click')
  @HostListener('keyup.enter')
  onClick() {
    this.active = !this.active;
    this.toggle.emit(this.active);
  }
}
