0.1.0 • Published 1 year ago

react-digital-timer v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

React-digital-timer

npm.io

FunctionalityControl by buttons / keyboard
set up timetype in count down in the timer frame
startPlay button / press Enter
pausePause button / press Enter
resetReset button / ctrl/command + Enter

Installation

Install via NPM

npm i react-digital-timer

Import

import { Timer } from 'react-digital-timer';

Example

import React from 'react';
import ReactDOM from 'react-dom';
import { Timer } from '../dist';
import './App.css';

const INIT_TIME = {
    hour: 0,
    minute: 0,
    second: 624
}

function App() {
    return (
        <div className="App">
            <header className="App-header">
                <p className="App-message">Digital Timer</p>
                <Timer
                    countDownTime={INIT_TIME}
                    onComplete={() => console.log('time\'s up')}
                />
            </header>
        </div>
    );
}

ReactDOM.render(<App />, document.getElementById('root'));

Config Params

FieldTypeDescriptionExample
countDownTimeobjectinitial timer (after reset, the timer will also start with this initial time period){ hour: 0, minute: 20, second: 0 } // 20 minutes
showTimeUpMessagebooleanto enable browser notification when timer count down finishedtrue
disableUpdateByKeyboardbooleanto disable controling timer by keyboard. Enable this config to run a fixed time count downtrue
disableControlPanelbooleanto disable controling timer by buttons (control buttons will be hided)true
digitClassNamestringto customize timer styles by your own CSS classnamelarge-digit (you can find this in the example css file)
iconClassNamestringto customize control button styles by your own CSS classnamelarge-btn (you can find this in the example css file)
onCompletefunctioncallback function fires when timer count down finished() => console.log('time\'s up')
onTickfunctioncallback function fires during every second's count down(secondsLeft: number) => console.log(secondsLeft)

Credits

Icons downloaded from icons8.com

License

MIT