-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
boolean widget & some documentation (#396)
- Loading branch information
1 parent
982d1db
commit aac5339
Showing
4 changed files
with
39 additions
and
0 deletions.
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
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,23 @@ | ||
import React, { PropTypes } from 'react'; | ||
import ImmutablePropTypes from "react-immutable-proptypes"; | ||
import Switch from 'react-toolbox/lib/switch'; | ||
|
||
export default class BooleanControl extends React.Component { | ||
render() { | ||
const { value, field, forId, onChange } = this.props; | ||
return ( | ||
<Switch | ||
id={forId} | ||
checked={value === undefined ? field.get('defaultValue', false) : value} | ||
onChange={onChange} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
BooleanControl.propTypes = { | ||
field: ImmutablePropTypes.map.isRequired, | ||
onChange: PropTypes.func.isRequired, | ||
forID: PropTypes.string.isRequired, | ||
value: PropTypes.bool, | ||
}; |
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