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

react-time-slider

v0.0.1

Published

React time slider component using JQuery-UI and Moment

Downloads

141

Readme

Note: This is an initial alpha. I haven't even added CSS to the demo. More to come.

Introduction

A common use case for the jQuery UI Slider is to allow the user to specify a date range which then impacts the other elements on the page.

Often, the dates impact the state of the app, which in turn is reflected in the URL via the router, though raw or formatted dates are not suitable for this purpose.

One solution is to ask the router to serialize the date into an Integer and ask the labels around the slider to format the date as desired, but the couples the two and creates extra work.

Instead, this component receives and returns Integers, allowing the user to specify a grain (annual, monthly, or daily) for the slider itself as well as the format for its labels.

Getting started

Install via npm:

npm install --save react-time-slider

Then simply require and pass configuration.

var TimeSlider = require('react-time-slider');

var Example = React.createClass({
  render: function() {
    var timeSlider = TimeSlider({
      minFrom: 201402,
      maxTo: 201411,
      initialFrom: 201404,
      initialTo: 201408,
      onChange: function(values) {
        console.log(values)
      }
    });
    return timeSlider;
  }
});

API

The component receives and returns Integers, so the grain at which the slider is set naturally impacts the other component properties.

grain (Optional Enum, default monthly)

The grain of the time slider can be set to daily, monthly, or annual.

  • If the grain is set to annual, dates will be Integers of the format YYYY.
  • If the grain is set to monthly, dates will be Integers of the format YYYYMM.
  • If the grain is set to daily, dates will be Integers of the format YYYYMMDD.

minFrom and maxTo (Required Numbers)

These properties reflect the overall valid range of the slider, passed as Integers of the specified grain. These values are immutable.

initialFrom and initialTo (Required Numbers)

These properties reflect the initial values of the range itself. They are only used in initializing the slider. Once initialized, the slider uses internal state to keep track of the current range values.

format (Optional String, default MMM YYYY)

The format property is used by Moment.js to format its labels associated with the current state of the slider.

onChange (Optional Function, default $.noop)

The slider internally handles the jQuery UI Slider onSlide event to update its labels, but the values are only returned to the caller on the Change event.

See jQuery UI Slider's documentation for more detailed event descriptions.

The function is not passed the event and values arguments, but rather just an array of length two with the from and to values as Integers of the specified grain.