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 🙏

© 2025 – Pkg Stats / Ryan Hefner

vue-chronometer

v1.0.0

Published

A Vue.js component that takes an integer of seconds and counts down by one every second

Downloads

57

Readme

vue-chronometer

A simple Vue.js component that takes an integer of seconds and counts down by one every second, displaying the time in HH:MM:SS format.

npm npm bundle size npm GitHub

Table of Contents

Installation

Install the package using npm:

npm install vue-chronometer

Requirements

  • Vue.js 3.x

This component uses the Composition API and <script setup> syntax, which requires Vue 3.

Usage

You can register vue-chronometer globally or locally within your Vue application.

Global Registration

// main.js
import { createApp } from 'vue';
import App from './App.vue';
import VueChronometer from 'vue-chronometer';

const app = createApp(App);

app.component('VueChronometer', VueChronometer);

app.mount('#app');

Local Registration

<!-- YourComponent.vue -->
<template>
  <div>
    <!-- Use the component here -->
    <VueChronometer :etaSeconds="300" />
  </div>
</template>

<script>
import VueChronometer from 'vue-chronometer';

export default {
  components: {
    VueChronometer,
  },
};
</script>

Props

etaSeconds (required)

  • Type: Number
  • Required: true
  • Description: The starting number of seconds for the countdown timer.

Example

Here's a basic example of how to use vue-chronometer in a component:

<template>
  <div>
    <h1>Countdown Timer Example</h1>
    <VueChronometer :etaSeconds="timeLeft" />
    <button @click="resetTimer">Reset Timer</button>
  </div>
</template>

<script>
import VueChronometer from 'vue-chronometer';

export default {
  components: {
    VueChronometer,
  },
  data() {
    return {
      timeLeft: 3600, // Starts from 1 hour
    };
  },
  methods: {
    resetTimer() {
      this.timeLeft = 3600; // Resets back to 1 hour
    },
  },
};
</script>

Explanation:

  • Importing the Component: We import VueChronometer from the installed package.
  • Registering the Component: We add it to the components object.
  • Using the Component: We use <VueChronometer :etaSeconds="timeLeft" /> in the template.
  • Dynamic Prop: The timeLeft data property is bound to the etaSeconds prop, allowing us to control the timer dynamically.
  • Reset Functionality: The resetTimer method resets the timeLeft, which restarts the countdown.

Customization

Styling

The component renders a <span> element containing the formatted time. You can style it using CSS classes or inline styles.

<template>
  <div>
    <VueChronometer :etaSeconds="600" class="countdown" />
  </div>
</template>

<style>
.countdown {
  font-size: 2em;
  color: #ff0000;
}
</style>

Event Handling (Future Feature)

Currently, the component does not emit any events. In future updates, I plan to add events like onFinish to notify when the countdown reaches zero.

Custom Formatting (Future Feature)

I also plan on being able to pass in a prop to change the formatting of the displayed time.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the Repository: Click the "Fork" button at the top right of the repository page.

  2. Clone Your Fork: Clone your forked repository to your local machine.

    git clone https://github.com/yourusername/vue-chronometer.git
  3. Create a Feature Branch:

    git checkout -b feature/my-new-feature
  4. Make Your Changes: Implement your feature or bug fix.

  5. Commit Your Changes:

    git commit -am 'Add new feature'
  6. Push to the Branch:

    git push origin feature/my-new-feature
  7. Submit a Pull Request: Go to the original repository and open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Additional Information

  • Dynamic Updates: If the etaSeconds prop is updated, the timer will reset and start counting down from the new value.
  • Zero Handling: When the countdown reaches zero, it stops and displays 00:00:00.

Support

If you encounter any issues or have questions, please open an issue on the GitHub repository.