-
Notifications
You must be signed in to change notification settings - Fork 839
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
[EuiCollapsibleNavBeta] Various API updates and cleanups #7228
Conversation
+ provide Storybook examples of custom Kibana usage
- split it out from `EuiCollapsibleNavAccordion`
- usage is still fairly beta
- instead of relying on consumers to use `EuiFlyoutBody` and `EuiFlyoutFooter` directly
ca08339
to
3291371
Compare
@tsullivan @sebelga - I threw a quick sync on your calendars for tomorrow morning to quickly chat about the proposed API changes in the PR description and to make sure they actually meet your team's needs. Feel free to leave any comments/questions ahead of time for discussion. |
c762937
to
de3c73e
Compare
- a la `EuiPageTemplate` + update stories to use namespaced components instead of direct imports + add stories for the new group component
de3c73e
to
4b31809
Compare
Thanks for putting this together! Some thoughts: // instead of this...
<EuiCollapsibleNavItem items={[
{ renderItem: () => <EuiTitle size="xxxs"><div>something</EuiTitle></div> },
{ renderItem: () => <EuiSpacer size="m" /> },
{ renderItem: WhateverOtherCustomComponentYouWant },
}] /> // Why not this? ...
<EuiCollapsibleNavItem>
<EuiTitle size="xxxs"><div>something</EuiTitle>
<EuiSpacer size="m" />
<WhateverOtherCustomComponentYouWant />
<EuiCollapsibleNavItem> I just love declarative syntax 😊 You should be able to get the items with import { Children } from 'react';
...
const EuiCollapsibleNavItem = () => {
...
const items = Children.toArray(children) as React.ReactElement[];
} For the <EuiCollapsibleNavBeta.Group title="myGroup">
<EuiCollapsibleNavBeta.Item>
<div>Any content>
</EuiCollapsibleNavBeta.Item>
<EuiCollapsibleNavBeta.Item>
<div>Any content>
</EuiCollapsibleNavBeta.Item>
</EuiCollapsibleNavBeta.Group title="myGroup"> If need be you can filter and only get those const allChildren = Children.toArray(children) as React.ReactElement[];
const onlyItemChildren = allChildren.filter((child) => child.type === EuiCollapsibleNavItem); And solving elastic/kibana#167323 would be one step away 😊 <EuiCollapsibleNavBeta.Group title="myGroup" wrapInAccordion={false}>
<EuiCollapsibleNavBeta.Item>
<div>Any content>
</EuiCollapsibleNavBeta.Item>
...
</EuiCollapsibleNavBeta.Group title="myGroup"> |
Using children isn't efficient with the underlying logic/concerns that
Using
EUI has had to face this kind of API decision before (whether to use a specific prop for a limited set of child types, or to use children) and typically trying to use |
- They're using the `Body` component now anyway which handles scrolling, and they need to be able to display security flyouts outside the nav
Preview staging links for this PR:
|
💚 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.
👍 I have to say, Storybook feels like the piece that binds these big PRs together. Being able to review and edit data structures in real time is so helpful.
I like this sub-component approach a lot. Namespacing makes it clear what belongs to what.
// Since this is a nav, we can almost guarantee there will be clickable | ||
// children/links that will enable scrolling. As such, we're optimistically | ||
// removing the extra tab stop | ||
scrollableTabIndex={-1} |
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.
After a couple of hours thinking about this, I agree with this thinking. The component is designed to house focusable links, so users should have no issue scrolling.
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.
Thanks for sanity-checking this Trevor! FWIW it's overrideable if necessary as well, for edge cases, e.g. <EuiCollapsibleNavBeta.Body scrollableTabIndex={0}>
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.
Fantastic. Sensible defaults and overrides where necessary.
@cee-chen I made a mistake in my explanation but that's ok, your API aligns with other EUI APIs (e.g. Tabs) so it is consistent 😊 I still prefer a declarative API <SomeGroupElement title="Accordion title">
{/* Render custom content */}
<SomeGroupElement.Item id="foo">
<div>I can render anything I want</div>
</SomeGroupElement.Item>
{/* Use the default UI */}
<SomeGroupElement.Item id="bar" title="I use the default UI" icon="someIcon" />
</SomeGroupElement> than using props <SomeGroupElement title="Accordion title"
items={[{
id: "foo",
renderItem: () => <div>I can render anything I want</div>
}, {
id:"bar",
title:"I use the default UI",
icon: "someIcon"
}]}
/> The former feels more "react" and declarative to me, but that's just a preference. <SomeGroupElement title="Accordion title">
{/* Render custom content */}
<SomeGroupElement.Item id="foo">
<div>I can render anything I want</div>
</SomeGroupElement.Item>
{/* I need to add all this in my accordion! :) */}
<EuiSpacer size="l" />
<img src="/why-not-an-image.jpg" />
<div>Those JSX are just rendered as they appear, total freedom</div>
{/* ...back to nav items... */}
<SomeGroupElement.Item id="bar" title="I use the default UI" icon="someIcon" />
</SomeGroupElement> I am not trying to convince you to change anything though! 😊 Just sharing what a declarative API allows vs using props. |
`v88.5.0`⏩`v88.5.4` This EUI upgrade helps unblock the Shared UX team with some beta serverless nav updates not listed in the below changelog (elastic/eui#7228 and elastic/eui#7248). --- ## [`88.5.4`](https://github.com/elastic/eui/tree/v88.5.4) - This release contains internal changes to a beta component needed by Kibana. ## [`88.5.3`](https://github.com/elastic/eui/tree/v88.5.3) **Bug fixes** - Fixed `EuiComboBox` search input width not resetting correctly on selection ([#7240](elastic/eui#7240)) ## [`88.5.2`](https://github.com/elastic/eui/tree/v88.5.2) **Bug fixes** - Fixed broken `EuiTextTruncate` testenv mocks ([#7234](elastic/eui#7234)) ## [`88.5.1`](https://github.com/elastic/eui/tree/v88.5.1) - Improved the performance of `EuiComboBox` by removing the `react-autosizer-input` dependency ([#7215](elastic/eui#7215)) **Dependency updates** - Updated `react-element-to-jsx-string` to v5.0.0 ([#7214](elastic/eui#7214)) - Removed unused `@types/vfile-message` dependency ([#7214](elastic/eui#7214))
Summary
This PR does multiple different things:
Removes
isGroupTitle
logic in favor of a wildcardrenderItem
(c12fb27)Old prop API:
New prop API:
I'm opting for this API over the old one because 1. it's simpler code and type-wise, and 2. it places the onus of consistent title and spacing styling directly on Kibana and not on EUI, and 3. it's a potential escape hatch for future customization (e.g. a button that toggles another flyout).
This new API should address elastic/kibana#167326
Adds
EuiCollapsibleNav.[SubComponent]
exports (3291371)Old API:
New API:
The goal of this architecture is to 1. reduce separate imports, 2. more clearly scope subcomponents only intended to be used within the new EuiCollapsibleNavBeta component, and 3. match existing component architecture for template-level components, e.g.
EuiPageTemplate.Section
.Adds new
EuiCollapsibleNavBeta.Group
top level component (#7208)New API:
Please note that this new component DOES NOT address elastic/kibana#167323 and is not meant to. This new component, per Ryan's designs specifications and screencaps in #7208, is ONLY meant to be used as a top-level component (not as a subitem or in the footer), and has very specific styling and considerations for the desktop docked state.
I'd like to discuss the potential Kibana-side options for elastic/kibana#167323 more before implementing this at the EUI level. bc1e8a2 is one example of something Kibana could do with no intervention from EUI.
QA
General checklist
- [ ] Checked for accessibility including keyboard-only and screenreader modesand cypress tests