-
Notifications
You must be signed in to change notification settings - Fork 840
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 EuiButtonIcon #6844
Conversation
abaad0b
to
a691211
Compare
- Remove `useEuiButtonRadiusCSS` in favor of a more agnostic `euiButtonSizeMap` - using the raw data is less strict and generates fewer classNames - `EuiButtonIcon` will shortly need the height/radius map and does not need to use all of `EuiButtonDisplay`'s logic (e.g. doesn't need fullWidth, or a content/text wrapper) - Move `_buttonSize` to internal fn to make it unexportable / clearer that its CSS is specific to `EuiButtonDisplay`
… to separate file
+ focus CSS comes from a hook
- this can mostly be simplified down from its Sass mixin to just the cursor CSS - the loading spinner color comment + logic is copied from `EuiButtonDisplay` - it previously existed in the `euiButtonContentDisabled` Sass mixin, but was targeting a selector that did not exist in EuiButtonIcon
+ convert enum types to new preferred syntax + move type enums to top of file
+ configure all playgrounds to sort props by required first, then alphabetical
a26c843
to
8c1b3b0
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_6844/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_6844/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_6844/ |
- preload all icons into the cache at once in the preview - this increases Storybook's startup time somewhat significantly, but will probably be necessary until we resolve dynamic icons for SSR/Vite
Preview documentation changes for this PR: https://eui.elastic.co/pr_6844/ |
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.
Great work with this Cee! The new DRY utils are nice and it's great to see patterns in EuiButtonIcon
being updated to match our other components.
I pulled locally to test and also compared staging against main and didn't find any visual changes. Storybook looks good as well.
❓ Question:
Is the isSelected
toggle supposed to change the state in our docs and Storybook? The behavior is the same in both places, so it's not a blocker. I just figured I would ask for my own knowledge.
When buttons are filled
or base
, there's no visual diff in whether the button is selected or not. For empty
, the button fills with the color, but I don't see that happen when I toggle isSelected
in the Playground or in Storybook.
EA36E09C-6A64-43CB-A086-B84292D69B9D_2_0_a.mov
const sizes = euiButtonSizeMap(euiThemeContext); | ||
|
||
const _buttonSize = (sizeKey: EuiButtonDisplaySizes) => { | ||
const size = sizes[sizeKey]; | ||
return css` | ||
${logicalCSS('height', size.height)} | ||
line-height: ${size.height}; /* Prevents descenders from getting cut off */ | ||
${euiFontSize(euiThemeContext, size.fontScale)} | ||
border-radius: ${size.radius}; | ||
`; | ||
}; |
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.
🧼 Super clean!
// When the button is disabled the text gets gray | ||
// and in some buttons the background gets a light gray | ||
// for better contrast we want to change the border of the spinner | ||
// to have the same color of the text. This way we ensure the borders | ||
// are always visible. The default spinner color could be very light. | ||
const loadingSpinnerColor = isDisabled | ||
? { border: 'currentcolor' } | ||
: undefined; | ||
|
||
buttonIcon = ( | ||
<EuiLoadingSpinner size={loadingSize} color={loadingSpinnerColor} /> | ||
); |
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.
Nice accessibility consideration!
export const SIZES = ['xs', 's', 'm'] as const; | ||
export type EuiButtonIconSizes = (typeof SIZES)[number]; | ||
|
||
export const DISPLAYS = keysOf(displayToClassNameMap); | ||
type EuiButtonIconDisplay = keyof typeof displayToClassNameMap; | ||
export const DISPLAYS = ['base', 'empty', 'fill'] as const; | ||
type EuiButtonIconDisplay = (typeof DISPLAYS)[number]; |
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.
Happy to see this being updated to the pattern we use in most other EUI components.
Great question! The |
Thanks a million for the speedy review Bree! |
`[email protected]` ⏩ `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 <[email protected]> Co-authored-by: Jeramy Soucy <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
Summary
This PR (hopefully) should be fairly quick to review/verify. Not a lot of major changes going on here (other than a million snapshots).
useEuiButtonRadiusCSS
hook in favor of a more agnosticeuiButtonSizeMap
- using the raw size data is less strict & generates fewer classNamesEuiButtonIcon
to Emotion, removing/cleaning up unnecessary CSS.euiButtonIcon--[size]
modifier classesisLoading
button icon spinners to have the same background color contrast as other button loading spinnersQA
EuiButtonIcon
's demo example looks the same between the twogh pr checkout 6844 && yarn storybook
EuiButtonIcon
playground and test multiple color/size permutations and confirm they look the same as beforeGeneral checklist
Emotion 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 issue- All dependent usages in EUI are calling the generic.euiButtonIcon
Checklists
Kibana usage
{euiComponent}-
(case sensitive) to check for usage of modifier classes- [ ] If usage exists, consider converting to a- no major Kibana usagesdata
attribute so that consumers still have something to hook intoGeneral
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
-inline
and-block
logical properties (check inline styles as well as CSS)- [ ] Usedgap
property to add margin between items if using flex- [ ] Wrapped all animations or transitions ineuiCanAnimate
DOM Cleanup
euiComponent
,euiComponent__child
)Kibana due diligence
**/target, **/*.snap, **/*.storyshot
for less noise) foreui{Component}
(case sensitive) to find:- [ ] Any Sass or CSS that will need to be updated, particularly if a component Sass var was deletedNoneeuiBadge
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