1.0.8 • Published 6 years ago

increaser-timer v1.0.8

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

increaser-timer

NPM

alt text

Demo

Install

npm install --save increaser-timer

Usage

import React from 'react'

import Timer from 'increaser-timer'

const Container = ({ children }) => (
  <div style={{ height: '100vh' width: '100%' }}>
    {children}
  </div>
)

// 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 (
      <Timer
        theme={theme}
        wrapper={Container}
        startTime={startTime}
        duration={duration}
        timeNow={timeNow}
        showTimeInTitle={true}
        handleBeforeUnload={true}
      />
    )
  }
}

Story on Medium

License

MIT © RodionChachura

1.0.8

6 years ago

1.0.6

6 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago