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 EuiColorPicker #7845

Merged

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Jun 24, 2024

Summary

Note

This PR merges into a feature branch.

Converts the base EuiColorPicker component to Emotion - more color picker components to come in future PRs.

This PR also slightly changes/flattens the DOM structure of the EuiColorPicker popover's elements, allowing for flex gap usage.

QA

The below links should look the same as before with no UI/visual regressions

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 tests to RTL

Sass/Emotion conversion process

  • Listed var/mixin removals in changelog
  • Removed or converted component-specific Sass vars/mixins to exported JS versions
  • Removed component from src/components/index.scss
  • [ ] 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)
  • [ ] Converted all global Sass vars/mixins to JS (e.g. $euiSize to euiTheme.size.base)
  • [ ] Added an @warn deprecation message within the global_styling/mixins/{component}.scss file

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.
    • Removed .euiColorPicker__popoverPanel--pickerOnly and .euiColorPicker__popoverPanel--customButton

Kibana due diligence

  • Search Kibana's codebase for {euiComponent}- (case sensitive) to check for usage of modifier classes - None
    • [ ] 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. - None
  • 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) - None

There's a single custom CSS override, but it appears to apply to a selector that doesn't even exist in EUI anymore 🤷


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

- swap margins to gap instead
- now entirely handled by `EuiFormControlLayout`

+ remove ignored `icon` prop being passed to EuiFieldText, does nothing if `controlOnly` is passed
- not really worth avoiding the nesting here
- Allows us to remove `margin`s from `EuiHue`
- Allows us to remove a bunch of conditional `EuiSpacer`s that didn't account  for every possible permutation

+ remove extra `<div>` wrapper in favor of passing `onKeyDown` events directly to child `EuiHue` and `EuiSaturation`

- tweak `EuiHue` to have a single wrapper (to work with flex gap) instead of multiple top level children. DOM shouldn't impact a11y behavior

+ fix incorrect `compressed` behavior on secondary input display, compressed is always true for that (vs the popover form control)
- remove unnecessary vars and just inline them since they only have 1 usage

- remove `.euiColorPicker__swatch-item` - not used anywhere in either EUI or Kibana

- remove `.euiColorPicker__swatchSelect` - not used in Kibana and can be replaced with component className instead in EUI
- convert Enzyme to RTL

- add `shouldRenderCustomStyles`

- update snapshots
@cee-chen cee-chen marked this pull request as ready for review June 24, 2024 22:54
@cee-chen cee-chen requested a review from a team as a code owner June 24, 2024 22:54
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.

🚢 🐈‍⬛ Looks great to me, nice cleanups! I didn't see any (unexpected) visual regression 👍


jest.mock('../portal', () => ({
EuiPortal: ({ children }: { children: any }) => children,
}));

const onChange = jest.fn();
describe('EuiColorPicker', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for myself: This will conflict with the jest upgrade PR and needs rebasing.

Copy link
Contributor

@mgadewoll mgadewoll Jun 25, 2024

Choose a reason for hiding this comment

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

I only just now realized how much more useful these comparison shots really are and what functionality they offer 🤯 😆 🐌

mindblown

Screen.Recording.2024-06-25.at.13.36.44.mov

Copy link
Member Author

Choose a reason for hiding this comment

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

Whooaaaaa I only just realized that too!!!! Thank you!!

- make it so user input changes the input (easier to QA/test) and also add an onChange action

- allow color/format controls to update the story correctly as expected
- show secondary input automatically if `mode` is set that way

- remove double form control layout wrapper
- fix clear icon not correctly stacking with invalid icon (needs to be passed to form control layout)

- allow compressed state of input to be controlled when `display` is inline, otherwise default to compressed
@cee-chen
Copy link
Member Author

I did a quick second pass on Storybook in more browsers and noticed a few friction points in the controls that I pushed up changes for. I think they're pretty minor so going to go ahead and merge, but let me know if you have any comments and I can open up a follow-up PR!

@cee-chen cee-chen merged commit 41d2c32 into elastic:emotion/color-pickers Jun 25, 2024
1 of 4 checks passed
@cee-chen cee-chen deleted the emotion/color-picker-2 branch June 25, 2024 17:08
@kibanamachine
Copy link

Preview staging links for this PR:

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cee-chen added a commit that referenced this pull request Jun 26, 2024
tkajtoch added a commit to elastic/kibana that referenced this pull request Jul 13, 2024
`v95.2.0`⏩`v95.3.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.3.0`](https://github.com/elastic/eui/releases/v95.3.0)

- Updated `EuiThemeProvider`s to allow modifying/setting custom
`breakpoint`s in nested usage (as opposed to only at the top
`EuiProvider` level) ([#7862](elastic/eui#7862))

**Bug fixes**

- Fixed a Chrome/Edge CSS `mask-image` bug that was affecting scroll
overflow shadow utilties
([#7855](elastic/eui#7855))

**CSS-in-JS conversions**

- Converted `EuiColorPicker` to Emotion; Removed `$euiColorPickerWidth`
([#7845](elastic/eui#7845))
- Converted `EuiColorPickerSwatch` to Emotion
([#7853](elastic/eui#7853))
- Converted `EuiColorPalettePicker` and `EuiColorPaletteDisplay` to
Emotion ([#7854](elastic/eui#7854))
  - Removed `$euiColorPaletteDisplaySizes`
  - Removed `@mixin euiColorPaletteInnerBorder`
- Removed `$euiColorPickerValueRange0`, `$euiColorPickerValueRange1`,
`$euiColorPickerSaturationRange0`, `$euiColorPickerSaturationRange1`,
and `$euiColorPickerIndicatorSize`
([#7859](elastic/eui#7859))

**Accessibility**

- Updated the `aria-label` attribute for the `EuiFilePicker` remove file
button ([#7860](elastic/eui#7860))

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
cee-chen pushed a commit to cee-chen/kibana that referenced this pull request Sep 12, 2024
`v95.2.0`⏩`v95.3.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)_

---

- Updated `EuiThemeProvider`s to allow modifying/setting custom
`breakpoint`s in nested usage (as opposed to only at the top
`EuiProvider` level) ([elastic#7862](elastic/eui#7862))

**Bug fixes**

- Fixed a Chrome/Edge CSS `mask-image` bug that was affecting scroll
overflow shadow utilties
([elastic#7855](elastic/eui#7855))

**CSS-in-JS conversions**

- Converted `EuiColorPicker` to Emotion; Removed `$euiColorPickerWidth`
([elastic#7845](elastic/eui#7845))
- Converted `EuiColorPickerSwatch` to Emotion
([elastic#7853](elastic/eui#7853))
- Converted `EuiColorPalettePicker` and `EuiColorPaletteDisplay` to
Emotion ([elastic#7854](elastic/eui#7854))
  - Removed `$euiColorPaletteDisplaySizes`
  - Removed `@mixin euiColorPaletteInnerBorder`
- Removed `$euiColorPickerValueRange0`, `$euiColorPickerValueRange1`,
`$euiColorPickerSaturationRange0`, `$euiColorPickerSaturationRange1`,
and `$euiColorPickerIndicatorSize`
([elastic#7859](elastic/eui#7859))

**Accessibility**

- Updated the `aria-label` attribute for the `EuiFilePicker` remove file
button ([elastic#7860](elastic/eui#7860))

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@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.

4 participants