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 Suggest Item #2090

Merged
merged 32 commits into from
Jul 19, 2019
Merged

Add Suggest Item #2090

merged 32 commits into from
Jul 19, 2019

Conversation

andreadelrio
Copy link
Contributor

Summary

Add SuggestItem component. Covers #2061

Checklist

  • This was checked in mobile
  • This was checked in IE11
  • This was checked in dark mode
  • Any props added have proper autodocs
  • Documentation examples were added
  • A changelog entry exists and is marked appropriately
    - [ ] This was checked for breaking changes and labeled appropriately
  • Jest tests were updated or added to match the most common scenarios
    - [ ] This was checked against keyboard-only and screenreader scenarios

@andreadelrio andreadelrio changed the title Suggest item Add Suggest Item Jul 3, 2019
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.

The layout prop documentation is a bit confusing for me -

Use layout to change the distribution of the EuiSuggestItem elements.

Suggests to me that the order of the content will change, or its organization will be different, as opposed to simply expanding to fit content. This should probably call out or demonstrate that inline doesn't just allow longer labels but will shorten to fit smaller content as well.

Also, I don't find the inline and setColumns values meaningful. Is this functionality expected to be expanded in the future?

src-docs/src/views/suggest_item/suggest_item_example.js Outdated Show resolved Hide resolved
@andreadelrio
Copy link
Contributor Author

@chandlerprall Good point about the layout prop. So that prop was initially called expandLongLabel. However, while discussing with Dave he suggested to make it more flexible and call it layout instead. My understanding is that we could eventually support more layouts. For example something like this:

image

@snide is this inline with what you were proposing?

@snide
Copy link
Contributor

snide commented Jul 5, 2019 via email

@thompsongl
Copy link
Contributor

Just a note: I've committed to helping @andreadelrio convert this to TypeScript after we're set with the functionality and design of the component. So this is purposefully TS-less, and there will (likely) be a follow-up PR.

@chandlerprall
Copy link
Contributor

Dave he suggested to make it more flexible and call it layout instead. My understanding is that we could eventually support more layouts. For example something like this:

I agree with allowing future options with an enum of values instead of a boolean. However, I don't find the current choices of inline and setColumns to be meaningful to an engineer using this component - I think the names are too attached to the actual CSS/DOM implementation instead of the presentation intent.

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.

The main things I notice is that we should try to avoid the hard-coded width of the label and figure out a more flexible way to handle the sizing.

Also, the contrast in dark mode is not great.

We'll have to figure out a better way to handle the "faded" version of the color.

src-docs/src/routes.js Outdated Show resolved Hide resolved
src-docs/src/views/suggest_item/suggest_item_example.js Outdated Show resolved Hide resolved
src-docs/src/views/suggest_item/suggest_item_example.js Outdated Show resolved Hide resolved
src-docs/src/views/suggest_item/suggest_item_example.js Outdated Show resolved Hide resolved
src/components/suggest_item/_suggest_item.scss Outdated Show resolved Hide resolved
src/components/suggest_item/suggest_item.js Outdated Show resolved Hide resolved
src/components/suggest_item/suggest_item.js Outdated Show resolved Hide resolved
src/components/suggest_item/suggest_item.js Outdated Show resolved Hide resolved
@cchaos
Copy link
Contributor

cchaos commented Jul 8, 2019

One other visual thing: Can you find a way to get the baselines of the two columns to line up?

@cchaos
Copy link
Contributor

cchaos commented Jul 8, 2019

Looks like there's some instances that also need a key prop as error in console shows:

Screen Shot 2019-07-08 at 12 17 22 PM

@andreadelrio
Copy link
Contributor Author

andreadelrio commented Jul 11, 2019

Thanks everyone for your feedback so far. Here are some things I'm considering:

  1. To ensure good color contrast: only allow the consumer to choose from a limited set of colors (mix of our core palette plus some viz colors). This is following what we currently do for EuiToken. That way we'd have something like:

image

  1. For the layout prop to have two values fixedWidthLabel and expandLabel. Alternative name for layout could be labelDisplay. By default, when SuggestItem doesn't have a description the layout goes to expandLabel. See:

image

  1. Where to place SuggestItem in the docs? SuggestItem will be part of SuggestInput so, as suggested, we could place it under Forms > Suggest Input > Suggest Item. Since SuggestInput will be a later and separate PR we could just hide SuggestItem's docs for now.

Please send your comments!

@cchaos
Copy link
Contributor

cchaos commented Jul 11, 2019

  1. only allow the consumer to choose from a limited set of colors

Yep, I think that's a good approach. We could still allow someone to pass a particular color, but that color would then be the full background color and we'd just calculate if the text should be white or black. Similar to how we handle in EuiAvatar.

  1. Alternative name for layout could be labelDisplay

I like that name better. You can even simplify the options to be:

labelDisplay: 'fixed' | 'expand'
  1. Where to place SuggestItem in the docs?

I'd assume, based on our previous patterns, that you'd have one large encompassing EuiSuggest (folder name: suggest) where the EuiSuggestInput is the actual component housing the search bar and then EuiSuggest would be combining EuiSuggestInput with a EuiPopover housing the EuiSuggestItems.

@chandlerprall
Copy link
Contributor

Fully agree with Caroline on 2!

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.

This is already getting much simpler. I think you're in the home stretch. The first big PR always takes a while.

src/components/suggest_item/_suggest_item.scss Outdated Show resolved Hide resolved
src/components/suggest_item/_suggest_item.scss Outdated Show resolved Hide resolved
src/components/suggest_item/_variables.scss Outdated Show resolved Hide resolved
@andreadelrio
Copy link
Contributor Author

I went ahead and replaced the color options to use the vis palette only. I think it looks better! Thanks for that suggestion.

Regarding the expand label situation. I decided to add a min-width:50% to the label that way if the "expanded" label would be less that 50% it would still take up 50%. See results below. First item has labelDisplay='fixed' and second and third items have labelDisplay='expand'

image

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.

Final comments, I swear. Mostly around docs and prop descriptions/requirements. I labelled a few optional. But functionally, stylistically, SASS-wise it all looks great!!!

src-docs/src/views/suggest/suggest_item.js Outdated Show resolved Hide resolved
src-docs/src/views/suggest/suggest_item.js Outdated Show resolved Hide resolved
src-docs/src/views/suggest/suggest_item.js Outdated Show resolved Hide resolved
src-docs/src/views/suggest/suggest_item.js Show resolved Hide resolved
src/components/suggest_item/_suggest_item.scss Outdated Show resolved Hide resolved
src/components/suggest_item/suggest_item.js Outdated Show resolved Hide resolved
src/components/suggest_item/suggest_item.js Outdated Show resolved Hide resolved
src/components/suggest_item/suggest_item.js Show resolved Hide resolved
src/components/suggest_item/suggest_item.js Outdated Show resolved Hide resolved
src/components/suggest_item/suggest_item.js Outdated Show resolved Hide resolved
@myasonik
Copy link
Contributor

I haven't had a chance to thoroughly review this yet but I wanted to check if keyboard and screen reader testing was on your radar? I noticed that it's crossed out but, especially as a reusable pattern, I think we have to make sure we're raising the bar on one-off implementations.

@cchaos
Copy link
Contributor

cchaos commented Jul 18, 2019

@myasonik Yes, it typically is an item we make sure to check off vs cross-off. But this is a smaller piece of a large component that we're piece-mealing in. When the full component is in review we'll be sure to do a full keyboard nav test as well.

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.

Looks great! Just saw one duplicated class name and you'll need a changelog entry.

<span className={`euiSuggestItem__type ${colorClass}`}>
<EuiIcon type={type.iconType} />
</span>
<span className={`euiSuggestItem__label ${labelDisplayClass}`}>
Copy link
Contributor

Choose a reason for hiding this comment

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

You no longer need euiSuggestItem__label here because you've added it to labelDisplayClass at line 41.

Screen Shot 2019-07-18 at 18 13 07 PM

Suggested change
<span className={`euiSuggestItem__label ${labelDisplayClass}`}>
<span className={labelDisplayClass}>

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 ask, but otherwise LGTM

text: (
<div>
<p>
<EuiCode>EuiSuggest</EuiCode> description goes here.
Copy link
Contributor

Choose a reason for hiding this comment

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

As this is merging into master, can we comment out this first section or update it with a coming soon message?

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 the idea is just to comment it out from the routes file for now instead.

@andreadelrio andreadelrio merged commit 5643b3c into elastic:master Jul 19, 2019
@snide snide mentioned this pull request Jul 22, 2019
7 tasks
@thompsongl thompsongl mentioned this pull request Oct 9, 2019
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.

6 participants