diff --git a/components/Slider.js b/components/Slider.js index 162d16c45e..53755778ca 100644 --- a/components/Slider.js +++ b/components/Slider.js @@ -1,6 +1,6 @@ var React = require('react'); -var Nouislider = require('react-nouislider'); +var Nouislider = require('./react-nouislider/'); class Slider extends React.Component { diff --git a/components/react-nouislider/.eslintrc b/components/react-nouislider/.eslintrc new file mode 100644 index 0000000000..127b02db4e --- /dev/null +++ b/components/react-nouislider/.eslintrc @@ -0,0 +1,7 @@ +{ + "extends": [ + "eslint:recommended", + "airbnb", + "algolia/es6" + ] +} diff --git a/components/react-nouislider/.travis.yml b/components/react-nouislider/.travis.yml new file mode 100644 index 0000000000..a82b987aaf --- /dev/null +++ b/components/react-nouislider/.travis.yml @@ -0,0 +1,16 @@ +language: node_js +node_js: + - stable +before_install: npm prune +install: npm install +script: npm test +branches: + only: + - master + - develop +# force container based infra +# http://docs.travis-ci.com/user/workers/container-based-infrastructure/#Routing-your-build-to-container-based-infrastructure +sudo: false +cache: + directories: + - node_modules diff --git a/components/react-nouislider/HISTORY.md b/components/react-nouislider/HISTORY.md new file mode 100644 index 0000000000..f82b940292 --- /dev/null +++ b/components/react-nouislider/HISTORY.md @@ -0,0 +1,8 @@ +# 1.0.1 (2015-09-12) + + * do not use JSX inside the reusable components, only React.DOM + +# 1.0.0 (2015-09-12) + + * initial + diff --git a/components/react-nouislider/LICENSE b/components/react-nouislider/LICENSE new file mode 100644 index 0000000000..b26a822d6d --- /dev/null +++ b/components/react-nouislider/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Algolia + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/components/react-nouislider/README.md b/components/react-nouislider/README.md new file mode 100644 index 0000000000..a0abd5bca7 --- /dev/null +++ b/components/react-nouislider/README.md @@ -0,0 +1,5 @@ +# react-nouislider + +Wraps [leongersen/noUiSlider](https://github.com/leongersen/noUiSlider) in a [react component](https://facebook.github.io/react/docs/component-api.html). + +Currently using [Algolia's fork](https://github.com/algolia/noUiSlider/tree/algolia-fork) of noUiSlider to allow setting ranges dynamically and other fixes to be merged in upstream project. diff --git a/components/react-nouislider/index.js b/components/react-nouislider/index.js new file mode 100644 index 0000000000..49762a8e69 --- /dev/null +++ b/components/react-nouislider/index.js @@ -0,0 +1,60 @@ +var React = require('react'); + +var nouislider = require('nouislider'); + +class Nouislider extends React.Component { + componentDidMount() { + var slider = this.slider = nouislider.create(React.findDOMNode(this), this.props); + + if (this.props.onSlide) { + slider.on('slide', this.props.onSlide); + } + + if (this.props.onChange) { + slider.on('change', this.props.onChange); + } + } + + componentWillReceiveProps(props) { + this.slider.updateOptions(props); + this.slider.set(props.start); + } + + componentWillUnmount() { + this.slider.destroy(); + } + + render() { + return React.DOM.div(); + } +} + +Nouislider.propTypes = { + // http://refreshless.com/nouislider/slider-options/#section-animate + animate: React.PropTypes.bool, + // http://refreshless.com/nouislider/slider-options/#section-Connect + connect: React.PropTypes.oneOfType([ + React.PropTypes.oneOf(['lower', 'upper']), + React.PropTypes.bool + ]), + // http://refreshless.com/nouislider/slider-options/#section-orientation + direction: React.PropTypes.oneOf(['ltr', 'rtl']), + // http://refreshless.com/nouislider/slider-options/#section-limit + limit: React.PropTypes.number, + // http://refreshless.com/nouislider/slider-options/#section-margin + margin: React.PropTypes.number, + // http://refreshless.com/nouislider/slider-options/#section-orientation + orientation: React.PropTypes.oneOf(['horizontal', 'vertical']), + // http://refreshless.com/nouislider/slider-values/#section-range + range: React.PropTypes.object.isRequired, + // http://refreshless.com/nouislider/slider-options/#section-start + start: React.PropTypes.arrayOf(React.PropTypes.number).isRequired, + // http://refreshless.com/nouislider/slider-options/#section-step + step: React.PropTypes.number, + // http://refreshless.com/nouislider/events-callbacks/#section-slide + onSlide: React.PropTypes.func, + // http://refreshless.com/nouislider/events-callbacks/#section-change + onChange: React.PropTypes.func +}; + +module.exports = Nouislider; diff --git a/components/react-nouislider/package.json b/components/react-nouislider/package.json new file mode 100644 index 0000000000..e302fe7d63 --- /dev/null +++ b/components/react-nouislider/package.json @@ -0,0 +1,37 @@ +{ + "name": "react-nouislider", + "version": "1.0.1", + "description": "React component wrapping leongersen/noUiSlider", + "main": "index.js", + "scripts": { + "lint": "./scripts/lint.sh", + "test": "npm run lint" + }, + "repository": "algolia/intantsearch.js", + "keywords": [ + "react", + "nouislider", + "slider", + "component", + "reactjs", + "range", + "slider" + ], + "author": "Algolia ", + "license": "MIT", + "bugs": { + "url": "https://github.com/algolia/instansearch.js/issues" + }, + "peerDependencies": { + "react": "0.13.x", + "nouislider": "git://github.com/algolia/noUiSlider.git#744f9166cf109de91de516e4af6fe3a6e4e95a7f" + }, + "homepage": "https://github.com/algolia/instansearch.js/tree/develop/components/react-nouislider#readme", + "devDependencies": { + "babel-eslint": "4.1.1", + "eslint": "1.4.1", + "eslint-config-airbnb": "0.0.8", + "eslint-config-algolia": "3.0.0", + "eslint-plugin-react": "3.3.2" + } +} diff --git a/components/react-nouislider/scripts/lint.sh b/components/react-nouislider/scripts/lint.sh new file mode 100755 index 0000000000..c41db44ee5 --- /dev/null +++ b/components/react-nouislider/scripts/lint.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e # exit when error + +printf "\nLint\n" + +eslint . --quiet diff --git a/package.json b/package.json index 2cc9b7c5a5..0989f7559c 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "browser": { "lodash": "lodash-compat" }, + "repository": "algolia/intantsearch.js", "devDependencies": { "babel": "5.8.23", "babel-eslint": "4.1.1", @@ -47,13 +48,13 @@ }, "dependencies": { "algoliasearch": "3.7.8", - "algoliasearch-helper": "2.3.0", + "algoliasearch-helper": "2.3.5", "classnames": "2.1.3", "hogan.js": "3.0.2", "lodash": "3.10.1", + "nouislider": "git://github.com/algolia/noUiSlider.git#744f9166cf109de91de516e4af6fe3a6e4e95a7f", "raw-loader": "0.5.1", "react": "0.13.3", - "react-nouislider": "1.0.0", "to-factory": "1.0.0" }, "license": "MIT"