eui
eui copied to clipboard
[EuiButton] Convert to Emotion
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 specificBUTTON_COLOR
but allow it to be passed intoeuiButtonColor
for coloring -
euiButtonColor()
now returns bothbackgroundColor
andcolor
for proper text contrast -
euiButtonFillColor()
creates thefill
(solid color, white/black text) styling combo -
euiButtonEmptyColor()
creates theempty
style using text-variants for color and transparent hover backgrounds -
useEuiButtonColorCSS()
now accepts options such as thedisplay: 'base' | 'fill' | 'empty'
and returns both keys for color and display. -
useEuiButtonRadiusCSS()
returns theborder-radius
values bysize
of button -
useEuiButtonFocusCSS()
is just the translate animation
3. Button component updates
EuiButton
- Renamed exported
ButtonColor
toEuiButtonColor
andButtonSize
toEuiButtonSize
- 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
, anddisabled
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.
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
, anddisabled
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
, anddisplay
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
, andisSelected
(asdisplay='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 thedisabled
,isDisabled
,isLoading
, and validity ofhref
to determine finaldisabled
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
Preview documentation changes for this PR: https://eui.elastic.co/pr_5989/
Preview documentation changes for this PR: https://eui.elastic.co/pr_5989/
Preview documentation changes for this PR: https://eui.elastic.co/pr_5989/
Preview documentation changes for this PR: https://eui.elastic.co/pr_5989/
Preview documentation changes for this PR: https://eui.elastic.co/pr_5989/
Preview documentation changes for this PR: https://eui.elastic.co/pr_5989/
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?
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.
@miukimiu Would you mind doing another design pass on this before I take a look from the engineering side?
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
.
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
❌ 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