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-addressable-sliders

v0.1.6

Published

Multi-range slider made with react with addressable and identifiable ranges

Downloads

45

Readme

react-addressable-sliders

npm npm bundle size

Description

React Slider with support for multi ranges. Each range has its own id and so can be easily addressed and identified.

Installation

yarn add react-addressable-sliders

Usage example

import React from 'react';
import { MultiRangeSlider } from 'react-addressable-sliders';

const MySlider = () => {
    const myCallback = (range, newValue, thumb) => console.log(range, newValue, thumb);
    return (
        <MultiRangeSlider
            ranges={{
                'range-id-1': {
                    id: 'range-id-1',
                    max: 10,
                    min: 1,
                    name: 'range-name',
                    parent_id: 'id-of-slider',
                    ref_id: 'id-of-object-represented-by-this-range',
                    trackColor: '#DD2C00'
                },
                'range-id-2': {
                    id: 'range-id-2',
                    max: 100,
                    min: 50,
                    name: 'other-range-name',
                    parent_id: 'id-of-slider',
                    ref_id: 'id-of-other-object-represented-by-this-range',
                    immovable: {
                        left: true,
                    }
                },
            }}
            emitChanges={myCallback}
        />
    );
};

Props

| Name | Required | Type | Description | | ----------------------|----------------- | ----------| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ranges | True | Object | Define the ranges shown in the slider. Each object must have at least the fields max min id.The trackColor can be used to specify the color of the range's track.The ref_id can be used to reference the id of an object you want to reference.The parent_id can be used in case you need to use multiple sliders and you want them to interact with each other.immovable is an Object that has fields left and right. When they are True the respective range extreme cannot be moved. | | extremes | False | Object | Force the extremes of the range to be the ones you specify. This Object has two fields: max and min, they control their respective extreme. | | emitChanges | False | Function| (range, newValue, thumb) => Void This callback fires onMouseUp. It lets you update the correct range object: its arguments are: range which has the old range data, newValue, which is the new value of the range after the change and thumb, which can be a string (max or min) and tells you which extreme was changed. | | checkContinuousChanges| False | Function| (range, newValue, thumb) => Void This callback works the same as emitChanges but it fires for every change, also during the sliding of the values. It is handy for checks that cannot be done only onMouseUp. | | emptySpaceCallback | False | Function| (clickInfo) => Void This callback fires when clicking the slider where no range is present.The argument clickInfo has relativePercentage, which gives you a number between 0 and 100 that tells you which part of the slider you clicked, relativeValue, which tells you the value of the slider at that particular point and closestRanges which is an Object with fields min and max which tells you where are the closest ranges' extremes on the left and on the right of the clicked point. | | labelFormatFun | False | Function| (value) => formatted_value With this function you can change the format of the slider values.For example if you want dates you can use timestamps as the slider value and then set this to value => moment.utc(value, 'X').format(dateFormatWithTimeShorter). | | options | False | Object | Lets you configure aspects of the slider with specific keys (see below).|

options fields

  • getTrackColor is a function (range) => hex str which lets you assign colors to the ranges' track for each range.
  • isImmovable is a function (range) => Boolean which gives you more control on which ranges are immovable. The ranges that return True are rendered immovable.
  • rangePadding is a Number that controls by how much at least the ranges have to be separated. Default is 0.
  • sliderValueStyles is an Object that lets you customize the style of the slider values under both extremes.
  • sliderNameStyles is an Object that lets you customize the style of the ranges' name.
  • sliderNamePopupStyles is an Object that lets you customize the style of the ranges' name when they popup onMouseHover.
  • sliderThumbStyles is an Object that lets you customize the style of the ranges' thumbs.
  • isVertical is a Boolean that lets you set the slider in a vertical position.

Typescript

From version 0.0.27 onwards this library is made in Typescript