Skip to content

Commit

Permalink
Merge pull request #2 from medilies/npm-package
Browse files Browse the repository at this point in the history
general export
  • Loading branch information
medilies authored Jun 17, 2022
2 parents 486eb8e + 7cc001c commit 173c0c3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.github*
webpack.config.js
examples*
.gitignore
38 changes: 24 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Countdown JS

A simple and lightweight library for adding coundowns to the frontend.
A simple and lightweight library for adding coundowns to the frontend in declarative way.

## Features

Expand All @@ -9,23 +9,33 @@ A simple and lightweight library for adding coundowns to the frontend.
- Custom update interval.
- Custom callback action.

## Usage
## Setup

Add the script to your project.
### NPM

```html
<script src="/countdown.js" defer></script>
```text
npm i @medilies/countdown-component
```

```js
import { autoStartCountown } from "@medilies/countdown-component/lib/countdownComponent";

autoStartCountown();
```

### CDN

## Usage

Write a `div` or many with the following attributes.

| Attribute | Description | |
| ------------------ | ------------------------------------------------------------------------------------------------- | ----------- |
| autoCountdown | Starts the countdown on page load | Requried |
| countdown-duration | Sets the coundown duration (an integer in seconds) | Required |
| countdown-format | Sets the display format (see the formatting table) | Required |
| countdown-tick-size | Sets the update interval size (a timespan) | Default: 1s |
| countdown-handler | Takes as value the name the function you defined to call as an action in the end of the countdown | Optional |
| Attribute | Description | |
| ------------------- | ------------------------------------------------------------------------------------------------- | ----------- |
| autoCountdown | Starts the countdown on page load | Requried |
| countdown-duration | Sets the coundown duration (an integer in seconds) | Required |
| countdown-format | Sets the display format (see the formatting table) | Required |
| countdown-tick-size | Sets the update interval size (a timespan) | Default: 1s |
| countdown-handler | Takes as value the name the function you defined to call as an action in the end of the countdown | Optional |

Note _a timespan is a string that is in the format "2m", "1h5s" or "2h20m40s"_

Expand Down Expand Up @@ -70,6 +80,6 @@ Note _a timespan is a string that is in the format "2m", "1h5s" or "2h20m40s"_

Any kind of contribution is very welcomed, so feel free to get in touch so I can add you to the repo :)

### Help needed
### Help needed to do

Set a github action to compile the code to ES5 and minify it.
...
2 changes: 1 addition & 1 deletion examples/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import autoStartCountown from "../lib/autoStartCountown";
import { autoStartCountown } from "../lib/countdownComponent";

// The page have divs for auto start countdowns
autoStartCountown();
3 changes: 3 additions & 0 deletions lib/countdownComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import autoStartCountown from "./autoStartCountown";

export { autoStartCountown };
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@medilies/countdown-component",
"version": "1.0.0",
"version": "1.0.1",
"description": "A simple and lightweight library for adding coundowns to the frontend.",
"main": "./dist/countdouwn.min.js",
"main": "./lib/countdownComponent.js",
"files": [
"dist"
"lib"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down

0 comments on commit 173c0c3

Please sign in to comment.