-
Notifications
You must be signed in to change notification settings - Fork 373
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
Add radio group controls for enums (#989) #1029
Conversation
1c9c733
to
38a273c
Compare
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.
This looks good, but is the vanilla renderer missing?
if (!visible) { | ||
style.display = 'none'; | ||
} | ||
const inputLabelStyle: { [x: string]: any } = { |
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.
Do we need this label style?
packages/examples/src/rule.ts
Outdated
@@ -41,7 +41,7 @@ export const schema = { | |||
}; | |||
|
|||
export const uischema = { | |||
type: 'HorizontalLayout', | |||
type: 'VerticalLayout', |
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.
I'd rather a new, explicit example for demonstrating the radio button group and revert this change.
FormLabel | ||
} from '@material-ui/core'; | ||
|
||
export class MaterialRadioGroupControl extends Control<ControlProps, ControlState> { |
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.
Do we have a vanilla version of this?
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.
Pushed new commit containing vanilla renderer as well.
expect(radioButtons.length).toBe(4); | ||
let currentlyChecked = _.filter(radioButtons, radio => radio.checked); | ||
expect(currentlyChecked.length).toBe(1); | ||
expect(currentlyChecked[0].value).toBe('D'); |
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.
We tested this expectation in the test before this one. Perhaps remove the assertions here and rename the tests accordingly. This test should only whether the binding works as intended.
38a273c
to
c9b25fe
Compare
General comment: |
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.
The Material Control is ok.
But the FormLabel is much bigger then all other labels in the form. Could you look into it?
Shouldn't we display Material and Vanilla RadioGroup in the same way?
Material is showing the options as row, and vanilla as column.
{computeLabel(isPlainLabel(label) ? label : label.default, required)} | ||
</label> | ||
|
||
<form> |
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.
why wrap in a form?
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.
I replaced it with a div, needed for styling.
{ | ||
options.map(optionValue => | ||
( | ||
<div> |
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.
why wrap each input into an own div?
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.
Because we need to return an input and a label.
import { VanillaControlProps } from '../index'; | ||
import { addVanillaControlProps } from '../util'; | ||
|
||
export class RadioGroupControl extends Control<VanillaControlProps, ControlState> { |
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.
In my opinion this can be a field, at least in the way it is currently implemented
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.
Discussed it with Edgar, we left it as a control for now.
c9b25fe
to
77d6d63
Compare
It is the same in the material examples: the FormLabel is big and does not change size when a value is selected in the radio group.
I fixed it in the new commit. |
- add new controls and tests
77d6d63
to
446d018
Compare
Adds MaterialRadioGroupControl and vanilla RadioGroupControl that renders enums as radio groups.