Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/radzionc/increaser-timer
Timer with React
https://github.com/radzionc/increaser-timer
react styled-components
Last synced: 11 days ago
JSON representation
Timer with React
- Host: GitHub
- URL: https://github.com/radzionc/increaser-timer
- Owner: radzionc
- License: mit
- Created: 2018-11-28T17:39:12.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-20T05:46:49.000Z (about 1 year ago)
- Last Synced: 2024-08-08T15:46:48.035Z (3 months ago)
- Topics: react, styled-components
- Language: JavaScript
- Homepage: https://radzionc.github.io/increaser-timer/
- Size: 1010 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# increaser-timer
>
[![NPM](https://img.shields.io/npm/v/increaser-timer.svg)](https://www.npmjs.com/package/increaser-timer)
![alt text](https://cdn-images-1.medium.com/max/2000/1*FSPccrD-tfhlbniF8sJluQ.gif)
## [Demo](https://radzionc.github.io/increaser-timer/)
## Install
```bash
npm install --save increaser-timer
```## Usage
```jsx
import React from 'react'import Timer from 'increaser-timer'
const Container = ({ children }) => (
{children}
)// optional
export theme = {
textColor: 'white',
timeFillColor: '#FFDC00',
circleColor: 'rgba(255, 255, 255, 0.15)'
}class Example extends React.Component {
constructor(props) {
super(props)
const startTime = Date.now()
this.state = {
startTime,
duration: 1,
timeNow: startTime
}
setInterval(() => {
const timeNow = Date.now()
const { startTime, duration } = this.state
this.setState({ timeNow })
if (timeNow - startTime > duration * 60 * 1000) {
this.setState({ startTime: timeNow })
}
}, 500)
}render() {
const { duration, startTime, timeNow } = this.state
return (
)
}
}
```
## [Blog Post](https://geekrodion.com/blog/timer-react)## License
MIT © [RodionChachura](https://geekrodion.com)