Code Monkey home page Code Monkey logo

react-semantic-ui-range's Introduction

react-semantic-ui-range

This is a React Component range slider for Semantic UI

It is developed based on https://github.com/tyleryasaka/semantic-ui-range but has additional functionalities

The demo for the project can be found here: https://iozbeyli.github.io/react-semantic-ui-range/

The original library was using jQuery so I changed the parts that use jQuery to make it more compatible with React.

  npm i react-semantic-ui-range

Sample Usage

import React, { useState } from "react";
import { Slider } from "react-semantic-ui-range";
import "semantic-ui-css/semantic.min.css";
import { Label, Grid, Input } from "semantic-ui-react";

const App = props => {
  const [value, setValue] = useState(5);

  const settings = {
    start: 2,
    min: 0,
    max: 10,
    step: 1,
    onChange: value => {
      setValue(value);
    }
  };

  const handleValueChange = e => {
    let value = parseInt(e.target.value);
    if (!value) {
      value = 0;
    }
    setValue(e.target.value);
  };

  return (
    <Grid>
      <Grid.Column width={16}>
        <Slider value={value} color="red" settings={settings} />
      </Grid.Column>
      <Grid.Column width={16}>
        <Input placeholder="Enter Value" onChange={handleValueChange} />
        <Label color="red">{value}</Label>
      </Grid.Column>
    </Grid>
  );
};

export default App;

react-semantic-ui-range's People

Contributors

hufftheweevil avatar iozbeyli avatar jeremiahchurch avatar nihey avatar supersnager 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-semantic-ui-range's Issues

Adding a background color to slider

Hello, I am not sure if this is currently possible, but I would like to change the default background from grey to black or something else. Would be nice if this can be a prop in a later implementation.

Have a great day :)

Slider does not update when controlled

When initializing the slider value via hardcoded value in settings.start, it renders the slider with that value as expected. But when I pass in a value from state that is fed by a text input field, it has no effect.

onChange obfuscating event call object

onChange within the slider settings returns the slider value without a mechanism for getting the event call object.

I would expect to be able to access the event object such as:

(e, {value})=>handleSliderChange(e,value)

The simple reason being that I am using the slider within another object where I need to do event.preventDefault().

Window mouseout issue

Hi,

there is a issue with mouseout event.

Steps to reproduce:

  1. Press left btn over slider
  2. Leave slider
  3. Release left btn
  4. Move mouse back on slider
  • slider is still active

I think it is fixed in #4 can you please merge?

Slider doesn't update when switching between two datasets.

I have two objects that I'm switching between, and the slider pulls it's starting position from a property of the objects. Changing from one object to another changes the data the slider is pulling, but the position of the slider doesn't update to reflect the change. The labels in these screenshots are pulling from the same data and property so the data is definitely updating.

screen shot 2018-09-13 at 12 29 59 pm

screen shot 2018-09-13 at 12 30 07 pm

Here's how I've coded the slider for reference

<div id="weight-slider-div">
    <div id="weight-slider">
         <Slider
             color="blue"
             settings={{
                  min: 0,
                  max: 10,
                  start: question.weight,
                  step: 1,
                  onChange: (value) => { this.setQuestionWeight(question, value, pendingWeighting) },
             }}
        />
     </div>
     <Label color="blue">{question.weight}</Label>
 </div>

Discrete "mode" not locking to position

Great work!

However, I can't get the discrete mode (setting step: 1) to get the slider to lock to position (as the first item in the demo: https://iozbeyli.github.io/react-semantic-ui-range/)

Here's my code, any idea what I'm doing wrong?
<Slider color='black' inverted={false} settings={ start: this.state.value, min: 0, max: 5, step:1, onChange: (value, meta) => { console.log('test', value, meta); if (meta.triggeredByUser) { this.setState({ value: value }) } } />

Unsafe life cycle methods componentWillReceiveProps

Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

  • Move data fetching code or side effects to componentDidUpdate.
  • If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
  • Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.

Please update the following components: Slider

Multiple slider doesn't render start values

Using v0.7.0

import React, { useState } from 'react';
import { Segment } from 'semantic-ui-react';
import { Slider } from 'react-semantic-ui-range';

const FilterSlider = () => {
  const [values, setValues] = useState([0, 5000]);
  const settings = {
    start: [0, 5000],
    min: 0,
    max: 5000,
    step: 1,
    onChange: array => {
      setValues(array);
    }
  };
  return (
    <Segment>
      <Slider multiple value={values} color="teal" settings={settings} />
    </Segment>
  );
};

export default FilterSlider;

Result on first render:
image

What I expect to see
image

Disabling button and then enabling doesn't restore style

If the disabled attribute is set to true and then disabled the style components for the slider (but not the thumb knob) are lost rather than restored to what they were before being disabled.

codesandbox demonstrating issue https://codesandbox.io/s/reverent-sky-89iip?fontsize=14

I cruised through the code and didn't see any immediate reason why this might happen. I'll dig in to this next week but wanted to create an issue in case the reason might be obvious to someone else.

Thank you!

Slider fails on mobile

When emulating mobile interface on Chrome Dev Tools:
[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive.

Slider cannot be dragged, can only be clicked into place on mobile.

Slider stuck on page resize

The title says it all. It gets stuck after resizing

  • going through other elements if making the window smaller
  • not updating the thumb's relative position when making the window bigger (ie. if I make my browser window twice as big, it is going to appear as if the thumb is in the middle).

Reproducible on chrome, edge and opera

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.