-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eyes only, webpack build in error
- Loading branch information
vvo
committed
Sep 14, 2015
1 parent
cd25b7f
commit 229bb02
Showing
7 changed files
with
301 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var React = require('react'); | ||
|
||
var Nouislider = require('react-nouislider'); | ||
|
||
class Slider extends React.Component { | ||
|
||
// we are only interested in rawValues | ||
handleChange(formattedValues, handleId, rawValues) { | ||
this.props.onChange(rawValues); | ||
} | ||
|
||
render() { | ||
return ( | ||
<Nouislider | ||
{...this.props} | ||
onChange={this.handleChange.bind(this)} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
Slider.propTypes = { | ||
onSlide: React.PropTypes.func, | ||
onChange: React.PropTypes.func, | ||
range: React.PropTypes.object.isRequired, | ||
start: React.PropTypes.arrayOf(React.PropTypes.number).isRequired | ||
}; | ||
|
||
module.exports = Slider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
var React = require('react'); | ||
|
||
var utils = require('../lib/widget-utils.js'); | ||
|
||
/** | ||
* Instantiate a slider based on a numeric attribute | ||
* @param {String|DOMElement} options.container Valid CSS Selector as a string or DOMElement | ||
* @param {String} options.facetName Name of the attribute for faceting | ||
* @return {Object} | ||
*/ | ||
function rangeSlider({ | ||
container = null, | ||
facetName = null | ||
}) { | ||
var Slider = require('../components/Slider'); | ||
|
||
var containerNode = utils.getContainerNode(container); | ||
|
||
return { | ||
getConfiguration: () => ({ | ||
disjunctiveFacets: [facetName] | ||
}), | ||
_currentValues: { | ||
min: -Infinity, | ||
max: Infinity | ||
}, | ||
_refine(helper, stats, newValues) { | ||
var min = helper.state.getNumericRefinement(facetName, '>='); | ||
var max = helper.state.getNumericRefinement(facetName, '<='); | ||
|
||
this._currentValues = { | ||
min: Math.max(min && min.length && min[0] || 0, stats.min), | ||
max: Math.min(max && max.length && max[0] || Infinity, stats.max) | ||
}; | ||
|
||
if (this._currentValues.min !== newValues[0] || this._currentValues.max !== newValues[1]) { | ||
this._currentValues = { | ||
min: newValues[0], | ||
max: newValues[1] | ||
}; | ||
|
||
helper.clearRefinements(facetName); | ||
helper.addNumericRefinement(facetName, '>=', this._currentValues.min); | ||
helper.addNumericRefinement(facetName, '<=', this._currentValues.max); | ||
helper.search(); | ||
} | ||
}, | ||
render(results, state, helper) { | ||
var stats = results.getFacetStats(facetName); | ||
|
||
React.render( | ||
<Slider | ||
start={[this._currentValues.min, this._currentValues.max]} | ||
range={{min: stats.min, max: stats.max}} | ||
onChange={this._refine.bind(this, helper, stats)} | ||
/>, | ||
containerNode | ||
); | ||
} | ||
}; | ||
} | ||
|
||
module.exports = rangeSlider; |