Skip to content

Conversation

@SMaxOwok
Copy link
Contributor

  • Adds labels
  • Adds children
  • Adds styles

Copy link

@davidmferris davidmferris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really nice. Just one minor comment for you about directory structure of the story.

import { withA11y } from '@storybook/addon-a11y';
import { withKnobs, text, boolean } from '@storybook/addon-knobs';

import RadioButton from '../src/RadioButton/RadioButton';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THIS
IS
HUGE

Wanna pull a Rachel and clean up the whole repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very much, but lemme do that on a separate PR, so this can get merged and I can keep trucking on my actual task...

/>

{props.label && (
<span className="RadioButton__label">{props.label}</span>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something, but when should this be used over:

  <FormControlLabel
    labelHtmlFor="radio"
    text="Labeled radio button"
  >
    <RadioButton id="radio" name="radio" />
  </FormControlLabel>

This is another story under "Form Control Label" that looks quite similar to the new Radio button stories

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah you're right. I forgot about FormControlLabel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, interesting. Let me look at how the radio button changes would work with this as the wrapper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm not sure this really works...

The order of the markup has to change for the radio button with children, since the children have to come after the form label. That said, I do think it's valid that RadioButton has its own markup and styles as it's a specific use of a label and not necessarily in line with a generic form label.

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW when I was doing the form styles I always kinda wondered why we had FormControlLabel and would generally think this would be part of the RadioButton styles. I don't know that flexing and padding are form specific.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I bit that from MUI. I was really trying to keep the base components as generic as possible so that we wouldn't have to add this label markup for each type of form control.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is separate from InputLabel right? I don't know that I fully understand the use case for this vs. adding a label to the radio button. Should this be use the FormControlLabel?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah InputLabel is meant for like text/number type inputs. FormControlLabel is for radios, switches, and checkboxes (the latter 2 which don't exist yet). Perhaps the naming could use some improvement since it's definitely not obvious

import { withA11y } from '@storybook/addon-a11y';
import { withKnobs, text, boolean } from '@storybook/addon-knobs';

import RadioButton from '../src/RadioButton/RadioButton';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THIS
IS
HUGE

Wanna pull a Rachel and clean up the whole repo?


RadioButton.defaultProps = {
bordered: false,
children: null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works and is typically what I do. Is there a reason to prefer undefined here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it lines up more with if the prop weren't in this list at all. It seems weird to put a value in here (even if it's null) vs. leaving it with the true default of undefined.


RadioButton.propTypes = {
bordered: PropTypes.bool,
children: PropTypes.node,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW per discussions with Darien it's not uncommon to not declare the children propType when you're just going to render it. I think there is a convention that you only declare the children prop when you want to make it required or set some specific rules on it (e.g. only a string) since it's such a weird prop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with it either way. I think it's useful to know the component can take children, since it's not necessarily obvious a radio button would, but I don't feel strongly. Would you rather it be removed?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, for some reason I thought if you rendered children without declaring the prop type you'd get a warning, but if not I'm fine either way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, though I may be wrong. I don't have a strong opinion here but if no one else cares I'd say let's remove it.


RadioButton.defaultProps = {
bordered: false,
children: null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it lines up more with if the prop weren't in this list at all. It seems weird to put a value in here (even if it's null) vs. leaving it with the true default of undefined.


RadioButton.propTypes = {
bordered: PropTypes.bool,
children: PropTypes.node,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, though I may be wrong. I don't have a strong opinion here but if no one else cares I'd say let's remove it.

@rsaris rsaris merged commit 129db71 into master Apr 1, 2020
@rsaris rsaris deleted the feature/bordered-radio branch April 1, 2020 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants