1.1.2 • Published 5 years ago

tri-slider v1.1.2

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

tri-slider

A React component of a three-way slider.

When to use

If three parts need to be balanced, it can be convenient to use this slider.

Demo

Click here

Props

PropTypeargsDescription
knobnodeComponent or element to use for the knob.
sizenumberThe width of the element. Excluding 10px margin.
backgroundColorstringThe color of the triangle.
styleobjectThe style of the parent of the triangle.
isThreeWayboolA toggle between a two way and three way slider.
onChangefunction*A,B,CFires while the element is being changed.
valuearrayThe value of the slider components. A,B,C Should add up to one
labelAfunctionAThe text on the label of angle A
labelBfunctionBThe text on the label of angle B
labelCfunctionCThe text on the label of angle C

Note: "A" is left-bottom, "B" is right-bottom, "C" is (center-)top.

Example

Basic (uncontrolled)

import Slider from 'tri-slider';

render(
  <Slider onChange={e => console.log(e)} />,
  document.querySelector('#root')
);

Controlled

import React, { Component } from 'react';
import { render } from 'react-dom';

import Slider from 'tri-slider';

class Demo extends Component {
  state = {
    threeWay: true,
    value: [0.33, 0.33, 0.33],
  };
  render() {
    return (
      <div>
        <h1>tri-slider Demo</h1>
        <button
          onClick={() => {
            this.setState({ threeWay: !this.state.threeWay });
          }}
        >
          toggle Three-way
        </button>
        <Slider
          isThreeWay={this.state.threeWay}
          onChange={e => {
            this.setState({ value: e });
          }}
          value={this.state.value}
        />
      </div>
    );
  }
}

render(<Demo />, document.querySelector('#demo'));
1.1.2

5 years ago

1.1.1

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago