Skip to content
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 CheckablePanel component #2555

Merged
merged 24 commits into from
Dec 2, 2019
Merged

Conversation

zinckiwi
Copy link
Contributor

@zinckiwi zinckiwi commented Nov 22, 2019

Summary

Adds a CheckablePanel component that wraps radio buttons or checkboxes and allows nested/child content to be more easily associated with the parent checkable.

In the course of working on this, also updated form/checkbox/* to TS.

It's been a while since I've done anything from scratch here so just yell if there's something I missed.

image

image

Checklist

  • Checked in dark mode
  • Checked in mobile
  • Checked in IE11 and Firefox
  • Props have proper autodocs
  • Added documentation examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@zinckiwi zinckiwi changed the title Checkable panel Add CheckablePanel component Nov 22, 2019
@zinckiwi
Copy link
Contributor Author

Not sure what to do with the build failure (on warning):

/app/src/components/datagrid/data_grid_schema.tsx
370:6  warning  React Hook useMemo has missing dependencies: 'definedColumnSchemas' and 'inMemory'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

Only showed up when I pulled in latest master so I'd figured it was something funky with my node_modules or something as yarn ran clean.

@cchaos
Copy link
Contributor

cchaos commented Nov 22, 2019

@zinckiwi Sorry it's taking so long to get to your PR. There were quite a few large ones going in this week. But if you rebase with master that warning should be gone now. I'll be sure to start reviewing this first thing next week.

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

@zinckiwi This is a really great start and thank you for converting the checkbox files to TS! You'll want to be sure to add a changelog entry for that work as well.

Design

My initial thought is the extra blue accents (border and shaded background) is a bit too much. I'm looking at this compared to the switches below and the radios above in the examples and I think just letting the checkbox and radio show the selected state.

Screen Shot 2019-11-25 at 11 07 53 AM

Disabled state

This probably needs to be more noticeably disabled. For instance in the radios and switches we decrease the contrast of the label.

Screen Shot 2019-11-25 at 11 11 01 AM

Code

Looks really good! Thank you for using SASS variables and correct BEM naming schemes.

My only concern with the layout is the use of EuiFlexGroup/Item. We find using this component within our own EUI components can become brittle and it's a bit safer to just write our own elements and flex styles.

I left a few other comments directly.

Docs

Question about the second example. I'd assume that for the nested example, the nested radio group should be disabled if the actual Option two is not checked? Otherwise users could select options but they never get applied since the parent isn't selected.

Screen Recording 2019-11-25 at 11 26 AM

Accessibility

Looks pretty good. Mainly got one Axe error around the fact that there's no unifying label for the top level radio group. Either we can just add another part to the docs example or we may need to create a EuiCheckablePanelGroup to enforce a unifying label.

Screen Shot 2019-11-25 at 11 29 12 AM


@zinckiwi Also feel free to hand this off to us if you don't have time for these updates. Or if you want to do some but not all that's perfectly fine too.

@@ -86,29 +118,7 @@ export class EuiCheckbox extends Component {

invalidateIndeterminate() {
if (this.inputRef) {
this.inputRef.indeterminate = this.props.indeterminate;
this.inputRef.indeterminate = Boolean(this.props.indeterminate);
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of casting here, let's add indeterminate: false to the defaultProps definition

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 still complains due to the entry in the Props type being optional -- leaving this as-is unless you know a way around that. I'd have thought it would parse defaultProps and figure out that by runtime it can't be undefined, but apparently not?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well that's annoying. You can tell TypeScript the value really does exist by appending an ! at the end of the property access:

this.inputRef.indeterminate = this.props.indeterminate!;

@zinckiwi
Copy link
Contributor Author

Thanks for the reviews both, will get to work on the changes. Quickly about the nested radios, perhaps not the greatest example but I wanted to show that nested controls would be a good use case, not necessarily do the whole show/hide implementation. Can revise that if you think it's misleading.

@gjones
Copy link
Contributor

gjones commented Nov 25, 2019

@cchaos, only minor comment on my end is the lack of an active/selected state (outside the radio itself). I understand where you're coming from when comparing them to the switches and other radio groups. I think we were looking at these as something closer to EuiCard-selectable than a regular form element.

I'm cool removing the border colour, but when it comes to EuiCard we at least tend to increase the shadow, show some extra depth to allow it to stand out at a glance, is this something we could think about here?

I'm just trying to ensure that if we have 6 or 8 of these, potentially two per row, that the contrast between selected and unselected is enough to instantly identify it even if there are eye catching elements (ie. product logos) inside the contents of the Panel itself.

That said, I trust your opinion on this, and how it fits into the greater framework. Just wanted to bring up a use case that may not have been considered.

@cchaos
Copy link
Contributor

cchaos commented Nov 25, 2019

@gjones I think it comes down to context and documentation then. You compare it to the selectable type of EuiCard and not as just another version of a radio/checkbox group. I think that's a big distinction that we will have to make clear to the consumer and there are just two tasks involved to do that.

  1. Change the name of this component to align with "Card" instead of "Panel". EuiCheckablePanel --> EuiCheckRadioCard (or something... naming is hard).
  2. Move both the component and the docs example to be nested in the card folders.

This should gear this new component's purpose more towards layout than a type of form element.

The only oddity then would be the inconsistency in selected state colors, but changing this component's border to green becomes too crayola when mixed with the blue of the radio.

Screen Shot 2019-11-25 at 17 35 25 PM

@zinckiwi
Copy link
Contributor Author

@cchaos Are those two bullets requests, then? No problem, but want to confirm given that currently it's very much an extension to form elements (to the point of passing the props through).

@chandlerprall yeah, my goof on the typing... that was why I converted checkbox to begin with, just blanked when I was actually finished with it!

@zinckiwi
Copy link
Contributor Author

Alternatively, we can keep this Cloud-side for now until there's another would-be consumer of it. I can pull the new stuff out and not waste the TSing of checkbox if you'd like to save the prospect of CheckablePanel (or whatever it becomes) for another day.

@cchaos
Copy link
Contributor

cchaos commented Nov 26, 2019

@zinckiwi Don't worry about my last comment. I can do some re-organizing of docs / components to fit with how we expect the usage afterward. You can also keep the blue border/shading in for the selected state as well.

@zinckiwi
Copy link
Contributor Author

Okay, I think that's all the feedback dealt with. Would appreciate another pass!

zinckiwi and others added 6 commits November 27, 2019 13:59
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

I have pushed 5 commits (details in the commit messages). Mainly moving this new component to /card and renaming it EuiCheckableCard but also simplifying a few styles and adding a11y fixes.

Then I just have one last comment about the changelog, but I'm a 👍

@cchaos cchaos requested a review from chandlerprall November 27, 2019 21:26
Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

One small change requested ( left it in #2555 (comment) ), otherwise changes LGTM; pulled & tested locally.

@chandlerprall
Copy link
Contributor

@zinckiwi one more thing I caught while switching branches - you removed @types/sinon from the package.json but it is still listed in the yarn.lock. Please re-run yarn and commit the updated yarn.lock file.

@zinckiwi zinckiwi merged commit 705de53 into elastic:master Dec 2, 2019
@zinckiwi zinckiwi deleted the checkable-panel branch December 2, 2019 21:31
thompsongl added a commit that referenced this pull request Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants