-
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
[EuiProvider] Set up componentDefaults
prop, context, & documentation
#6923
[EuiProvider] Set up componentDefaults
prop, context, & documentation
#6923
Conversation
+ light tests - actual defaults/override tests should be written per-component
25f47e7
to
663b7ac
Compare
componentDefaults
context + documentationcomponentDefaults
prop, context, & documentation
const badge = (isBeta || isNew) && ( | ||
<EuiBetaBadge label={isBeta ? 'Beta' : 'New'} color="accent" size="s" /> | ||
); | ||
|
||
titleNode = ( | ||
<> | ||
<EuiTitle> | ||
<h2 id={id}>{title}</h2> | ||
<h2 id={id}> | ||
{title} | ||
{badge && <> {badge}</>} | ||
</h2> |
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.
Just want to note that I know this new beta/new badge logic for subsections (de3cfc2) is not terribly clean and is pretty repetitive with the existing beta/new badge logic, but I'm not bothering to get super DRY or fancy with it since we're migrating all our docs to EUI+ at some point in the future.
// Declaring as a static const for reference integrity/reducing rerenders | ||
const emptyDefaults = {}; |
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 not sure how necessary this is, but I recall = {}
defaults in destructuring causing rerender/reinstantation issues previously, and I figure better safe than sorry with things like this that exist at the top level of the app.
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.
It should be fine here because createContext
will be called only once when executing the contents of the file in runtime and props defaults will only execute when componentDefaults
is initialized or updated with undefined
value (see PropertyDestructuringAssignmentEvaluation section of EcmaScript specification)
Preview documentation changes for this PR: https://eui.elastic.co/pr_6923/ |
/** | ||
* Provide a global setting for EuiPortal's default insertion position. | ||
*/ | ||
EuiPortal?: { insert: EuiPortalProps['insert'] }; |
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 cribbed this prop doc copy from @y1j2x34's excellent community PR: https://github.com/elastic/eui/pull/6889/files#diff-a327a1618b19bc3a89edef20304da7b7dcbe3cf879362a00ea48d08864e719f9R67
But as always, feel free to leave copy suggestions!
663b7ac
to
7728a18
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_6923/ |
@elastic/eui-team 👋 Hey y'all! I'm not assigning this PR to any one specific dev, but would love to hear from you all on this. @tkajtoch, I know you're busy with docsmobile work, but IIRC you commented on the original convo w/ Clint for this work - please let me know if you'd rather hold this PR until you've had a chance to review it. BTW, crazy thought - part of me wonders how abstract we could get with this architecturally. Could we allow every component to obtain its defaults from this provider/context? 🤔 e.g., what if someone wanted all their |
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 is a cool notion of global prop configuration. Referencing the community PR was a big help bridging the foundation work here and the end goal of adding the new Provider to EuiProvider
.
I think we could extend component defaults, with a caveat I trend toward a conservative addition arc. Thinking out loud, if we ran a poll after the feature ships asking our community what components they'd like to see set globally, we might get a good sense where to put our energy.
/** | ||
* Provide a global setting for EuiPortal's default insertion position. | ||
*/ | ||
EuiPortal?: { insert: EuiPortalProps['insert'] }; |
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.
EuiPortal?: { insert: EuiPortalProps['insert'] }; | |
EuiPortal?: Partial<Pick<EuiPortalProps, 'insert'>>; |
What do you think of doing this instead with the future goal of replacing it with just Partial<EuiPortalProps>
when we're ready to support all props?
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 hesitant to expand this so soon, I think I'd rather stick to specific usages for now (per our beta callout) and expand it later when we consciously decide to.
If a consumer really wants to they could @ts-ignore
and pass in other global EUI props in any case and that would work; so the support is technically there, but I don't want to be explicit about it just yet. Also, EuiPortal doesn't really have any other props (options are children
and a ref function) that make sense to be configured globally vs per-instance in any case 😅
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 love to see this feature getting real! Thank you Cee for driving this effort. |
Thank you all for your feedback. Going to go ahead and merge this into the feature branch (assuming comments or lack of objections count as approvals, as this PR has been open for several days now). There's still time to leave more feedback before the feature branch merges, so shout out whenever! |
…on (#6923) * Set up `EuiComponentDefaultsProvider` + light tests - actual defaults/override tests should be written per-component * Add documentation * Add support for beta/new badges to subitems in nav and subheadings * changelog
…on (elastic#6923) * Set up `EuiComponentDefaultsProvider` + light tests - actual defaults/override tests should be written per-component * Add documentation * Add support for beta/new badges to subitems in nav and subheadings * changelog
…on (elastic#6923) * Set up `EuiComponentDefaultsProvider` + light tests - actual defaults/override tests should be written per-component * Add documentation * Add support for beta/new badges to subitems in nav and subheadings * changelog
…on (elastic#6923) * Set up `EuiComponentDefaultsProvider` + light tests - actual defaults/override tests should be written per-component * Add documentation * Add support for beta/new badges to subitems in nav and subheadings * changelog
…on (#6923) * Set up `EuiComponentDefaultsProvider` + light tests - actual defaults/override tests should be written per-component * Add documentation * Add support for beta/new badges to subitems in nav and subheadings * changelog
…on (elastic#6923) * Set up `EuiComponentDefaultsProvider` + light tests - actual defaults/override tests should be written per-component * Add documentation * Add support for beta/new badges to subitems in nav and subheadings * changelog
…on (elastic#6923) * Set up `EuiComponentDefaultsProvider` + light tests - actual defaults/override tests should be written per-component * Add documentation * Add support for beta/new badges to subitems in nav and subheadings * changelog
`v86.0.0`⏩`v87.1.0`⚠️ The biggest set of type changes in this PR come from the breaking change that makes `pageSize` and `pageSizeOptions` now optional props for `EuiBasicTable.pagination`, `EuiInMemoryTable.pagination` and `EuiDataGrid.pagination`. This caused several other components that were cloning EUI's pagination type to start throwing type warnings about `pageSize` being optional. Where I came across these errors, I modified the extended types to require `pageSize`. These types and their usages may end up changing again in any case once the Shared UX team looks into #56406. --- ## [`87.1.0`](https://github.com/elastic/eui/tree/v87.1.0) - Updated the underlying library powering `EuiAutoSizer`. This primarily affects typing around the `disableHeight` and `disableWidth` props ([#6798](elastic/eui#6798)) - Added new `EuiAutoSize`, `EuiAutoSizeHorizontal`, and `EuiAutoSizeVertical` types to support `EuiAutoSizer`'s now-stricter typing ([#6798](elastic/eui#6798)) - Updated `EuiDatePickerRange` to support `compressed` display ([#7058](elastic/eui#7058)) - Updated `EuiFlyoutBody` with a new `scrollableTabIndex` prop ([#7061](elastic/eui#7061)) - Added a new `panelMinWidth` prop to `EuiInputPopover` ([#7071](elastic/eui#7071)) - Added a new `inputPopoverProps` prop for `EuiRange`s and `EuiDualRange`s with `showInput="inputWithPopover"` set ([#7082](elastic/eui#7082)) **Bug fixes** - Fixed `EuiToolTip` overriding instead of merging its `aria-describedby` tooltip ID with any existing `aria-describedby`s ([#7055](elastic/eui#7055)) - Fixed `EuiSuperDatePicker`'s `compressed` display ([#7058](elastic/eui#7058)) - Fixed `EuiAccordion` to remove tabbable children from sequential keyboard navigation when the accordion is closed ([#7064](elastic/eui#7064)) - Fixed `EuiFlyout`s to accept custom `aria-describedby` IDs ([#7065](elastic/eui#7065)) **Accessibility** - Removed the default `dialog` role and `tabIndex` from push `EuiFlyout`s. Push flyouts, compared to overlay flyouts, require manual accessibility management. ([#7065](elastic/eui#7065)) ## [`87.0.0`](https://github.com/elastic/eui/tree/v87.0.0) - Added beta `componentDefaults` prop to `EuiProvider`, which will allow configuring certain default props globally. This list of components and defaults is still under consideration. ([#6923](elastic/eui#6923)) - `EuiPortal`'s `insert` prop can now be configured globally via `EuiProvider.componentDefaults` ([#6941](elastic/eui#6941)) - `EuiFocusTrap`'s `crossFrame` and `gapMode` props can now be configured globally via `EuiProvider.componentDefaults` ([#6942](elastic/eui#6942)) - `EuiTablePagination`'s `itemsPerPage`, `itemsPerPageOptions`, and `showPerPageOptions` props can now be configured globally via `EuiProvider.componentDefaults` ([#6951](elastic/eui#6951)) - `EuiBasicTable`, `EuiInMemoryTable`, and `EuiDataGrid` now allow `pagination.pageSize` to be undefined. If undefined, `pageSize` defaults to `EuiTablePagination`'s `itemsPerPage` component default. ([#6993](elastic/eui#6993)) - `EuiBasicTable`, `EuiInMemoryTable`, and `EuiDataGrid`'s `pagination.pageSizeOptions` will now fall back to `EuiTablePagination`'s `itemsPerPageOptions` component default. ([#6993](elastic/eui#6993)) - Updated `EuiHeaderLinks`'s `gutterSize` spacings ([#7005](elastic/eui#7005)) - Updated `EuiHeaderAlert`'s stacking styles ([#7005](elastic/eui#7005)) - Added `toolTipProps` to `EuiListGroupItem` that allows customizing item tooltips. ([#7018](elastic/eui#7018)) - Updated `EuiBreadcrumbs` to support breadcrumbs that toggle popovers via `popoverContent` and `popoverProps` ([#7031](elastic/eui#7031)) - Improved the contrast ratio of disabled titles within `EuiSteps` and `EuiStepsHorizontal` to meet WCAG AA guidelines. ([#7032](elastic/eui#7032)) - Updated `EuiSteps` and `EuiStepsHorizontal` to highlight and provide a more clear visual indication of the current step ([#7048](elastic/eui#7048)) **Bug fixes** - Single uses of `<EuiHeaderSectionItem side="right" />` now align right as expected without needing a previous `side="left"` sibling. ([#7005](elastic/eui#7005)) - `EuiPageTemplate` now correctly displays `panelled={true}` ([#7044](elastic/eui#7044)) **Breaking changes** - `EuiTablePagination`'s default `itemsPerPage` is now `10` (was previously `50`). This can be configured through `EuiProvider.componentDefaults`. ([#6993](elastic/eui#6993)) - `EuiTablePagination`'s default `itemsPerPageOptions` is now `[10, 25, 50]` (was previously `[10, 20, 50, 100]`). This can be configured through `EuiProvider.componentDefaults`. ([#6993](elastic/eui#6993)) - Removed `border` prop from `EuiHeaderSectionItem` (unused since Amsterdam theme) ([#7005](elastic/eui#7005)) - Removed `borders` object configuration from `EuiHeader.sections` ([#7005](elastic/eui#7005)) **CSS-in-JS conversions** - Converted `EuiHeaderAlert` to Emotion; Removed unused `.euiHeaderAlert__dismiss` CSS ([#7005](elastic/eui#7005)) - Converted `EuiHeaderSection`, `EuiHeaderSectionItem`, and `EuiHeaderSectionItemButton` to Emotion ([#7005](elastic/eui#7005)) - Converted `EuiHeaderLinks` and `EuiHeaderLink` to Emotion; Removed `$euiHeaderLinksGutterSizes` Sass variables ([#7005](elastic/eui#7005)) - Removed `$euiHeaderBackgroundColor` Sass variable; use `$euiColorEmptyShade` instead ([#7005](elastic/eui#7005)) - Removed `$euiHeaderChildSize` Sass variable; use `$euiSizeXXL` instead ([#7005](elastic/eui#7005)) --------- Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Patryk Kopyciński <[email protected]>
Summary
This PR sets up the prop, context, and documentation for an
<EuiProvider componentDefaults={}>
API that be used so that certain components (to be discussed) can have various settings configured at a global level instead of needing to be set on every instance.I recommend following along by commit for review, as the last commit adds some nice-to-have (but not required) logic for adding badges to sub-sections of pages.
QA
General checklist
@default
if default values are missing)and playground togglesand cypress tests- [ ] Checked in both light and dark modes- [ ] Checked in mobile- [ ] Checked in Chrome, Safari, Edge, and Firefox- [ ] Checked Code Sandbox works for any docs examples- [ ] Checked for breaking changes and labeled appropriately- [ ] Checked for accessibility including keyboard-only and screenreader modes- [ ] Updated the Figma library counterpart