eui icon indicating copy to clipboard operation
eui copied to clipboard

[EuiButton] Convert to Emotion

Open cchaos opened this issue 2 years ago • 9 comments

1. Moved Amsterdam-specific Sass overrides to default global_styling/ folder

This just cleans up some of the unnecessary overrides and Sass files. But mostly leaves the variable / mixins in tact for now.

2. New theme-specific (Amsterdam only for now) button styling functions

  • Removed disabled as a specific BUTTON_COLOR but allow it to be passed into euiButtonColor for coloring
  • euiButtonColor() now returns both backgroundColor and color for proper text contrast
  • euiButtonFillColor() creates the fill (solid color, white/black text) styling combo
  • euiButtonEmptyColor() creates the empty style using text-variants for color and transparent hover backgrounds
  • useEuiButtonColorCSS() now accepts options such as the display: 'base' | 'fill' | 'empty' and returns both keys for color and display.
  • useEuiButtonRadiusCSS() returns the border-radius values by size of button
  • useEuiButtonFocusCSS() is just the translate animation

3. Button component updates

EuiButton

  • Renamed exported ButtonColor to EuiButtonColor and ButtonSize to EuiButtonSize
  • Using the new EuiButtonDisplay component as the render and passing on all the rest of the props to handle the button vs anchor logic
  • Using Emotion for color, fill, and disabled and removing associated classes.
  • Fixed outline focus color of text color fill buttons
  • Background colors for base buttons are no longer transparent

The new tinted colors are just slightly different from their old transparent counterpart. The biggest difference being in the text version which will now align better to forms.

image

Note This basically means this whole component is now Emotion since EuiButton now only handles superficial styling, everything else is passed through to the already Emotion EuiButtonDisplay.

EuiButtonEmpty

  • Using Emotion for color, and disabled and removing associated classes.

Note There's still more we can do here to make use of EuiButtonDisplay but I didn't want to get too far into the weeds.

EuiButtonIcon

  • Using Emotion for color, disabled, and display removing associated classes.

Note There's still more we can do here to make use of EuiButtonDisplay but I didn't want to get too far into the weeds.

EuiButtonGroup & Option

  • [Breaking]: Removed support for ghost. The combo styles between Emotion and CSS were too complex to maintain, but it felt safe to remove support (based an searching for usages - none) and will guide consumers to use colorMode instead once fully converted.
  • Using Emotion for color, disabled, and isSelected (as display='fill')

Note This still uses the old/deprecated EuiButtonDisplay for now

EuiButtonDisplay

Since this is the component that renders the actual element (button vs anchor) I have moved all the logic around the associated props of each from EuiButton to this file so all consumers of this can benefit / doesn't have to worry about the actual DOM element.

EuiButtonDisplayContent

I moved the currently applied disabled styles to be handled by EuiButtonDisplay instead while also applying truncation to the text span using the utility class.

Other updates

  • Added isButtonDisabled() utility for DRY-ing out the logic which compares the disabled, isDisabled, isLoading, and validity of href to determine final disabled state.
  • [EuiMarkdownEditorToolbar] Added data-test-subj props to empty buttons for tests

Checklist

  • [x] BWC for ghost colors
  • [x] Checked in both light and dark modes
  • [x] Checked in mobile
  • [x] Checked in Chrome, Safari, Edge, and Firefox
  • [ ] Props have proper autodocs and playground toggles
  • [x] Added documentation
  • ~[ ] Checked Code Sandbox works for any docs examples~
  • [x] Added or updated jest and cypress tests
  • [x] Checked for breaking changes and labeled appropriately
  • [x] Checked for accessibility including keyboard-only and screenreader modes
  • [ ] Updated the Figma library counterpart
  • [x] A changelog entry exists and is marked appropriately

cchaos avatar Jun 21 '22 19:06 cchaos

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

kibanamachine avatar Jun 21 '22 20:06 kibanamachine

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

kibanamachine avatar Jun 21 '22 23:06 kibanamachine

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

kibanamachine avatar Jun 24 '22 03:06 kibanamachine

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

kibanamachine avatar Jun 27 '22 16:06 kibanamachine

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

kibanamachine avatar Jun 29 '22 15:06 kibanamachine

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

kibanamachine avatar Jul 26 '22 20:07 kibanamachine

I downloaded and trying EUI yesterday for the first time. When setting the primary color via the modify prop of EuiProvider, button colors do not change. Is this PR necessary for this to work?

morksinaanab avatar Aug 03 '22 10:08 morksinaanab

When setting the primary color via the modify prop of EuiProvider, button colors do not change. Is this PR necessary for this to work?

Yes. Only components converted to Emotion styling will react to changes introduced with the modify prop.

thompsongl avatar Aug 08 '22 18:08 thompsongl

@miukimiu Would you mind doing another design pass on this before I take a look from the engineering side?

thompsongl avatar Aug 09 '22 15:08 thompsongl

I am just going to hand off this PR. I'd worry I'm rushing to push it through based on some incidental issues we had with forcing colorMode.

cchaos avatar Aug 10 '22 17:08 cchaos

I am just going to hand off this PR. I'd worry I'm rushing to push it through based on some incidental issues we had with forcing colorMode.

Sounds good. 👍🏽

I opened the PR for the color mode issue with EuiText: https://github.com/elastic/eui/issues/6123

miukimiu avatar Aug 10 '22 17:08 miukimiu

❌ Author of the following commits did not sign a Contributor Agreement: fb72b85df921a6c9150134515c13d8445210ce66, 3ae838c5bcc979cb64e81a37161fe29ebb241ce1, 9d7da0dc023d10d2fc3df49ac2328f898ca3c0dd, 7ef4061ef7a6b3321f455e266928867aa2ed84c7, 85669eccd694ce9e7e65fcb0c29aa599797edd8e, 4f7a81160c8fb20c4a7e861d71a8c37ac5e147f6, 0dd3a51d8bceef6c76625d7bd070b086bcf7d83e, c7c06f2e55aa09743149572f6e4cba86db239651, 7060b3f00b83f4c06b0c8226bf8d021823b5fcb1, c12dd0e03808abefb474a553d12ca514f9475101, ba8d863145f7b81136722652452306ee32a271a6, ee7c0a798082a4cddb109b0482a6131104dc1e35, cbeb27a8cca7b0219cdde06e318ef9c23e93c03e

Please, read and sign the above mentioned agreement if you want to contribute to this project

Closing in favor of #6150

miukimiu avatar Aug 22 '22 12:08 miukimiu