Git Product home page Git Product logo

time-input's Introduction

time-input

A keyboard friendly react component for capturing time

features

  • small UI surface area (just a form input)
  • keyboard friendly (can type times, use up and down keys to go forwards and backwards in time, can tab between time groups)
  • simple api (infers most options from value, e.g. 24hr time or 12hr, whether to display seconds and milliseconds)
  • easy going UX: ignores invalid input and simply skips over separator if omitted
  • no dependencies
  • 95% test coverage

installation

npm install time-input

usage

var ReactDom = require('ReactDom')
var TimeInput = require('time-input')

function render (value) {
  ReactDom.render((
    <TimeInput value={value} onChange={render}/>
  ), document.body)
}

render()

valid formats

/*
 * '12:00'
 * '12:00 AM'
 * '12:00:00'
 * '12:00:00:000 AM'
*/

run tests

npm test

demo

link

time-input's People

Contributors

alanclarke avatar janv avatar mattliving avatar radumardale avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

time-input's Issues

UX Questions

Hi @alanclarke, thank you for putting out this library - seems very useful.

As I began implementing, I noticed a few things which I wanted to bring up -

  1. Support for placeholder: I feel like if you don't have a value to initialize with, showing a placeholder would be good user experience. The placeholder could be time or a string (like 'enter time').

  2. Guides: This is especially useful when one begins to type, as it guides the user. So, lets say a user starts entering the number I am thinking of being able to show the separator and no text (or grayed out text). This, in conjunction with the a placeholder time makes for a good user experience as the placeholder doesn't disapper but just grays out acting as a guide.

  3. When we enter the two digits for the hours, I feel like the cursor should move past the separator seeing how it moved to the next digit previously (when you enter the first hour digit).

  4. I noticed that the input has type=text. I wonder if it would be more semantic to have it be type=time?

Thank you!

Deprecations warnings ([email protected])

Hello!

Recently React 15.5 was released, and with it come some deprecations for React.createClass and React.propTypes. At present it looks like time-input is still using the deprecated API - causing warnings to be emitted to the JS console and when running tests. Would it be possible to update to the new API? Happy to provide a PR.

Disable Backspace

For my project I wanted to disable backspace completely. How do I do it?

Allow implementors to provide their own `validate()` function

The validate() function that's provided only allows for a very specific timestamp format, specifically timestamps with leading zeroes. It would be great if a validate={} prop could be passed that would allow the implementor to provide their own validator.

Better UX flow for hour input

When the first input is greater than one, like '5', it should move it to become '05:' and position it after the colon.

Is this project still being maintained?

  • There's no license specified in this project and the issue for that hasn't been answered. #29
  • The demo link is not working. #32
  • There's a serious bug (IMO) that hasn't been answered #34

These lead to my doubt about the maintenance status of this project. I'm willing to help if you need some more maintainer.

Also, @radumardale has made some great work improving this project in his fork (https://github.com/radumardale/react-keyboard-time-input). Perhaps you two might consider merging these two projects together.

License

Hello, I'd like to know is it possible to add license to the project?

Custom className on input element.

Hi there.
I would be great if one could define a className for the input element, as well as the wrapping div. This would make it easier to use with Bootstrap etc.

Thanks.

Custom input

This component could allow the input component customization by props.

Example:

const MyCustomInput = (props) => <input data-custom-attribute="custom" {...props} />;
return <TimeInput inputComponent={MyCustomInput} />

What do you think? I could create a pull request with this suggestion if you agree it.

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.