0.1.4 • Published 4 years ago

@shwilliam/react-rubber-slider v0.1.4

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

\<RubberSlider/>

Demo screengrab

Installation

$ npm i @shwilliam/react-rubber-slider
$ npm i @reach/slider d3

Usage

import React, {useState} from 'react'
import RubberSlider from '@shwilliam/react-rubber-slider'
import '@shwilliam/react-rubber-slider/dist/styles.css'

export const App = () => {
  const [value, setValue] = useState(0.5)

  return <RubberSlider width={250} value={value} onChange={setValue} />
}

@shwilliam/react-rubber-slider demo

Component API

PropTypeRequiredDefault
namestringfalseundefined
idstringfalse'rubber-slider'
valuenumberfalse0
onChangefunctionfalseno-op
widthnumberfalse200
heightnumberfalse100
maxnumberfalse100
minnumberfalse0
stepnumberfalse1
easeFunctionfunctionfalsed3.easeElastic
easeDurationnumberfalse700
onDragStartfunctionfalseno-op
onDragfunctionfalseno-op
onDragEndfunctionfalseno-op

Styling

Override the default slider styles by targeting the following:

.rubber-slider {
}
.rubber-slider-input {
}
.rubber-slider-pseudo-track {
}
.rubber-slider-pseudo-handle {
}

Development

To start local development, simply install npm dependencies (npm i) and run npm run build:watch to watch ts files in src/. Built files can be found in dist/.

Testing

To run existing tests locally, run the command npm t, or npm run test:watch for watch mode.

Demo

To run the demo, ensure you have run the build script and have a dist dir in your project root. Then run npm run demo:setup to copy these to the demo and npm run demo to start it locally.

Contributing

This project is open to and encourages contributions! Feel free to discuss any bug fixes/features in the issues. If you wish to work on this project:

  1. Fork this project
  2. Create a branch (git checkout -b new-branch)
  3. Commit your changes (git commit -am 'add new feature')
  4. Push to the branch (git push origin new-branch)
  5. Submit a pull request!