-
-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allows material BoolFields to be checkboxes or toggles #189
Conversation
…if appearance set to 'toggle'. Default or any other value is 'checkbox' (present behavior) Updated combined tests for the above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of them should be handled by ESLint, but it's not configured yet.
@@ -7,6 +7,7 @@ import {spy} from 'sinon'; | |||
import {stub} from 'sinon'; | |||
|
|||
import MaterialCheckbox from 'material-ui/Checkbox'; | |||
import MaterialToggle from 'material-ui/Toggle'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep them sorted.
@@ -1,4 +1,5 @@ | |||
import Checkbox from 'material-ui/Checkbox'; | |||
import Toggle from 'material-ui/Toggle'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep imports sorted.
@@ -11,18 +12,28 @@ const Bool = ({ | |||
name, | |||
onChange, | |||
value, | |||
appearance = 'checkbox', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Props also should be sorted.
name={name} | ||
onCheck={(event, value) => disabled || onChange(value)} | ||
ref={inputRef}{...filterDOMProps(props)} | ||
/>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things here:
- keep props sorted
- ternary should be formatted like this:
appearance === 'toggle' ? (
<Toggle
...
/>
) : (
<Checkbox
...
/>
)
Great! And I'm really glad to see, that you've written tests! |
…mbined.js Update: Formatting of ternary expression in BoolField.js
Updated. |
Yeah, I have to update ESLint finally... Thanks! |
This PR adds an appearance property to BoolField that allows rendering as a Toggle if appearance set to 'toggle'. Default or any other value is 'checkbox' (present behavior) so as to not break any existing apps.
That is,
<BoolField name='field' />
still works as it previously did by rendering a checkbox, but now you can alternatively use toggles:<BoolField name='field' appearance='toggle' />
Updated combined tests for the above (x35)
NOTE: I did not update any package version numbers.