mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 10:40:07 -04:00
> Pre-req for https://github.com/elastic/kibana/issues/56406
## Summary
We've had a long-standing problem in Kibana around our use of React
context, particularly with EUI and i18n. There hasn't existed an
idempotent context structure, and that has lead to a lot of unexpected
results, (e.g. missing translations, inconsistent dark mode, excess
context providers, etc).
The biggest change coming from this PR is knowing exactly which provider
to use in a particular use case. This means, for example,
`ReactDOM.render` calls won't be missing `i18n` or `theme` due to a
missing context. It also allows consumers to use `darkMode` without
having to read the `uiSetting` themselves, instead allowing the context
to do it for them.
We also haven't been honoring the intended [`EuiProvider`
API](https://eui.elastic.co/#/utilities/provider#theming-and-global-styles)...
in some cases we've been creating and re-creating the Emotion caches,
often by copy/paste of the cache code. We've also been nesting
`EuiThemeProvider` contexts unnecessarily-- thinking we need to render a
theme provider in an isolated component-- which renders an additional
`span` element into the DOM.
This PR attempts to address this inconsistency by creating a set of
context providers divided by use case:
![diagram](
|
||
---|---|---|
.. | ||
test_helpers | ||
index.ts | ||
jest.config.js | ||
kibana.jsonc | ||
mount_point_portal.test.tsx | ||
mount_point_portal.tsx | ||
package.json | ||
README.md | ||
to_mount_point.test.tsx | ||
to_mount_point.tsx | ||
tsconfig.json | ||
utils.ts |
@kbn/react-kibana-mount
Empty package generated by @kbn/generate