-
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
[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
|
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, it makes the code way cleaner!
const { | ||
registry: { resizers } = { resizers: {} } as EuiResizableContainerRegistry, | ||
} = useEuiResizableContainerContext(); |
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.
Odd that VSCode would flag this and not our linter
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'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. 🤷
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.
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
EuiResizableButton
to 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/Y
currently does not respectdirection
orwriting-mode
and flex does.QA
display: none
General 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 adata
attribute 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
$euiSize
toeuiTheme.size.base
)or convertedcomponent-specific Sass vars/mixins to exported JS versions[ ] Ranyarn compile-scss
to update var/mixin JSON files[ ] Added an@warn
deprecation message within theglobal_styling/mixins/{component}.scss
file[ ] Simplifiedcalc()
tomathWithUnits
if 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}.scss
files (styles within should have been converted to the baseline Emotion styles)CSS tech debt
euiCanAnimate
gap
property to add margin between items if using flex-inline
and-block
logical properties (check inline styles as well as CSS)DOM Cleanup
euiComponent
,euiComponent__child
)Kibana due diligence
**/target, **/*.snap, **/*.storyshot
for less noise) foreui{Component}
(case sensitive) to find:euiBadge
class on a div instead of simply using theEuiBadge
component) - 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