forked from JTMCaplin/DamJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatcherButton.js
More file actions
34 lines (34 loc) · 850 Bytes
/
MatcherButton.js
File metadata and controls
34 lines (34 loc) · 850 Bytes
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
define(['lib/react'], function(React) {
return React.createClass({
getInitialState: function() {
this.setFiltered();
return this.getFilteredState()
},
componentWillReceiveProps: function(props) {
this.setFiltered();
},
toggleFilter: function() {
this.props.toggleFilter();
this.setFiltered()
},
setFiltered: function() {
this.setState(this.getFilteredState());
},
getFilteredState: function() {
if (this.props.isFiltered()) {
return {
style: {backgroundColor: "lightgreen"},
openOrFiltered: "On"
};
} else {
return {
style: {backgroundColor: "lightgrey"},
openOrFiltered: "Off"
};
}
},
render: function() {
return React.DOM.button({onClick: this.toggleFilter, style: this.state.style}, this.props.buttonLabel /* + " " +this.state.openOrFiltered*/);
}
})
});