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 EuiSelectable #7940

Merged
merged 10 commits into from
Aug 5, 2024
Merged

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Aug 2, 2024

Summary

Converts the baseline EuiSelectable component. Does not convert EuiSelectableTemplateSitewide, because this PR is already large enough (although most of the diffs are snapshots)

QA

General checklist

  • Browser QA
    • Checked in both light and dark modes
    • Checked in mobile
    • Checked in Chrome, Safari, Edge, and Firefox
    • Checked for accessibility including keyboard-only and screenreader modes
  • Docs site QA - N/A
  • Code quality checklist
  • Release checklist
    • A changelog entry exists and is marked appropriately.
      - [ ] If applicable, added the breaking change issue label (and filled out the breaking change checklist)
  • Designer checklist - N/A
Emotion checklist

General

  • Output CSS matches the previous CSS (works as expected in all browsers)
  • Rendered className(s) read as expected in snapshots and browsers
  • ~[ ] Checked component playground ~

Unit tests

  • shouldRenderCustomStyles() test was added and passes with parent component and any nested childProps (e.g. tooltipProps)
  • Converted Enzyme to RTL

Sass/Emotion conversion process

  • Removed component from src/components/index.scss
  • Converted all global Sass vars/mixins to JS (e.g. $euiSize to euiTheme.size.base)
  • Listed var/mixin removals in changelog
  • [ ] Added an @warn deprecation message within the global_styling/mixins/{component}.scss file
  • [ ] Removed or converted component-specific Sass vars/mixins to exported JS versions
  • [ ] Ran yarn compile-scss to update var/mixin JSON files
  • [ ] Simplified calc() to mathWithUnits if possible (if mixing different unit types, this may not be possible)
  • [ ] Deleted any src/amsterdam/overrides/{component}.scss files (styles within should have been converted to the baseline Emotion styles)

CSS tech debt

  • [ ] Wrapped all animations or transitions in euiCanAnimate
  • [ ] Used gap property to add margin between items if using flex
  • Converted side specific padding, margin, and position to -inline and -block logical properties (check inline styles as well as CSS)

DOM Cleanup

  • Did NOT remove any block/element classNames (e.g. euiComponent, euiComponent__child)
  • SEARCH KIBANA FIRST: Deleted any modifier classNames or maps if not being used in Kibana.

Kibana due diligence

  • Search Kibana's codebase for {euiComponent}- (case sensitive) to check for usage of modifier classes
    • [ ] If usage exists, consider converting to a data attribute so that consumers still have something to hook into
  • Pre-emptively check how your conversion will impact the next Kibana upgrade. This entails searching/grepping through Kibana (excluding **/target, **/*.snap, **/*.storyshot for less noise) for eui{Component} (case sensitive) to find:
  • Any test/query selectors that will need to be updated
  • Any Sass or CSS that will need to be updated, particularly if a component Sass var was deleted
  • Any direct className usages that will need to be refactored (e.g. someone calling the euiBadge class on a div instead of simply using the EuiBadge component)

Extras/nice-to-have

  • [ ] Reduced specificity where possible (usually by reducing nesting and class name chaining)
  • [ ] Optional component/code cleanup: consider splitting up the component into multiple children if it's overly verbose or difficult to reason about
  • [ ] Documentation pass
  • [ ] Check for issues in the backlog that could be a quick fix for that component

Modifier classes removed:

  • euiSelectable-fullHeight
  • euiSelectableList-fullHeight
  • euiSelectableList-bordered
  • euiSelectableMessage--bordered
  • euiSelectableListItem--paddingSmall
  • euiSelectableListItem__text--truncate & euiSelectableListItem__text--wrap

Comment on lines +19 to +21
const lighterBorder = transparentize(euiTheme.border.color, 0.4);
return {
border: `${euiTheme.border.width.thin} solid ${lighterBorder}`,
Copy link
Member Author

@cee-chen cee-chen Aug 2, 2024

Choose a reason for hiding this comment

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

This was an intentional change from the previous Sass styles:

$euiSelectableListItemBorder: 1px solid darken($euiColorLightestShade, 2%);

I deliberately wanted to use a color that we already use for borders instead of a random shade, and I also liked transparentize over darken (which wasn't showing up at all in dark mode) as it shows up better for focused items.

}

&[aria-disabled='true'] {
color: ${euiTheme.colors.disabledText};
Copy link
Member Author

Choose a reason for hiding this comment

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

This was another intentional change from production:

&[aria-disabled='true'] {
color: $euiColorMediumShade;

We should also be using the token we specifically have for disabled text over a random shade

Comment on lines +36 to +37
line-height: ${euiFontSize(euiThemeContext, 'm').lineHeight};
font-size: ${euiFontSize(euiThemeContext, 's').fontSize};
Copy link
Member Author

Choose a reason for hiding this comment

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

Just to clarify, Caroline changed the euiFontSize() mixin in Emotion/JS compared to Sass, generally reducing line height. To preserve the previous production appearance of EuiSelectable, I had to split up the line-height and font size mixins.

- might as well get it out of the way now, because Enzyme snapshots will make the Emotion conversion annoying
- hooray for no theme tokens needed
+ add `shouldRenderCustomStyles` test
…hEuiTheme`

- `EuiSelectableList` is going to need this because it's a class component with a generic :T
+ leftover __groupLabel element

+ fix `euiFontSize(s)` which has reduced line height in Emotion - not sure what the intent was here but just going to preserve the old line height for now

+ replace `.euiSelectableListItem__tooltipAnchor` with a CSS utility className

+ delete Sass variables

opinionated changes:
- change disabled text to use disabled text color specifically, not medium shade
- change item border to use the border color specifically (but transparentized to match prev lightness) instead of a random shade
@cee-chen cee-chen marked this pull request as ready for review August 2, 2024 17:02
@cee-chen cee-chen requested a review from a team as a code owner August 2, 2024 17:02
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

Copy link
Contributor

@mgadewoll mgadewoll left a comment

Choose a reason for hiding this comment

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

🚢 🐈‍⬛ Awesome conversion and straight forward updates - thanks for the explanations on intentional changes 👍 I didn't notice any unexpected regression 🎉

@cee-chen
Copy link
Member Author

cee-chen commented Aug 5, 2024

@mgadewoll I think I'm going to yolo ahead with merging this to get the next conversion (EuiSelectableTemplateSitewide) out, but feel free to follow up on the util feedback there or suggest a specific example/comment!

@cee-chen cee-chen merged commit 8d0d8d0 into elastic:main Aug 5, 2024
6 checks passed
@cee-chen cee-chen deleted the emotion/selectable branch August 5, 2024 19:06
cee-chen added a commit to elastic/kibana that referenced this pull request Aug 14, 2024
`v95.6.0` ⏩ `v95.7.0`

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

## [`v95.7.0`](https://github.com/elastic/eui/releases/v95.7.0)

**CSS-in-JS conversions**

- Converted `EuiSelectable` to Emotion
([#7940](elastic/eui#7940))
  - Removed `$euiSelectableListItemBorder`
  - Removed `$euiSelectableListItemPadding`
- Converted `EuiSelectableTemplateSitewide` to Emotion
([#7944](elastic/eui#7944))
  - Removed `$euiSelectableTemplateFocusBackgroundLight`
  - Removed `$euiSelectableTemplateFocusBackgroundDark`
  - Removed `$euiSelectableTemplateSitewideTypes`
- Converted `EuiComboBox` to Emotion
([#7950](elastic/eui#7950))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants