npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bonobolabs/time-picker

v0.1.1

Published

Accessible and customisable React time picker

Downloads

54

Readme

TimePicker

An accessible and customisable React TimePicker.

This is an opinionated, simplified fork of rc-time-picker with the following changes:

Styling

  • very minimal styling (see codesandbox for example of how we're using it in our app)
    • uses styled components instead of less
    • uses flexbox for columns instead of floating & fixed widths
  • the panel now expands inline instead of popping above the content
  • in collapsed state the element is now a div (instead of an input). AM/PM is separated so it can be styled independently:

Collapsed

Expanded

Accessibility improvements

  • keyboard navigation
    • press space/enter to open or select options
    • press escape to close panel
    • change time and navigate between lists with arrow keys
  • focus trap
    • focus stays within open time picker panel and doesn't get lost to background content
    • when the panel is expanded the input is focused, and focus is returned when collapsed
  • uses ul/li elements with radiogroup/radio roles - so when you select hour 3 screenreader will read "3, radio, 1 of 12, Select hour, radio group".
    • This also allows for navigating between radio groups (from "Select hour" to "Select minute") in Group mode.
    • aria-checked is used to indicate the currently selected element
  • screen-reader friendly aria-labels with no leading zeros (so screenreader says "one" instead of "zero one"), and labels on radio groups (e.g. "Select AM or PM").
  • aria-invalid is used to indicate incorrectly formatted time (when entering time manually)

New fields

  • allowStepInputOnly (defaults to true) - only allow entering times that match shown times (hourStep, minuteStep, secondStep) into the input.
    • Set to false to allow entering e.g. "1:23 pm", even if minuteStep is set to 15.

Demo

Demo

https://codesandbox.io/s/styled-time-picker-13h6y

Install

npm install @bonobolabs/time-picker

or

yarn add @bonobolabs/time-picker

Usage

import TimePicker from '@bonobolabs/time-picker'
import ReactDOM from 'react-dom'
import styled from 'styled-components'

const StyledTimePicker = styled(TimePicker)`
  /* your CSS here */
`

const App = () => (
  <StyledTimePicker
    showSecond={false} // hide seconds
    use12Hours={true} // show AM/PM
    value={moment()} // show current time
    onChange={date =>
      // on change log the updated time to the console
      console.log(date.format('LTS'))
    }
    // set a custom aria-label when collapsed
    ariaLabelFunc={time => `A ${time} reminder is set, editable`}
  />
)

ReactDOM.render(<App />, container)

See TimePicker.jsx and rc-time-picker docs for options.

License

MIT