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

@smithalan2/vue-countdown

v1.0.2

Published

A simple countdown timer component for Vue 3 written using the composition API.

Downloads

70

Readme

Vue Countdown

A simple countdown timer component for Vue 3 written using the composition API.

Demo https://smithalan92.github.io/vue-countdown/


Installation

Install with npm

npm i --save @smithalan2/vue-countdown

Props

| Name | Type | Required | Default | Notes | |---------|-------|------| ------- | ----- | | startDateTime | Date | no | new Date() on each tick | Passing a start date time will result in only 1 calc being made. | | endDateTime | Date | yes | n/a | ---- | | startImmediately | Boolean | false | true | If passed as false, you need to call run on the component ref. | | tickDelay | Number | no | 1000 | ms to run each recalculation. |


Events

| Name | Args | Notes | |---------|-------|------| | start | None | Emitted the first time a countdown starts | | finished | None | Emitted when the countdown has reached the end time | | cancelled | None | Emitted when the countdown has been cancelled | | tick | Countdown | The newely calculated countdown values


Slot props

If the component is passed a default slot. The slot will recieve a prop with Countdown data


Exposed Properties

The component instance exposes a number of properties that can be used if required.

| Name | Notes | |---------|-------| | run | A function to manually start the countdown. | | cancel | A function to cancel the countdown | | countdown | The actual reactive countdown data


Countdown Data

The countdown data is a reactive object. It is passed as a slot prop and also given as a param to the tick event.

The countdown prop contains the values for the countown, as well as formatted text that can be used for display. The countdown data object is structured as follows

{
  remainingSeconds: { value: Number, text: String },
  remainingMinutes: { value: Number, text: String },
  remainingHours: { value: Number, text: String },
  remainingDays: { value: Number, text: String },
  remainingWeeks: { value: Number, text: String },
  remainingMonths: { value: Number, text: String },
  remainingYears: { value: Number, text: String },
}

Sample key values may are

remainingYears: { value: 0, text: '0 years' },
remainingDays: { value: 1, text: '1 day' },
remainingSeconds: { value: 54, text: '54 seconds' },

Sample Usage

vue-countdown can be used in 2 ways. You can either use slots to render out the countdown, or provide no slot and listen to the tick event to get countdown updates and do whatever you need to.

With slots

<vue-countdown
  :end-date-time="endDateTime">
  <template
    v-slot:default="{ countdown }">
    {{ countdown }}
  </template>
</vue-countdown>

With event

<vue-countdown
  :end-date-time="endDateTime"
  @tick="onTick">
...
onTick(countdown) {
  ...
}

License

See License.md