npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zokelion/ngx-countdown

v1.0.4

Published

ngx-countdown is a light and easy to use Angular library that will give you access to a countdown display component

Downloads

54

Readme

Welcome to @Zokelion/NgxCountdown !

This is an Angular 7+ package to make your life easier. But before we get started, let's just check that this plugin will fit your needs 😉

What does this do ?

  • As the name suggests, this offers a component to display countdowns
  • We give customizable output format via config option. Since we rely on Angular's DatePipe usage, anything shown here will work (in a limited way, we'll discuss this later 😉)

What is it that this plugin won't do ?

  • Sadly, we don't support countdowns larger than 23 hours, 59 minutes and 59 seconds. As I said, we rely on Angular's DatePipe, so if you want to display a countdown with units bigger than hours, you'll get... A date (something like 03-01-1970 00:00:00) 😞

NgxCountdown seems fine for your needs ?

Alright, so it's time for some serious doc now I guess, if you're gonna use this, here are the few things you'll need to know

Quickstart

First of all, you'll need to import NgxCountdownModule into your app.module.ts, just like this:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { NgxCountdownModule } from '../lib/ngx-countdown.module';

@NgModule({
    declarations: [AppComponent],
    imports: [BrowserModule, NgxCountdownModule], // Add this module to your imports here
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule {}

Once this is done, it's pretty simple to use. By importing the module, you gained access to a brand new HTML tag: <ngx-countdown> Let's get straight into the @Input() and @Output() of this component !

@Input() parameters

| Name | Type | Default Value | | ------ | :----------------: | ------------- | | config | NgxCountdownConfig | Cf: below |

NgxCountdownConfig type

This is a simple interface that describes expected parameters for a countdown component. It does not have many options, here are all of them:

| Name | Type | required | Description | Default | | -------- | -------- | :------: | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | | timeLeft | number | ❌ | The time at which your countdown will start in seconds, 3600 will make it 1 hour long | 0 | | notifyAt | number[] | ❌ | Whenever the timer hits one of the numbers given here, it will fire a NgxCountdownNotifyEvent. Doesn't work for 0 since we have the finished event | [] | | format | string | ❌ | The time format you want, anything shown here will work | 'HH:mm:ss' |

Events fired by a countdown

| Name | Event type | Description | | -------- | ----------------------- | ----------------------------------------------------------------------------------------------- | | started | void | Fired when the timer starts for the first time | | finished | void | Fired when the countdown reaches 0 | | notify | NgxCountdownNotifyEvent | Fired when the remaining time is one of the values givent in the notifyAt parameter of config |

NgxCountdownNotifyEvent

This is a simple class that gives the remaining time when a notify event is fired by the component. It has only one property: timeLeft, which is a number. I created it for more convenience if someday I decide to add some infos into this.

Publicly available methods on the component

And the last part of this doc: "how do I use this component ?" You'll need a reference to it in your TS, just like this:

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
})
export class AppComponent {
    @ViewChild('timer')
    public timer: NgxCountdownComponent;
}

You can then call the following methods:

| Name | Parameters | Return type | Description | | ----- | ---------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | start | none | void | Starts the timer and makes it continue after a call to stop() | | stop | none | void | Stops the countdown. Actually, this could be named pause() as well since that's exactly he job it performs. | | reset | none | void | Resets the countdown, causing it to get paused and brought back to config.timeLeft. If you want a change to your config.timeLeft to take effect immediately, you need to call this right after the update |

And we're done for now guys, hope this will be useful to you, now do some fun things and enjoy coding 😎