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

[Emotion] Convert EuiIcon #5967

Merged
merged 30 commits into from
Jun 28, 2022
Merged

[Emotion] Convert EuiIcon #5967

merged 30 commits into from
Jun 28, 2022

Conversation

miukimiu
Copy link
Contributor

@miukimiu miukimiu commented Jun 14, 2022

Summary

This PR converts EuiIcon to Emotion.

  • I'm using withEuiTheme, WithEuiThemeProps so that I can pass the theme to emotion
  • Searched for euiIcon- to see if there was any usage and I could only find euiIcon-loaded being used in tests.
  • Because the file icon.tsx was too large due to the typeToPathMap object, I decided to move this object to its own file src/components/icon/icon_map.ts.
  • Some tests were updated (cached icons). Thanks, @constancecchen!
  • This PR doesn't convert the EuiToken to Emotion. I added a new entry in [Meta][CSS-in-JS] Component conversions #5685 to follow up on it.

Loading

The isLoading icon borders radius was updated to euiTheme.border.radius.small

icon-loading@2x

Checklist

  • Checked 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 any docs examples
  • Added or updated jest and cypress tests
  • [ ] Checked for breaking changes and labeled appropriately
  • [ ] Checked for accessibility including keyboard-only and screenreader modes
  • [ ] Updated the Figma library counterpart
  • A changelog entry exists and is marked appropriately

Things to look out for when moving styles

  • [ ] Anything in the backlog that could be a quick fix for that component?
  • [ ] Convert global Sass vars to JS version like sizing
  • [ ] Convert component-specific Sass vars to exported JS versions
  • [ ] Convert side specific padding, margin, and position to -inline and -block (Logical properties)
  • Reduce specificity where possible (usually by reducing class name chaining)
  • [ ] Use gap property to add margin between items if using flex
  • Can any still existing .js files be converted to TS?
  • All animations or transitions are wrapped in euiCanAnimate

QA

  • Does the output CSS match the previous CSS / as expected
  • Does the rendered class read as expected

{
// The app icon only gets the .euiIcon--app class if no color is passed or if color="default" is passed
'euiIcon--app': isAppIcon && !appIconHasColor,
'euiIcon-isLoading': isLoading,
'euiIcon-isLoaded': !isLoading && neededLoading,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In use in Kibana for tests.

Copy link
Member

Choose a reason for hiding this comment

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

Can we opt to replace this with a data-is-loaded attribute instead of a className (same for data-is-loading), and change the Kibana CSS overrides to target that data selector instead of the class?

@kibanamachine
Copy link

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

1 similar comment
@kibanamachine
Copy link

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

- by checking for loading state rather than a basic component check
@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

Comment on lines 41 to 46
// TODO find out if this is still valid
// this focus was added 5 years ago
&:focus {
opacity: 1; // We often hide icons on hover. Make sure they appear on focus.
/* background: $euiFocusBackgroundColor; */
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does anyone know if this is still valid?

This how it would look like:
Screenshot 2022-06-21 at 15 08 21

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's safe to remove the background-color.

Copy link
Member

Choose a reason for hiding this comment

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

is the opacity: 1 still valid as well? I can't personally think of a single scenario where we hide an icon on hover?

@kibanamachine
Copy link

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

@miukimiu miukimiu marked this pull request as ready for review June 21, 2022 15:43
@kibanamachine
Copy link

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

@miukimiu miukimiu requested review from cee-chen and cchaos June 24, 2022 12:57
Copy link
Member

@cee-chen cee-chen 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 looking great so far! I pushed up some minor cleanup, but there's a few larger items (that may need more discussion or that you may have other feelings on) that I think still need to be addressed:

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@miukimiu
Copy link
Contributor Author

Thanks, @constancecchen for reviewing this PR and for the cleanup. I went through your review and addressed the issues:

  • Re-added the custom colors as style 3b57233
  • Deleted $euiIconLoadingOpacity and $euiIconColors. And moved the icon sizes variables to the _form.scss file 509b890
  • Removed the euiIcon-isLoaded className in favor of a data attribute. I also added a data attribute for isLoading. I'm just not sure about the tests. I tried to update them. Let me know if it is the right way. ae58c9d
  • Removed &:focus { opacity: 1 } 193d9e3
  • Renamed the underscore functions and variables from icon.styles.ts 591acab

Co-authored-by: Constance <constancecchen@users.noreply.github.com>
@cee-chen
Copy link
Member

Fantastic work with the changes!! :) Just 2 small suggestions/comments left and I think this is good to go!

@kibanamachine
Copy link

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

miukimiu and others added 2 commits June 28, 2022 17:47
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
Copy link
Member

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

🎉 This looks really great! Thanks so much for taking my feedback!

@miukimiu miukimiu enabled auto-merge (squash) June 28, 2022 17:19
@kibanamachine
Copy link

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

1 similar comment
@kibanamachine
Copy link

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

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