0.1.10 • Published 2 years ago

@logustra/vountdown v0.1.10

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Vountdown

Codecov Downloads Version Gzip Size Licence Code Style Commitizen

A minimalist countdown component for vue.js 2-3

Getting Started

NPM

npm install @logustra/vountdown

To make @logustra/vountdown work for Vue 2, you need to have @vue/composition-api installed.

npm install @vue/composition-api

CDN

Drop <script> inside your HTML file.

Vue 3

<script src="https://cdn.jsdelivr.net/npm/vue@3.2.31"></script>
<script src="https://cdn.jsdelivr.net/npm/@logustra/vountdown"></script>

Vue 2

<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
<script src="https://cdn.jsdelivr.net/npm/@vue/composition-api@1.4.9"></script>
<script src="https://cdn.jsdelivr.net/npm/@logustra/vountdown"></script>

Usage

Setup

Vue 3

import { createApp } from 'vue'
import Vountdown from '@logustra/vountdown'
import App from './app.vue'

const app = createApp(App)
app.use(Vountdown)

Vue 2

import Vue from 'vue'
import CompositionAPI from '@vue/composition-api'
import Vountdown from '@logustra/vountdown'

Vue.use(CompositionAPI)
Vue.use(Vountdown)

Basic Usage

<template>
  <vountdown 
    :time="new Date('Jan 1, 2024').getTime()" 
    v-slot="{ 
      days,
      hours,
      minutes,
      seconds 
    }"
  >
    {{ days }} days {{ hours }} hours {{ minutes }} minutes {{ seconds }} seconds.
  </vountdown>
</template>

Demo →

On-demand

<template>
  <button @click="auto = true">
    <vountdown
      :auto="auto"
      :time="10000"
      v-slot="{
        isStart,
        isDone,
        seconds,
      }"
    >
      <template v-if="isStart && !isDone">
        Send again {{ seconds }} seconds later
      </template>
      <template v-else> Send OTP </template>
    </vountdown>
  </button>
</template>

<script>
import { ref } from 'vue'
export default {
  setup() {
    const auto = ref(false)

    return {
      auto
    }
  },
}
</script>

Demo →

API

Props

NameTypeDefaultDescription
tagstringspanThe tag name of the component root element
autobooleantrueStart countdown automatically
timenumber5000The time (in milliseconds) to count down from

Events

NameParametersListen toDescription
start(value)@startEmitted after the countdown starts
stop(value)@stopEmitted after the countdown has stopped
done(value)@doneEmitted after the countdown has endded

Slots

NameDescription
daysSlot to display days
hoursSlot to display hours
minutesSlot to display minutes
secondsSlot to display seconds
isStartSlot to display when the countdown starts
isStopSlot to display when the countdown has stopped
isDoneSlot to display when the countdown has endded

Cheer me on

If you like my works, you can cheer me on here 😆

    🇮🇩 Trakteer     🌍 Ko-Fi

License

MIT License © 2022 Faizal Andyka

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago