Skip to content

Commit

Permalink
Cleaning up boolean value example
Browse files Browse the repository at this point in the history
  • Loading branch information
JedWatson committed Jan 31, 2017
1 parent cab0b72 commit 881873c
Showing 1 changed file with 1 addition and 53 deletions.
54 changes: 1 addition & 53 deletions examples/src/components/BooleanSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,75 +12,23 @@ var ValuesAsBooleansField = React.createClass({
{ value: true, label: 'Yes' },
{ value: false, label: 'No' }
],
matchPos: 'any',
matchValue: true,
matchLabel: true,
value: null,
multi: false
value: null
};
},
onChangeMatchStart(event) {
this.setState({
matchPos: event.target.checked ? 'start' : 'any'
});
},
onChangeMatchValue(event) {
this.setState({
matchValue: event.target.checked
});
},
onChangeMatchLabel(event) {
this.setState({
matchLabel: event.target.checked
});
},
onChange(value) {
this.setState({ value });
console.log('Boolean Select value changed to', value);
},
onChangeMulti(event) {
this.setState({
multi: event.target.checked
});
},
render () {
var matchProp = 'any';
if (this.state.matchLabel && !this.state.matchValue) {
matchProp = 'label';
}
if (!this.state.matchLabel && this.state.matchValue) {
matchProp = 'value';
}
return (
<div className="section">
<h3 className="section-heading">{this.props.label}</h3>
<Select
matchPos={this.state.matchPos}
matchProp={matchProp}
multi={this.state.multi}
onChange={this.onChange}
options={this.state.options}
simpleValue
value={this.state.value}
/>
<div className="checkbox-list">
<label className="checkbox">
<input type="checkbox" className="checkbox-control" checked={this.state.multi} onChange={this.onChangeMulti} />
<span className="checkbox-label">Multi-Select</span>
</label>
<label className="checkbox">
<input type="checkbox" className="checkbox-control" checked={this.state.matchValue} onChange={this.onChangeMatchValue} />
<span className="checkbox-label">Match value</span>
</label>
<label className="checkbox">
<input type="checkbox" className="checkbox-control" checked={this.state.matchLabel} onChange={this.onChangeMatchLabel} />
<span className="checkbox-label">Match label</span>
</label>
<label className="checkbox">
<input type="checkbox" className="checkbox-control" checked={this.state.matchPos === 'start'} onChange={this.onChangeMatchStart} />
<span className="checkbox-label">Only include matches from the start of the string</span>
</label>
</div>
<div className="hint">This example uses simple boolean values</div>
</div>
);
Expand Down

0 comments on commit 881873c

Please sign in to comment.