coffeekraken-s-countdown-component v1.0.2
Coffeekraken s-countdown-component
Table of content
- Demo
- Install
- Get Started
- Digit
- Active class
- Step classes
- Javascript API
- Sugar Web Components Documentation
- Browsers support
- Code linting
- Contribute
- Who are Coffeekraken?
- Licence
Install
npm install coffeekraken-s-countdown-component --save
Get Started
First, import the component into your javascript file like so:
import SCountdownComponent from 'coffeekraken-s-countdown-component'
Then simply use it inside your html like so:
<s-countdown end-timestamp="2999999999">
<span s-countdown-years></span> Years
<span s-countdown-months></span> Months
<span s-countdown-days></span> Days
<span s-countdown-hours></span> Hours
<span s-countdown-minutes></span> Minutes
<span s-countdown-seconds></span> Seconds
</s-countdown>
Digit
Each countdown elements like [s-countdown-years]
, [s-countdown-hours]
, etc... will contain his remaining digit. This digit will be wrapped inside a span
that will have these classes:
.s-countdown-digit-container
: Applied on the parent element.s-countdown-digit
: The main class applied during the whole life of the digit..s-countdown-digit--out
: The class applied on the digit that need to get out.
Note that the new digit will be added when the previous one has finished his
out
animation/transition.
Active class
An active class will be applied on the element itself during the countdown and removed at the end. This is useful if you want to hide the countdown when it's finished.
.active
: Applied on the component itself during the countdown
Step classes
Step classes are an interesting concept. There are classes applied depending on the number of seconds remaining in the countdown. By default, these are the step classes registered:
stepClasses: {
week1: 3600 * 24 * 7,
day1: 3600 * 24,
hour1: 3600,
minutes30: 60 * 30,
minutes10: 60 * 10,
minutes5: 60 * 5,
minute1: 60
},
Thie mean that the these classes will be applied on the countdown:
.week1
: Applied when the countdown is less than 1 week left.day1
: Applied when the countdown is less than 1 day left.hour1
: Applied when the countdown is less than 1 hour left.minutes30
: Applied when the countdown is less than 30 minutes left.minutes10
: Applied when the countdown is less than 10 minutes left.minutes5
: Applied when the countdown is less than 5 minutes left.minute1
: Applied when the countdown is less than 1 minute left
You can as well configure that by setting the props.stepClasses
property
Browsers support
IE / Edge | Firefox | Chrome | Safari |
---|---|---|---|
IE11+ | last 2 versions | last 2 versions | last 2 versions |
As browsers are automatically updated, we will keep as reference the last two versions of each but this component can work on older ones as well.
The webcomponent API (custom elements, shadowDOM, etc...) is not supported in some older browsers like IE10, etc... In order to make them work, you will need to integrate the corresponding polyfill.
Code linting
This package uses some code linting rules. Here's the list:
- StandardJS for javascript files
- Stylelint with stylelint-config-standard for
scss
files
Your commits will not been accepted if the code style is not respected!
Contribute
This is an open source project and will ever be! You are more that welcomed to contribute to his development and make it more awesome every day. To do so, you have several possibilities:
Who are Coffeekraken
We try to be some cool guys that build some cool tools to make our (and yours hopefully) every day life better.
More on who we are
License
The code is available under the MIT license. This mean that you can use, modify, or do whatever you want with it. This mean also that it is shipped to you for free, so don't be a hater and if you find some issues, etc... feel free to contribute instead of sharing your frustrations on social networks like an asshole...