GithubHelp home page GithubHelp logo

robertqin86 / react-stopwatch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saeta-eth/react-stopwatch

0.0 0.0 0.0 2.85 MB

A Stopwatch Component built on top of React.

License: MIT License

JavaScript 100.00%

react-stopwatch's Introduction

react-stopwatch

A Stopwatch Component built on top of React.

Travis npm package Coveralls

Demo

Installation

First, install the component:

yarn add react-stopwatch

or

npm install react-stopwatch --save

Usage

import * as React from 'react';
import ReactStopwatch from 'react-stopwatch';

const Stopwatch = () => (
  <ReactStopwatch
    seconds={0}
    minutes={0}
    hours={0}
    limit="00:00:10"
    onChange={({ hours, minutes, seconds }) => {
      // do something
    }}
    onCallback={() => console.log('Finish')}
    render={({ formatted, hours, minutes, seconds }) => {
      return (
        <div>
          <p>
            Formatted: { formatted }
          </p>
          <p>
            Hours: { hours }
          </p>
          <p>
            Minutes: { minutes }
          </p>
          <p>
            Seconds: { seconds }
          </p>
        </div>
      );
    }}
   />
);

export default Stopwatch;

Properties

  • seconds: Integer. Needs to be between 0 >= seconds <= 60. (Required)
  • minutes: Integer. Needs to be between 0 >= minutes <= 60. (Required)
  • hours: Integer. Needs to be 0 >= hours. (Required)
  • limit: String. Need to have the following format XX:XX:XX. (Optional)
  • withLoop: Boolean. If it is true when the watch is equal to limit, it makes a loop. (Optional)
  • autoStart: Boolean. Start counting time. Default: true (Optional)
  • onCallback: Function. If you need to do something when the watch is equal to limit. (Optional)
  • onChange: Function. It returns the values each second. (Optional)

Made with ❤ by

License

MIT license. Copyright © 2018.

react-stopwatch's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar robertqin86 avatar slorenzo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.