-
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
[EuiButtonGroup] Convert to Emotion #6841
Conversation
- required for deprecation of old component, used by `EuiButtonGroup` + rename `element` usage in `EuiButtonGroupButton` to match existing prefix syntax
Preview documentation changes for this PR: https://eui.elastic.co/pr_6841/ |
1 similar comment
Preview documentation changes for this PR: https://eui.elastic.co/pr_6841/ |
25bb55a
to
16a8487
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_6841/ |
d500bff
to
a3832be
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_6841/ |
a3832be
to
6fefe91
Compare
- `label`s that wrap `input`s don't need a `for` attribute, and buttons really aren't benefiting from randomly generated IDs/data-test-subjs
- update focus utils with a new `euiOutline` helper that only exports the outline CSS and not the `:focus-visible` - Button group focus-visible behavior wasn't working as expected - `:has(:focus-visible)` is what's needed for `:focus-within` keyboard behavior, but it needs a Firefox interim workaround
…nternal - New `EuiButtonDisplay` component makes a lot of the old Sass styles unnecessary + add euiCanAnimate
- Disabled & selected buttons need a custom style + make all selected buttons have a slightly heavier font weight + remove unused(?) z-index CSS
- handles `border-radius` - handles faux box-shadow borders (with better cleanup) - compressed vs uncompressed styles
- remove unnecessary `box-shadow` affordances - doesn't appear to be a thing anymore in Amsterdam theme - remove `overflow hidden` - doesn't seem to be needed - remove `groupSizeToClassNameMap`
- compressed font weight is not the same as default button weight - [opinionated] increase uncompressed font weight to make it more obvious which is chosen
There's no longer any components using it in EUI now that `EuiButtonGroup` has been converted to Emotion
- Convert Enzyme to RTL - Reorganize tests slightly - Add tests for ensuring `css` properly merges
6fefe91
to
52625bd
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_6841/ |
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 looks great Cee! I compared staging to prod and noted the changes mentioned in your description. There are so many QOL changes here! The emboldened text on the selected buttons makes a difference.
I also spun up Storybook and what an experience! This made it so easy to test different permutations of EuiButtonGroup and it's so much easier to use than the Playground.
❓ Question
- Is it expected that the keyboard controls use the left and right arrows for single selection button groups, but the tab button for multi-select button groups?
👀 Observation for Future
- The button backgrounds in dark mode have a fairly low contrast ratio to the page background. This is something we may want to address at a later time.
describe('type', () => { | ||
test('single is rendered', () => { | ||
const component = render( | ||
describe('type="single"', () => { |
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 like how you broke these up and renamed them. They're easier to read and follow
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 wanted to clean up the other props/unit tests in a similar vein, but I figure they're better candidates for saving for storybook visual snapshots or similar tests in the future!
Yes, the single selections are using TBH, I'm not sure if I would have chosen that approach myself necessarily as I agree it feels odd compared to multiselect, but EuiButtonGroup was already set up this way to start, and I don't think it needs an overhaul at this point.
Good eye, agreed! Honestly I really like the |
Thanks a million for the speedy review Bree! |
Preview documentation changes for this PR: https://eui.elastic.co/pr_6841/ |
`eui@82.1.0` ⏩ `83.0.0`⚠️ The biggest change in this PR by far is the `EuiButtonEmpty` Emotion conversion, which changes the DOM structure of the button slightly as well as several CSS classes around it. EUI has attempted to convert any custom EuiButtonEmpty CSS overrides where possible, but would super appreciate it if CODEOWNERS checked their touched files. If anything other than a snapshot or test was touched, please double check the display of your button(s) and confirm everything still looks shipshape. Feel free to ping us for advice if not. --- ## [`83.0.0`](https://github.com/elastic/eui/tree/v83.0.0) **Bug fixes** - Fixed `EuiPaginationButton` styling affected by `EuiButtonEmpty`'s Emotion conversion ([#6893](elastic/eui#6893)) **Breaking changes** - Removed `isPlaceholder` prop from `EuiPaginationButton` ([#6893](elastic/eui#6893)) ## [`82.2.1`](https://github.com/elastic/eui/tree/v82.2.1) - Updated supported Node engine versions to allow Node 16, 18 and >=20 ([#6884](elastic/eui#6884)) ## [`82.2.0`](https://github.com/elastic/eui/tree/v82.2.0) - Updated EUI's SVG icons library to use latest SVGO v3 optimization ([#6843](elastic/eui#6843)) - Added success color `EuiNotificationBadge` ([#6864](elastic/eui#6864)) - Added `badgeColor` prop to `EuiFilterButton` ([#6864](elastic/eui#6864)) - Updated `EuiBadge` to use CSS-in-JS for named colors instead of inline styles. Custom colors will still use inline styles. ([#6864](elastic/eui#6864)) **CSS-in-JS conversions** - Converted `EuiButtonGroup` and `EuiButtonGroupButton` to Emotion ([#6841](elastic/eui#6841)) - Converted `EuiButtonIcon` to Emotion ([#6844](elastic/eui#6844)) - Converted `EuiButtonEmpty` to Emotion ([#6863](elastic/eui#6863)) - Converted `EuiCollapsibleNav` and `EuiCollapsibleNavGroup` to Emotion ([#6865](elastic/eui#6865)) - Removed Sass variables `$euiCollapsibleNavGroupLightBackgroundColor`, `$euiCollapsibleNavGroupDarkBackgroundColor`, and `$euiCollapsibleNavGroupDarkHighContrastColor` ([#6865](elastic/eui#6865)) --------- Co-authored-by: Cee Chen <constance.chen@elastic.co> Co-authored-by: Jeramy Soucy <jeramy.soucy@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
This PR converts
EuiButtonGroup
andEuiButtonGroupButton
to Emotion. I recommend following along by commit. TL;DR of changes:euiOutline()
CSS-in-JS util (a lighter weight version ofeuiFocusRing()
, without the focus-visible styles)EuiButtonDisplayDeprecated
in favor of the new internalEuiButtonDisplay
component, and then removesEuiButtonDisplayDeprecated
entirelyEuiButtonDisplay
usage)compressed
button groups now correctly use the same color as the button fillEuiButtonGroup
, making permutations significantly easier to testQA
EuiButtonDisplay
. I consider this to be an intentional change to match other existing buttonsgh pr checkout 6841
yarn storybook
General checklist
- [ ] Checked for breaking changes and labeled appropriately- Even thoughEuiButtonDisplayDeprecated
was deleted, this was not a publicly exported component and therefore is not a breaking change- [ ] Props have proper autodocs (using@default
if default values are missing) and playground toggles- [ ] Added documentation- [ ] Checked Code Sandbox works for any docs examples- [ ] Updated the Figma library counterpartEmotion checklist
Acceptance criteria
- [ ] All SCSS overrides have been removed from the Amsterdam theme- No overrides for this component- [ ] Any dependent components are identified in a new issueChecklists
Kibana usage
{euiComponent}-
(case sensitive) to check for usage of modifier classes- [ ] If usage exists, consider converting to a- Retaineddata
attribute so that consumers still have something to hook into.euiButtonGroupButton-isSelected
className, which is the primary modifier usageGeneral
className(s)
read as expected in snapshots and browsersUnit tests
shouldRenderCustomStyles()
test was added and passes with parent component and any nestedchildProps
(e.g.tooltipProps
)- [ ] Removed any mounted snapshotsSass/Emotion conversion process
src/components/index.scss
- [ ] Deleted anysrc/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
toeuiTheme.size.base
)- [ ] Removed or converted component-specific Sass vars/mixins to exported JS versions- [ ] Listed var/mixin removals in changelog- [ ] Ranyarn compile-scss
to update var/mixin JSON files- [ ] Simplifiedcalc()
tomathWithUnits
if possible (if mixing different unit types, this may not be possible)- [ ] Added an@warn
deprecation message within theglobal_styling/mixins/{component}.scss
fileCSS tech debt
euiCanAnimate
-inline
and-block
logical properties (check inline styles as well as CSS)- [ ] Usedgap
property to add margin between items if using flexDOM Cleanup
euiComponent
,euiComponent__child
)Kibana due diligence
**/target, **/*.snap, **/*.storyshot
for less noise) foreui{Component}
(case sensitive) to find:- [ ] Any test/query selectors that will need to be updatedNone- [ ] Any Sass or CSS that will need to be updated, particularly if a component Sass var was deletedNone- [ ] Any direct className usages that will need to be refactored (e.g. someone calling theNoneeuiBadge
class on a div instead of simply using theEuiBadge
component)Extras/nice-to-have
- [ ] Documentation pass- [ ] 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