[Emotion] Convert EuiResizableButton#7081
Conversation
- not sure why tsc wasn't picking up on this 🤷
- mostly for custom styles testing, but we might as well write some missing unit tests while we're here
- for code coverage, because I'm incredibly anal + misc code cleanup - optional chaining syntax, remove unneccessary fn declarations
in favor of JS logic + HTML attribute - `hidden` is equivalent to `display: none` and is not overrideable via CSS and thus does not require an important - this cleanup allows us to remove unnecessary `:disabled` selectors in favor of simpler ones - if the button is disabled, we can assume it's never visible or interactable
+ remove $euiResizableButtonTransitionSpeed
+ Remove all now-unnecessary modifier clases + Remove `$euiResizableButtonSize` Sass var
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_7081_buildkite/ |
- vs absolute positioning/transforms Doing this has two major benefits: - The hover/focus animations were broken on Safari in production, and this fixes that - CSS transform do not respect logical properties and flex does, so this automatically makes the component fully direction/writing-mode compatible for less code :)
14039f7 to
78e57b8
Compare
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_7081_buildkite/ |
The `hidden` attribute sadly gets overridden by the new `display: flex`, so we need to restore the `:disabled { display: none }` selector
|
As a heads up, I'm planning on following up this PR not just with another
|
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_7081_buildkite/ |
💚 Build Succeeded
History
|
breehall
left a comment
There was a problem hiding this comment.
Hey Cee, I just have a question here about the decision to hide the resizable button when not in use. Other than that, this conversion looks good. Here was my review process:
- Reviewed the Sass conversion to ensure it's in parody with production. Loved the CSS refactor with flex
- Ensured the resizable button is hidden in the DOM when a panel is toggled off in the docs
- Observed improved transitions in Safari due to the CSS refactor
| it('renders as disabled if the disabled prop is passed', () => { | ||
| const { container } = render(<EuiResizableButton disabled />, { | ||
| wrapper, | ||
| }); | ||
|
|
||
| expect(container.firstChild).toBeDisabled(); | ||
| }); |
There was a problem hiding this comment.
Can I ask why we choose to render the button as disabled with the style display:none instead of removing it from the DOM when it's not in use by a resizable panel?
There was a problem hiding this comment.
I'm honestly not sure - I think it was part of the original component design and I can't say exactly why those devs chose to go with display: none vs simply not rendering anything.
I did play around with returning null if disabled, but in the end I decided against it - the potential for downstream impacts felt too large for what was supposed to be "just" an Emotion conversion. Also, the 'collapsed' content uses a similar paradigm (display: none on all children) so I felt like it made sense to keep that for now so they stay in-line with one another.
There was a problem hiding this comment.
the potential for downstream impacts felt too large for what was supposed to be "just" an Emotion conversion
Totally makes sense, I was just curious!
| flex-shrink: 0; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| gap: ${mathWithUnits(grabHandleHeight, (x) => x * 2)}; | ||
|
|
||
| /* 1 */ | ||
| &:hover, | ||
| &:focus { | ||
| gap: 0; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| ${euiCanAnimate} { | ||
| transition: gap ${transition}, justify-content ${transition}; | ||
| } |
There was a problem hiding this comment.
[Attaching to closes code snippet] This is a nice update. Flex is easier to visualize and understand when looking at the code (at least for me)!
There was a problem hiding this comment.
Agreed, it makes the code way cleaner!
| const { | ||
| registry: { resizers } = { resizers: {} } as EuiResizableContainerRegistry, | ||
| } = useEuiResizableContainerContext(); |
There was a problem hiding this comment.
Odd that VSCode would flag this and not our linter
There was a problem hiding this comment.
I've had 1:1 disparities between vscode types and CLI tsc in the past, so it's not terribly uncommon, but it is mildly annoying. I think vscode is a bit more opinionated than the CLI is. 🤷
breehall
left a comment
There was a problem hiding this comment.
Thank you for taking a look at my question. Everything has been answered and I have no further questions.
|
Thanks Bree! |
`87.1.0` ➡️ `87.2.0` ## [`87.2.0`](https://github.com/elastic/eui/tree/v87.2.0) - `EuiResizableButton` is now available as a generic top-level export ([#7087](elastic/eui#7087)) - Added new `alignIndicator` prop to `EuiResizableButton`. Defaults to `center`, and can now additionally be configured to `start` and `end` ([#7087](elastic/eui#7087)) - Updated `useGeneratedHtmlId` hook to use `React.useId` as the source of unique identifiers when available ([#7095](elastic/eui#7095)) **CSS-in-JS conversions** - Converted `EuiResizableButton` to Emotion; Removed `$euiResizableButtonTransitionSpeed` and `$euiResizableButtonSize` ([#7081](elastic/eui#7081)) - Converted `EuiResizableCollapseButton` to Emotion ([#7091](elastic/eui#7091)) --------- Co-authored-by: Cee Chen <constance.chen@elastic.co>
Summary
#6408
EuiResizableButtonto EmotionEuiResizableCollapseButton. That conversion + this one was getting fairly gnarly, so I opted to leave it separate to make review easier.EuiResizableButton, including adding unit tests that were previously missing, and gets component code coverage up to 100%transform: translateX/Ycurrently does not respectdirectionorwriting-modeand flex does.QA
display: noneGeneral checklist
- [ ] Checked in mobileand cypress testsEmotion checklist
Kibana usage
{euiComponent}-(case sensitive) to check for usage of modifier classes[ ] If usage exists, consider converting to adataattribute so that consumers still have something to hook intoGeneral
className(s)read as expected in snapshots and browsers[ ] Checked component playgroundUnit tests
shouldRenderCustomStyles()test was added and passes with parent component and any nestedchildProps(e.g.tooltipProps)[ ] Removed anymount()ed snapshots in favor ofrender()or a more specific assertionSass/Emotion conversion process
$euiSizetoeuiTheme.size.base)or convertedcomponent-specific Sass vars/mixins to exported JS versions[ ] Ranyarn compile-scssto update var/mixin JSON files[ ] Added an@warndeprecation message within theglobal_styling/mixins/{component}.scssfile[ ] Simplifiedcalc()tomathWithUnitsif possible (if mixing different unit types, this may not be possible)[ ] Removed component from- Not doable yetsrc/components/index.scss[ ] Deleted anysrc/amsterdam/overrides/{component}.scssfiles (styles within should have been converted to the baseline Emotion styles)CSS tech debt
euiCanAnimategapproperty to add margin between items if using flex-inlineand-blocklogical properties (check inline styles as well as CSS)DOM Cleanup
euiComponent,euiComponent__child)Kibana due diligence
**/target, **/*.snap, **/*.storyshotfor less noise) foreui{Component}(case sensitive) to find:euiBadgeclass on a div instead of simply using theEuiBadgecomponent) - No usagesExtras/nice-to-have
[ ] Documentation pass:[ ] Check for issues in the backlog that could be a quick fix for that component- Will be opening up a follow-up PR for this[ ] Optional component/code cleanup: consider splitting up the component into multiple children if it's overly verbose or difficult to reason about