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 EuiFilterGroup and EuiFilterButton #6957

Merged
merged 18 commits into from
Jul 18, 2023

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Jul 18, 2023

Summary

  • See [Emotion] EuiFilterGroup #6398
    • There's still one unconverted component before this issue closes (EuiFilterSelectItem), but this PR is getting pretty long as it is and already has its own set of Kibana changes, so I'll convert that component later separately.

I recommend following along by commit - as always, there's a good amount of incidental cleanup happening, so I tried to make individual commits as atomic and 1:1 as possible for easier review.

Other than snapshots, there is one active Kibana cleanup item that needs to be done as part of the next upgrade, which is converting all direct usages of .euiFilterGroup__popoverPanel to Emotion (see 7412d84). @tkajtoch, let me know once you've created a Kibana upgrade PR and I'll push up the work needed for this to your branch.

QA

General checklist

  • Checked in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Added or updated jest and cypress tests
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

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 - No playground exists for this component

Unit tests

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

Sass/Emotion conversion process

  • [ ] Converted all global Sass vars/mixins to JS (e.g. $euiSize to euiTheme.size.base) No Sass vars
  • [ ] 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
  • Removed converted Sass files
  • 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 No animations
  • 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.
    • - (single hyphen instead of double hyphen) modifiers left alone, as there's multiple references to them across Kibana. Double hyphen modifiers are in snapshots only and were removed

Kibana due diligence

  • 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)
    • ⚠️ KIBANA TODO: Direct references to .euiFilterGroup__popoverPanel need to be converted to Emotion instead (see 7412d84)

Extras/nice-to-have

  • [ ] Documentation pass:
  • Reduced specificity where possible (usually by reducing nesting and class name chaining)
  • [ ] 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

- flattening out as much CSS as possible to EuiFilterButton

- styles targeting popover/tooltip wrappers can't be targeted, but we can at least avoid euiFilterButtons receiving those styles with a DRY util and a `:not` selector
TODO: Kibana usages will need to be converted to a `css` prop as well, and import the styles fn directly
- DRY out box-shadow CSS, add more comments
- remove disabled styles - just use EuiButtonEmpty's default styles instead

- non-disabled styles still need to be converted despite grody nesting levels :T
+ misc JS syntax cleanup

+ DRY out `hasNotification` condition - should be using `showBadge` instead

content:
- flatten `hasIcon` CSS

text:
- add missing parent `.euiFilterButton__text` className on textprops

notification:
- remove unnecessary vertical-align (no effect since flex is already doing its thing)
- switch to gap instead of margin for spacing
- flatten disabled opacity styles
- (focus) add manually border radius rounding logic - it's verbose (due to popover anchors) but visually worth it

- (hover) force the notification badge to inherit both interactive and disabled cursors
@cee-chen cee-chen marked this pull request as ready for review July 18, 2023 06:43
@kibanamachine
Copy link

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

Copy link
Member

@tkajtoch tkajtoch left a comment

Choose a reason for hiding this comment

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

Code and updated tests look great! I found a couple of styling differences that probably need fixing:

  • Single filter focus state outline offset is 1px different (fixed border radius looks so much better though!)
Screenshot 2023-07-18 at 18 06 57
  • fullWidth Layout example is squished to a single line and doesn't look good on small viewports
Screenshot 2023-07-18 at 18 09 52

@cee-chen
Copy link
Member Author

cee-chen commented Jul 18, 2023

Single filter focus state outline offset is 1px different (fixed border radius looks so much better though!)

This was an intentional change (see 15cd531). I think the slight offset difference on the right is well worth the improved border-radius focus state, especially across multiple browsers (this is primarily only an issue on Chromium - FF and Safari have better focus rings).

fullWidth Layout example is squished to a single line and doesn't look good on small viewports

Will take a look at this, not sure what's going on there. Thanks for catching it!

@cee-chen

This comment was marked as outdated.

- just use `euiMaxBreakpoint` instead of `euiBreakpoints`, the concept of "s and under" is easier to follow
@cee-chen cee-chen requested a review from tkajtoch July 18, 2023 17:15
@cee-chen
Copy link
Member Author

@tkajtoch Breakpoints shenanigans should be fixed now. Thanks a million for catching that again! 🎉 Let me know if you're good with shipping with the focus outline change.

@tkajtoch
Copy link
Member

Thank you!! I'm good, it definitely looks better than the previous version and I don't mind it at all :) I'll retest it as soon as the PR environment updates

@kibanamachine
Copy link

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

Copy link
Member

@tkajtoch tkajtoch left a comment

Choose a reason for hiding this comment

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

Code and functionality look great! Thanks for converting tests to RTL 🎉

@cee-chen cee-chen merged commit 35e30ec into elastic:main Jul 18, 2023
1 check passed
@cee-chen cee-chen deleted the emotion/filter-group-button branch July 18, 2023 18:08
Ikuni17 pushed a commit to elastic/kibana that referenced this pull request Jul 27, 2023
## Summary

`eui@84.0.0` ⏩ `eui@85.0.1`

## [`85.0.1`](https://github.com/elastic/eui/tree/v85.0.1)

**Bug fixes**

- Fixed `EuiFilterGroup`'s responsive styles
([#6983](elastic/eui#6983))

## [`85.0.0`](https://github.com/elastic/eui/tree/v85.0.0)

- Updated `EuiThemeProvider` to set an Emotion theme context that
returns the values of `useEuiTheme()`
([#6913](elastic/eui#6913))
- Added `size` prop to `EuiStepsHorizontal`, defaulting to the previous
size of `m` ([#6928](elastic/eui#6928))
- Added new `s` sizing to `EuiStepsHorizontal`
([#6928](elastic/eui#6928))
- Added `at` and `key` icon glyphs.
([#6934](elastic/eui#6934))
- Added a new `cloneElementWithCss` Emotion utility
([#6939](elastic/eui#6939))
- Updated `EuiPopover` to allow consumer control of all `focusTrapProps`
([#6955](elastic/eui#6955))

**Bug fixes**

- Fixed `EuiDataGrid` height calculation bug when browser zoom levels
are not 100% ([#6895](elastic/eui#6895))
- Fixed `EuiTab` not correctly passing selection color state to
`prepend` and `append` children
([#6938](elastic/eui#6938))
- Fixed `EuiInputPopover` to allow consumer control of its focus trap
via `focusTrapProps` ([#6955](elastic/eui#6955))

**Breaking changes**

- `EuiProvider` will no longer render multiple or duplicate nested
instances of itself. If a nested `EuiProvider` is detected, that
instance will return early without further processing, and will warn if
configured to do so via `setEuiDevProviderWarning`. For nested theming,
use `EuiThemeProvider` instead.
([#6949](elastic/eui#6949))
- Removed `onTrapDeactivation` prop from `EuiPopover`. Use
`focusTrapProps.onDeactivation` instead
([#6955](elastic/eui#6955))

**CSS-in-JS conversions**

- Converted `EuiFilterGroup` and `EuiFilterButton` to Emotion; Removed
styles attached to `.euiFilterGroup__popoverPanel`
([#6957](elastic/eui#6957))

---------

Co-authored-by: Cee Chen <constance.chen@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
adcoelho pushed a commit to adcoelho/kibana that referenced this pull request Jul 28, 2023
## Summary

`eui@84.0.0` ⏩ `eui@85.0.1`

## [`85.0.1`](https://github.com/elastic/eui/tree/v85.0.1)

**Bug fixes**

- Fixed `EuiFilterGroup`'s responsive styles
([elastic#6983](elastic/eui#6983))

## [`85.0.0`](https://github.com/elastic/eui/tree/v85.0.0)

- Updated `EuiThemeProvider` to set an Emotion theme context that
returns the values of `useEuiTheme()`
([elastic#6913](elastic/eui#6913))
- Added `size` prop to `EuiStepsHorizontal`, defaulting to the previous
size of `m` ([elastic#6928](elastic/eui#6928))
- Added new `s` sizing to `EuiStepsHorizontal`
([elastic#6928](elastic/eui#6928))
- Added `at` and `key` icon glyphs.
([elastic#6934](elastic/eui#6934))
- Added a new `cloneElementWithCss` Emotion utility
([elastic#6939](elastic/eui#6939))
- Updated `EuiPopover` to allow consumer control of all `focusTrapProps`
([elastic#6955](elastic/eui#6955))

**Bug fixes**

- Fixed `EuiDataGrid` height calculation bug when browser zoom levels
are not 100% ([elastic#6895](elastic/eui#6895))
- Fixed `EuiTab` not correctly passing selection color state to
`prepend` and `append` children
([elastic#6938](elastic/eui#6938))
- Fixed `EuiInputPopover` to allow consumer control of its focus trap
via `focusTrapProps` ([elastic#6955](elastic/eui#6955))

**Breaking changes**

- `EuiProvider` will no longer render multiple or duplicate nested
instances of itself. If a nested `EuiProvider` is detected, that
instance will return early without further processing, and will warn if
configured to do so via `setEuiDevProviderWarning`. For nested theming,
use `EuiThemeProvider` instead.
([elastic#6949](elastic/eui#6949))
- Removed `onTrapDeactivation` prop from `EuiPopover`. Use
`focusTrapProps.onDeactivation` instead
([elastic#6955](elastic/eui#6955))

**CSS-in-JS conversions**

- Converted `EuiFilterGroup` and `EuiFilterButton` to Emotion; Removed
styles attached to `.euiFilterGroup__popoverPanel`
([elastic#6957](elastic/eui#6957))

---------

Co-authored-by: Cee Chen <constance.chen@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
ThomThomson pushed a commit to ThomThomson/kibana that referenced this pull request Aug 1, 2023
## Summary

`eui@84.0.0` ⏩ `eui@85.0.1`

## [`85.0.1`](https://github.com/elastic/eui/tree/v85.0.1)

**Bug fixes**

- Fixed `EuiFilterGroup`'s responsive styles
([elastic#6983](elastic/eui#6983))

## [`85.0.0`](https://github.com/elastic/eui/tree/v85.0.0)

- Updated `EuiThemeProvider` to set an Emotion theme context that
returns the values of `useEuiTheme()`
([elastic#6913](elastic/eui#6913))
- Added `size` prop to `EuiStepsHorizontal`, defaulting to the previous
size of `m` ([elastic#6928](elastic/eui#6928))
- Added new `s` sizing to `EuiStepsHorizontal`
([elastic#6928](elastic/eui#6928))
- Added `at` and `key` icon glyphs.
([elastic#6934](elastic/eui#6934))
- Added a new `cloneElementWithCss` Emotion utility
([elastic#6939](elastic/eui#6939))
- Updated `EuiPopover` to allow consumer control of all `focusTrapProps`
([elastic#6955](elastic/eui#6955))

**Bug fixes**

- Fixed `EuiDataGrid` height calculation bug when browser zoom levels
are not 100% ([elastic#6895](elastic/eui#6895))
- Fixed `EuiTab` not correctly passing selection color state to
`prepend` and `append` children
([elastic#6938](elastic/eui#6938))
- Fixed `EuiInputPopover` to allow consumer control of its focus trap
via `focusTrapProps` ([elastic#6955](elastic/eui#6955))

**Breaking changes**

- `EuiProvider` will no longer render multiple or duplicate nested
instances of itself. If a nested `EuiProvider` is detected, that
instance will return early without further processing, and will warn if
configured to do so via `setEuiDevProviderWarning`. For nested theming,
use `EuiThemeProvider` instead.
([elastic#6949](elastic/eui#6949))
- Removed `onTrapDeactivation` prop from `EuiPopover`. Use
`focusTrapProps.onDeactivation` instead
([elastic#6955](elastic/eui#6955))

**CSS-in-JS conversions**

- Converted `EuiFilterGroup` and `EuiFilterButton` to Emotion; Removed
styles attached to `.euiFilterGroup__popoverPanel`
([elastic#6957](elastic/eui#6957))

---------

Co-authored-by: Cee Chen <constance.chen@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
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