Giter VIP home page Giter VIP logo

Comments (5)

mpowaga avatar mpowaga commented on June 12, 2024

I'm thinking about adding two new components to be used as a children of slider. One will be just a handle and a second to fill the space between handles. So the user can easily create range slider with two handles or even more. Something like this:

<Slider>
  <Handle min={0} max={100} />
  <span style={{ backgroundColor: 'red' }} />
  <Handle min={0} max={100} />
</Slider>

You can use div but then you loose the ability to show the current value.

Default handle component is a good idea. Feel free to add it.

from react-slider.

positlabs avatar positlabs commented on June 12, 2024

I implemented this in my project, in order to use html elements as handles. If props.children is a component, then it assigns props to it. There might be a better way to check if object is a component, but this works.

The default handle assignment can also be handled here.

var userHandle = this.props.children;
    if(userHandle){
      if(userHandle.props){ // check if child is a component
        userHandle.props[this.props.valuePropName] = this.state.value;
      }
    } else {
      // use default handle
    }

I do like the idea of a fillable bar, but multi-handle functionality would be better as a separate component, imo.

from react-slider.

qwtel avatar qwtel commented on June 12, 2024

I don't really know where else to put this, so it goes here.

I've built a multi slider component based on your slider (repository, demo). It can have multiple handles, draws bars between them, provides default handles if the component has no children and prevents text selection while dragging.

I tried to make it closer to the <input type="range" /> element. This means it can be used either as a "controlled" component by providing a value or more like the original slider by providing a defaultValue and using the internal state. This also removes the need to "inject" the current slider value into the props of the children which is a anti pattern in my opinion.

I'd be happy to submit a pull request, but since everything changed quite significantly and also breaks things, I'd rather ask for your opinion first.

from react-slider.

mpowaga avatar mpowaga commented on June 12, 2024

@cell303 That look really great. Bit different than my first ideas but I like similarity to range input.

Feel free to submit PR. This component isn't set in stone yet so I don't mind to break things.

from react-slider.

qwtel avatar qwtel commented on June 12, 2024

I think this is all implemented now

from react-slider.

Related Issues (20)

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.