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

EuiCards #385

Merged
merged 13 commits into from
Feb 13, 2018
Merged

EuiCards #385

merged 13 commits into from
Feb 13, 2018

Conversation

cchaos
Copy link
Contributor

@cchaos cchaos commented Feb 9, 2018

First pass at creating a card component.

  • A basic card requires a title and description.
  • Cards can either take an Icon in node form or Image url
  • Card footers can be any combination of nodes
  • Footers will stick to the bottom visually so all footers in a grouping of cards will line up
  • If a card's onClick attribute exists, it will apply the new isHoverable prop to the containing EuiPanel for hover effects

To do:

  • Clickable cards are focusable

screen shot 2018-02-09 at 16 05 42 pm

screen shot 2018-02-09 at 16 05 45 pm

screen shot 2018-02-09 at 16 05 52 pm

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

Chatted a bit over slack.

  1. Needs focus states to work (just needs accessible wrapper for onclick).
  2. Should add a custom validator similar to our buttons, so that you can't use icon AND image together.

}

.euiCard__image {
.euiIcon {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should add a class for this instead of overwriting through nests.

margin-bottom: $euiCardSpacing;
}

.euiImage {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

&:hover,
&:focus {
transform: translateY(-2px);
@include euiSlightShadowHover;
Copy link
Contributor

Choose a reason for hiding this comment

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

Prolly just move this a line up.

let imageNode;
if (image) {
imageNode = (
<EuiImage url={image} alt="" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe pass the title in the alt?

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 left the alt blank here on purpose since the image should not be representing content or describing something in this instance. It's strictly a visual aid to the card's title. Adding the card title to the alt will make the screen ready read the card's title twice.

};

EuiPanel.defaultProps = {
paddingSize: 'm',
hasShadow: false,
grow: true,
isHoverable: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add some auto-gen prop docs to this to explain it.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably also document this on the EuiPanel page as well. Doubtful it would be used outside of a card, but prolly a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

Blargh. I suck at GH today.

@cchaos
Copy link
Contributor Author

cchaos commented Feb 12, 2018

Address comments and open for final review.

Copy link
Contributor

@cjcenizal cjcenizal 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 fantastic! I just had one suggestion.

@@ -50,10 +52,12 @@ EuiPanel.propTypes = {
paddingSize: PropTypes.oneOf(SIZES),
grow: PropTypes.bool,
panelRef: PropTypes.func,
isHoverable: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless we can think of a situation where we want this behavior to be uncoupled from an onClick callback, then I think it's worth just renaming this to be onClick: PropTypes.func. WDYT?

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 we should pass the onClick from EuiCard onto EuiPanel?

Copy link
Contributor

@snide snide Feb 13, 2018

Choose a reason for hiding this comment

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

I can think of situations where you wouldn't want the card to bounce, but still want onClick. Common one would be W I D E P A N E L that is skinny vertically.

Hey, DO THIS THING, IM A BIG CALLOUT at the top.

Putting the hover on the card when it's such a large element is usually something you wouldn't want. Normally works better for bite-sized repeatable elements (which is the common scenario).

But you're right it's not gonna happen very often.

Copy link
Contributor

@cjcenizal cjcenizal Feb 13, 2018

Choose a reason for hiding this comment

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

I think I know what you're talking about. I've seen that pattern on the Bootstrap site. It's pretty neat though at first I didn't realize it was clickable. Maybe that pattern should require a button inside the panel instead? Or a new kind of component which has a noticeable hover state, like a background change?

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 think that's better for documenting patterns though. Large panels like jumbotrons should have buttons as actions not be an action itself.

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

Yay. Cards.

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

🌞

… if it exists

Also making Card’s text left aligned by default.
@cchaos
Copy link
Contributor Author

cchaos commented Feb 13, 2018

@cjcenizal & @snide Can you take one more look at this (mainly just that last commit).

On @cjcenizal's request, I passed the onClick handler to the EuiPanel and changed the outer element to a <button> if it has onClick. I had to add some more styles to Panel in case of this since <button>'s don't have the same inherent display properties as <div>.

Also, I realized there may be good cases for cards that have their content left aligned vs centered, so I gave it a isCentered prop. Though now that I think on it, I'm going to change that to alignment and have it take 'left', 'center', or 'right' and default to 'center'.

@snide
Copy link
Contributor

snide commented Feb 13, 2018

@cchaos Looks good to me. Make your prop "textAlign" instead of "alignment" just so it's a little more specific to what it does.

I think the PanelTag bit works fine here.

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

Looks awesome!

@cchaos cchaos merged commit ebfe6fd into elastic:master Feb 13, 2018
@cchaos cchaos deleted the cards branch February 13, 2018 14:58
@snide snide mentioned this pull request Feb 13, 2018
51 tasks
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.

3 participants