Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

general export #2

Merged
merged 1 commit into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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