src/components/sq-countdown/sq-countdown.component.ts
Represents the SqCountdownComponent, a component for countdown.
Example :<sq-countdown [leftTime]="10"></sq-countdown>| selector | sq-countdown | 
| standalone | true | 
| imports | CountdownComponent | 
| styleUrls | ./sq-countdown.component.scss | 
| templateUrl | ./sq-countdown.component.html | 
| Methods | 
| Inputs | 
| Outputs | 
| format | |
| Type : string | |
| Default value : 'mm:ss' | |
| Formats a date value, pls refer to Accepted patterns. | |
| leftTime | |
| Type : number | |
| Default value : 10 | |
| Starting time to countdown (e.g., 5.5, 30) (Unit: seconds). | |
| notify | |
| Type : number[] | number | |
| Should be trigger type  | |
| doneEmitter | |
| Type : EventEmitter<ReturnEvent> | |
| Event emitter for when the countdown ends. | |
| notifyEmitter | |
| Type : EventEmitter<ReturnEvent> | |
| Event emitter for when the count reaches the input notify times. | |
| startEmitter | |
| Type : EventEmitter<ReturnEvent> | |
| Event emitter for when the countdown starts. | |
| eventMap | ||||||||
| eventMap(event: CountdownEvent) | ||||||||
| Map the CountdownEvents to emit startEmitter, notifyEmitter or doneEmitter. 
                                Parameters :
                                
                                 
 
                            Returns :          void | 
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { CountdownComponent, CountdownEvent } from 'ngx-countdown';
/**
 * Interface for the return event os emitters.
 * @interface
 */
interface ReturnEvent {
  /**
   * The time left in the countdown.
   */
  left: number;
}
/**
 * Represents the SqCountdownComponent, a component for countdown.
 *
 * @example
 * <sq-countdown [leftTime]="10"></sq-countdown>
 */
@Component({
  selector: 'sq-countdown',
  templateUrl: './sq-countdown.component.html',
  styleUrls: ['./sq-countdown.component.scss'],
  standalone: true,
  imports: [CountdownComponent],
})
export class SqCountdownComponent {
  /**
   * Starting time to countdown (e.g., 5.5, 30) (Unit: seconds).
   */
  @Input() leftTime = 10;
  /**
   * Formats a date value, pls refer to [Accepted patterns](https://angular.io/api/common/DatePipe#usage-notes).
   */
  @Input() format?: string = 'mm:ss';
  /**
   * Should be trigger type `notify` event on the x second. When values is `0` will be trigger every time.
   */
  @Input() notify?: number[] | number;
  /**
   * Event emitter for when the countdown starts.
   */
  @Output() startEmitter: EventEmitter<ReturnEvent> = new EventEmitter();
  /**
   * Event emitter for when the count reaches the input notify times.
   */
  @Output() notifyEmitter: EventEmitter<ReturnEvent> = new EventEmitter();
  /**
   * Event emitter for when the countdown ends.
   */
  @Output() doneEmitter: EventEmitter<ReturnEvent> = new EventEmitter();
  /**
   * Map the CountdownEvents to emit startEmitter, notifyEmitter or doneEmitter.
   * @param event - The event associated with the CountdownEvents.
   */
  eventMap(event: CountdownEvent) {
    const action = event.action as 'start' | 'notify' | 'done';
    if (action && this[`${action}Emitter`]) {
      const returnEvent: ReturnEvent = {
        left: event.left,
      };
      this[`${action}Emitter`].emit(returnEvent);
    }
  }
}
<countdown
  [config]="{
    leftTime: leftTime,
    format: format,
    notify: notify,
  }"
  (event)="eventMap($event)"
/>
                    ./sq-countdown.component.scss
                
::ng-deep {
  sq-countdown {
    min-width: min-content;
    countdown.count-down {
      span {
        color: var(--text_color);
      }
    }
  }
}