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

[EuiIcon] Fix two-tone icons to inherit parent color when nested in specific components #4760

Merged
merged 13 commits into from
Apr 30, 2021

Conversation

miukimiu
Copy link
Contributor

@miukimiu miukimiu commented Apr 27, 2021

Summary

Closes #4739 and closes #4755.

This PR fixes a bug in EuiIcon where two-tone icons were not inheriting their parent color when nested in specific components. The two-tone colors would always prevail and consumers would expect these icons to behave more similarly to normal glyphs.

So to make the icon behave similarly to normal glyphs inside specific components like EuiBadge, EuiCallOut, or EuiContextMenu we pass color="inherit" to enforce two-tone icons to inherit the parent colors and this way they don't get the .euiIcon--app. So they just behave as consumers expect.

As we can see in the following image, these icons now behave as expected. They inherit their parent color. So if there's a disabled state, a link color, the icon just inherits it.

icons-app@2x

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
  • Added documentation
  • Checked Code Sandbox works for the any docs 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

@miukimiu miukimiu changed the title [EuiIcon] Fix two-tone icons colors to inherit parent color when nested in specific components [EuiIcon] Fix two-tone icons to inherit parent color when nested in specific components Apr 27, 2021
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4760/

@miukimiu miukimiu marked this pull request as ready for review April 27, 2021 11:05
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4760/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4760/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4760/

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.

Code looks great. I think the inherit prop is extremely clear what it will do (even if it's the same a default for normal icons).

My only comments are around documentation. We need it to be very clear which components force their color inheritance. I think that's just in the form of adding an example to each of the other components affected. Like changing one of these context menu items to use the app icon.

Screen Shot 2021-04-29 at 16 45 33 PM

src/components/list_group/list_group_item.tsx Show resolved Hide resolved
Comment on lines +703 to +704
// The app icon only gets the .euiIcon--app class if no color is passed or if color="default" is passed
'euiIcon--app': isAppIcon && !appIconHasColor,
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

src-docs/src/views/icon/icon_example.js Outdated Show resolved Hide resolved
src-docs/src/views/icon/icon_colors_apps.js Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4760/

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.

🎉 Thanks for updating all those other examples. It'll be super clear now how those icons are handled, and even helps us continue to test those other usages. Just had a couple final things.

src-docs/src/views/badge/badge_with_icon.js Outdated Show resolved Hide resolved
src-docs/src/views/button/button_empty.js Show resolved Hide resolved
src-docs/src/views/button/button_icon.js Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
src/components/list_group/list_group_item.tsx Outdated Show resolved Hide resolved
src/components/list_group/list_group_item.tsx Outdated Show resolved Hide resolved
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4760/

@miukimiu
Copy link
Contributor Author

Thanks @cchaos. 🙏🏽

I went through the final suggestions. Can you take another look?

@miukimiu miukimiu requested a review from cchaos April 30, 2021 19:02
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!!!

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4760/

@miukimiu miukimiu merged commit aa71e7a into elastic:master Apr 30, 2021
cchaos added a commit that referenced this pull request May 4, 2021
…pecific components (#4760)

* Making app icons to inherit parent color when nested in specific components

* Improving example

* CL

* Improving comment msg

* Adding color inherit

* Checking if icon has color applied

* Color inherit example

* Addressing PR review

* WIP

* CL and list group icon props

Co-authored-by: Caroline Horn <[email protected]>
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.

App icons don't consider disabled state App icon colors don't match button text color
3 participants