forked from gre/multi-slider
-
Notifications
You must be signed in to change notification settings - Fork 6
/
example.js
65 lines (57 loc) · 1.44 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var React = require("react/addons");
var MultiSlider = require(".");
var packageJson = require("./package.json");
window.Perf = React.addons.Perf;
function hslPalette (n,s,l) {
var c = [];
for (var i=0; i<n; ++i) {
c.push("hsl("+~~(255*i/n)+","+(s||"50%")+","+(l||"50%")+")");
}
return c;
}
var Example = React.createClass({
getInitialState: function () {
return {
values: [48,29,23]
};
},
onChange: function (values) {
this.setState({
values: values
});
},
render: function () {
var colors = ["#FCBD7E","#EB9F71","#E6817C"];
return <div style={{ fontFamily: "sans-serif" }}>
<p>
<h1>{packageJson.name}</h1>
<h2 style={{ color: "#555" }}>{packageJson.description}</h2>
<pre><code>values={JSON.stringify(this.state.values)} colors={JSON.stringify(colors)}</code></pre>
<MultiSlider
colors={colors}
values={this.state.values}
onChange={this.onChange}
/>
</p>
<hr />
<p style={{width:"400px"}}>
<MultiSlider
defaultValues={[8, 1]}
/>
</p>
<p style={{width:"400px"}}>
<MultiSlider
colors={hslPalette(4, "70%", "60%")}
defaultValues={[1, 2, 8, 1]}
/>
</p>
<p style={{width:"400px"}}>
<MultiSlider
colors={hslPalette(8, "70%")}
defaultValues={[3,4,5,6,4,5,6,7]}
/>
</p>
</div>;
}
});
React.render(<Example />, document.body);