-
Notifications
You must be signed in to change notification settings - Fork 1
/
components.jsx
45 lines (42 loc) · 1.35 KB
/
components.jsx
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
var Components = Components || {};
Components.SelectDropdown = React.createClass({
getDefaultProps: function () {
return {
options: [],
className: ""
};
},
getInitialState: function () {
this.value = this.props.defaultValue || this.options[0];
return {};
},
componentDidMount: function () {
},
render: function () {
var options = this.props.options.map(function (option) {
return (<option key={option} >{option}</option>)
}.bind(this));
return (<select defaultValue={this.props.defaultValue} className={this.props.className} onChange={this.handleChange}>{options}</select>);
},
handleChange: function (e) {
var node = React.findDOMNode(this);
this.value = node.value;
if (this.props.onChange)
this.props.onChange(node.value);
}
});
Components.FileList = React.createClass({
getInitialState: function () {
return { files: Data.files };
},
render: function () {
var options = this.state.files.map(function (file) {return file.title});
return (
<div>
<p> Examples:
<Components.SelectDropdown options={options} defaultValue={this.props.defaultValue} onChange={this.props.onClick} />
</p>
</div>
);
},
});