-
Notifications
You must be signed in to change notification settings - Fork 842
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
[EuiButton] Convert to Emotion #5989
Conversation
# Conflicts: # src/components/accessibility/skip_link/__snapshots__/skip_link.test.tsx.snap # src/components/accordion/__snapshots__/accordion.test.tsx.snap # src/components/collapsible_nav/collapsible_nav_group/__snapshots__/collapsible_nav_group.test.tsx.snap # src/components/control_bar/__snapshots__/control_bar.test.tsx.snap
- Uses new EuiButtonDisplay - Updates EuiButtonDisplay with more styles and fixes
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/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is ready for review. I know it's large, but it's also a lot of snap updates. There is also still a lot of repetition that will hopefully get updated soon after this PR. A lot of the styling is importing from the theme
folder but I'm hoping we'll find a solution to #5888 that will remove these relative imports.
font-weight: ${euiTheme.font.weight.medium}; | ||
padding: 0 ${euiTheme.size.m}; | ||
|
||
&:hover:not(:disabled), | ||
&:focus { | ||
text-decoration: underline; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be addressing theses styles more globally in a follow up.
src/components/button/button.tsx
Outdated
// Use defaultProps for simple pass-through props | ||
EuiButton.defaultProps = { | ||
minWidth: 112, | ||
size: 'm', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a cool little pattern I realized in our Props table. If the component is inheriting props from somewhere else and doesn't actually do anything with the props but pass them through, instead of having to re-declare them outside of the ..rest
spread, just using .defaultProps
works here and spits out the values in our docs props table. 🙌
Preview documentation changes for this PR: https://eui.elastic.co/pr_5989/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just found some initial issues but I just tested in Chome for now. I'll test later in other browsers.
|
||
const buttonColorStyles = useEuiButtonColorCSS({ | ||
display: fill ? 'fill' : 'base', | ||
})[color === 'ghost' ? 'text' : color]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not yet, mainly becuase the dark background components haven't been converted to Emotion to use the dark-mode emptyShade
instead of this custom color. Check out the first bottom bar example which is a fully dark-mode component: https://eui.elastic.co/pr_5989/#/layout/bottom-bar
@@ -46,18 +46,29 @@ export const euiButtonDisplayStyles = ( | |||
euiButtonDisplay: css` | |||
${euiButtonBaseCSS()}; | |||
${minWidth && logicalCSS('min-width', minWidth)}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was the one adding this minWidth
here. But I wonder if is it better to handle this in the style
tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're definitely right if the minWidth
is provided by the consumer. But I wonder if we should put the default in the style
tag becuase that could be a breaking change if consumers are currently adjusting this property via a custom class. By moving the default to the style
tag, their specificity would be overridden.
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? |
Yes. Only components converted to Emotion styling will react to changes introduced with the |
@miukimiu Would you mind doing another design pass on this before I take a look from the engineering side? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🎉
Tested in Chrome, Safari, Edge, and Firefox.
Just one minor suggestion. What do you think of changing the last example to have a EuiPanel
with color "subdued"
? I think the contrast gets a little bit better. Let me know your thoughts.
Also the EuiText is not working inside the <EuiThemeProvider colorMode="dark">
, I'll open an issue for that.
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 |
Sounds good. 👍🏽 I opened the PR for the color mode issue with EuiText: #6123 |
* Convert text globals/utilities to Emotion + fix missing CSS logical property on text truncation mixin + convert textLeft/Right to logical CSS - note that we can't use the logicalTextAlign util for this as !important can't be passed to that util * Pass euiTheme to globalStyles and convert euiNumberFormat * Convert display utils to Emotion + convert euiFullHeight Sass mixin to Emotion + move @mixin euiFullHeight to `mixins/_helpers` instead of living in `_utility` * Document euiFullHeight under scroll utils - since that's where the className was documented * Convert scroll globals to Emotion (+ add logical CSS properties) - this requires adding a new `logicalCSSWithFallback` util, since overflow-inline/block is not yet supported on non-FF browsers + fix incorrect overflow mapping - inline should be x and block should be y * Convert .eui-isFocusable global to Emotion + convert mixin to accept the entire euiThemeContext instead of just the euiTheme to match all other mixins * Convert responsive globals to Emotion * Add snapshot test for quick checking of global styles output * Changelog * Remove `.eui-isFocusable` - not being used anywhere + already being handled by global reset
Closing in favor of #6150 |
1. Moved Amsterdam-specific Sass overrides to default
global_styling/
folderThis 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
disabled
as a specificBUTTON_COLOR
but allow it to be passed intoeuiButtonColor
for coloringeuiButtonColor()
now returns bothbackgroundColor
andcolor
for proper text contrasteuiButtonFillColor()
creates thefill
(solid color, white/black text) styling comboeuiButtonEmptyColor()
creates theempty
style using text-variants for color and transparent hover backgroundsuseEuiButtonColorCSS()
now accepts options such as thedisplay: 'base' | 'fill' | 'empty'
and returns both keys for color and display.useEuiButtonRadiusCSS()
returns theborder-radius
values bysize
of buttonuseEuiButtonFocusCSS()
is just the translate animation3. Button component updates
EuiButton
ButtonColor
toEuiButtonColor
andButtonSize
toEuiButtonSize
EuiButtonDisplay
component as the render and passing on all the rest of the props to handle the button vs anchor logiccolor
,fill
, anddisabled
and removing associated classes.text
color fill buttonsThe 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.EuiButtonEmpty
color
, anddisabled
and removing associated classes.EuiButtonIcon
color
,disabled
, anddisplay
removing associated classes.EuiButtonGroup & Option
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.color
,disabled
, andisSelected
(asdisplay='fill'
)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
isButtonDisabled()
utility for DRY-ing out the logic which compares thedisabled
,isDisabled
,isLoading
, and validity ofhref
to determine finaldisabled
state.data-test-subj
props to empty buttons for testsChecklist
ghost
colors[ ] Checked Code Sandbox works for any docs examples