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 EuiDroppable & EuiDraggable #7187

Merged
merged 17 commits into from
Sep 18, 2023

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Sep 14, 2023

Summary

As always, I recommend following along by commit as this PR contains some cleanup/tech debt tasks around tests etc.

This PR additionally contains a very small focus outline placement fix in 6e1823e:

Before:

After:

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 - skipped
  • 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~
    • [ ] Updated the Figma library counterpart

Emotion checklist

Kibana usage

  • 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:
  • Search Kibana's codebase for {euiComponent}- (case sensitive) to check for usage of modifier classes - Two modifier usages: 1, 2
  • Any test/query selectors that will need to be updated - None
  • Any Sass or CSS that will need to be updated, particularly if a component Sass var was deleted - None
  • 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) - None

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 No playground, but added Storybooks

Unit tests

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

Sass/Emotion conversion process

  • Converted all global Sass vars/mixins to JS (e.g. $euiSize to euiTheme.size.base)
  • Removed or converted component-specific Sass vars/mixins to exported JS versions
  • Listed var/mixin removals in changelog
  • [ ] 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)
  • [ ] Added an @warn deprecation message within the global_styling/mixins/{component}.scss file
  • All SCSS files have been removed from the component(s) directory
  • [ ] All SCSS overrides have been removed from the Amsterdam theme No overrides

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) - Note: removed an unused modifier class on a child euiDroppable__placeholder element
  • SEARCH KIBANA FIRST: Deleted any modifier classNames or maps if not being used in Kibana.

Extras/nice-to-have

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

- remove more modifier classes
- [syntax nit] destructure `snapshot` for more readable code
- no theme tokens, so can be a static obj

+ remove 4 year old TODO that has never been added and probably isn't needed at this point
`euiFocusRing` mixin doesn't work because of `:focus-visible`

prefer just an auto outline to match prod behavior, the outline is just more focused on the child item

not sure what the custom drag handle CSS is for, drag handle focus outlines work fine as-is
- Remove all unused modifier classes (based on Kibana usage)

- Fix cloned items missing Emotion styles

- Fix missing React 17 snapshot updates
- DRY out with EuiDraggable spacing

+ switch `none` to a null to match EuiPanel padding styles (reduces rendered classNames)

+ remove exported types, not really being used
- convert all tests to RTL

- add shouldRenderCustomStyles tests

- switch modifier class to non BEM to indicate state vs styles
- add `shouldRenderCustomStyles` test

- DRY out test context wrapper logic

- fixed `...requiredProps` logic

- switch from screen usage to destructured APIs
- remove unnecessary/unused jest mock
+ fix `false` className by using `classNames()` util
- extra selector specifier needed due to new Emotion wrapper around drag/drop components
@cee-chen cee-chen requested review from a team and breehall September 15, 2023 00:52
@cee-chen cee-chen marked this pull request as ready for review September 15, 2023 00:52
@cee-chen
Copy link
Member Author

cee-chen commented Sep 15, 2023

@breehall I opted not to create a Storybook for this conversion mostly for expedience - the existing EUI docs are quite good for QA, and the props are a little tricky since this is a very 3rd party lib heavy and render prop heavy component. I'd love to see you create stories for drag/drop in the future however! (no rush, of course)

@kibanamachine
Copy link

Preview staging links for this PR:

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

Copy link
Contributor

@breehall breehall left a comment

Choose a reason for hiding this comment

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

Great conversion! It was actually a little less complicated than I thought it would be. I thoroughly tested the QA against prod and didn't find any unexpected changes.

One question on a class name below, but I think that's about it!

src/components/drag_and_drop/draggable.styles.ts Outdated Show resolved Hide resolved
Comment on lines +90 to +98
const PanelOrDiv = withPanel ? EuiPanel : 'div';
const panelOrDivProps = withPanel
? {
panelRef: provided.innerRef,
hasShadow: true,
paddingSize: 'none' as const,
}
: { ref: provided.innerRef };

Copy link
Contributor

Choose a reason for hiding this comment

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

Elegant refactor and use down on line 119!

'euiDroppable--noGrow': !grow,
},
spacingToClassNameMap[spacing],
{ 'euiDroppable-isDisabled': dropIsDisabled },
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we just keeping this class for Kibana usages?

Copy link
Member Author

@cee-chen cee-chen Sep 18, 2023

Choose a reason for hiding this comment

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

Yes, there's two Kibana usages targeting --isDisabled (that restore the cursor).

@cee-chen cee-chen merged commit d1b54f6 into elastic:main Sep 18, 2023
2 checks passed
@cee-chen cee-chen deleted the emotion/drag-drop branch September 18, 2023 16:23
jbudz pushed a commit to elastic/kibana that referenced this pull request Sep 27, 2023
`v88.3.0`⏩`v88.5.0`

closes #151514

---

## [`88.5.0`](https://github.com/elastic/eui/tree/v88.5.0)

- Updated `EuiCallOut` with a new `onDismiss` prop
([#7156](elastic/eui#7156))
- Added a new `renderCustomToolbar` prop to `EuiDataGrid`, which allows
custom rendering of the toolbar.
([#7190](elastic/eui#7190))
- Added a new `allowResetButton` prop to
`toolbarVisibility.showDisplaySelector` of `EuiDataGrid`, which allows
hiding the "Reset to default" button from the display settings popover.
([#7190](elastic/eui#7190))
- Added a new `additionalDisplaySettings` prop to
`toolbarVisibility.showDisplaySelector` of `EuiDataGrid`, which allows
rendering extra settings inside the display settings popover.
([#7190](elastic/eui#7190))
- Updated `EuiDataGrid`'s toolbar display settings button icon
([#7190](elastic/eui#7190))
- Updated `EuiTextTruncate` with significantly improved iteration
performance. Removed `measurementRenderAPI` prop, as `EuiTextTruncation`
now only uses more performant canvas render API
([#7210](elastic/eui#7210))
- Updated `EuiPopover` with a new configurable `repositionToCrossAxis`
prop ([#7211](elastic/eui#7211))
- Updated `EuiDatePicker` to support `compressed` input styling
([#7218](elastic/eui#7218))
- Added `gradient` and `palette` icon glyphs.
([#7220](elastic/eui#7220))

**Bug fixes**

- Fixed `EuiPopover`'s missing animations on popover close
([#7211](elastic/eui#7211))
- Fixed `EuiInputPopover` anchoring to the wrong side and missing
shadows on smaller screens
([#7211](elastic/eui#7211))
- Fixed `EuiSuperDatePicker` icon spacing on the quick select button
([#7217](elastic/eui#7217))
- Fixed a missing type in `EuiMarkdownEditor`'s default processing
plugins ([#7221](elastic/eui#7221))


## [`88.4.1`](https://github.com/elastic/eui/tree/v88.4.1)

**Bug fixes**

- Fixed missing `className`s on `EuiTextTruncate`
([#7212](elastic/eui#7212))
- Fixed `title`s on `EuiComboBox` dropdown options to always be present
([#7212](elastic/eui#7212))
- Fixed `EuiComboBox` truncation issues when search is an empty space
([#7212](elastic/eui#7212))

## [`88.4.0`](https://github.com/elastic/eui/tree/v88.4.0)

- Updated `EuiComboBox` to allow configuring text truncation behavior
via `truncationProps`. These props can be set on the entire combobox as
well as on on individual dropdown options.
([#7028](elastic/eui#7028))
- Updated `EuiInMemoryTable` with a new `searchFormat` prop (defaults to
`eql`). When setting this prop to `text`, the built-in search bar will
ignore EQL syntax and allow searching for plain strings with special
characters and symbols.
([#7175](elastic/eui#7175))

**Bug fixes**

- `EuiComboBox` now always shows the highlighted search text, even on
truncated text ([#7028](elastic/eui#7028))
- Fixed missing i18n in `EuiSearchBar`'s default placeholder and
aria-label text ([#7175](elastic/eui#7175))
- Fixed the inline compressed styles of `EuiDescriptionListTitle` to use
a taller line-height for readability
([#7185](elastic/eui#7185))
- Fixed `EuiComboBox` to correctly truncate selected items when
displayed as pills and plain text
([#7193](elastic/eui#7193))

**Accessibility**

- Added `aria-current` attribute to `EuiTablePagination`
([#7186](elastic/eui#7186))

**CSS-in-JS conversions**

- Converted `EuiDroppable` and `EuiDraggable` to Emotion; Removed
`$euiDragAndDropSpacing` Sass variables
([#7187](elastic/eui#7187))

---------

Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com>
Co-authored-by: Jan Monschke <jan.monschke@elastic.co>
Co-authored-by: Thomas Watson <watson@elastic.co>
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.

4 participants