[EuiProvider] Add globalStyles prop for customization#5497
[EuiProvider] Add globalStyles prop for customization#5497thompsongl merged 16 commits intoelastic:mainfrom
globalStyles prop for customization#5497Conversation
globalStyles prop for customization
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5497/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5497/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5497/ |
| export const EuiProvider = <T extends {} = {}>({ | ||
| cache, | ||
| theme = EuiThemeAmsterdam, | ||
| globalStyles: GlobalStyles = EuiGlobalStyles, |
There was a problem hiding this comment.
Should the default be undefined instead? My guess is that most consumer's of multiple providers won't realize they need to remove the global styles. But likely, they'll notice they need to add it in order to fix the base styles.
Or should we be recommending two different providers. For instance this is just the theme provider, so should Kibana's multiple instances just switch to using the theme provider?
There was a problem hiding this comment.
The summary might be overly concerned with multiple providers. The reasons for having default global styles but allowing for their removal are that:
- Custom themes need to remove default global styles
- With the exception of Kibana, apps will only have one
EuiProviderinstance - In the future,
EuiProviderwill likely also include i18n and other features- The Kibana provider that wraps
EuiProviderwill need access to all that data - That is,
EuiThemeProviderisn't enough, but we need a way to prevent duplicate global styles (again, this very likely only affect Kibana)
- The Kibana provider that wraps
There was a problem hiding this comment.
very likely only affect Kibana
This is specifically where I worry that Kibana engineers will not know that they need to remove the global styles, making them compound or override. What is your plan to educate those engineers about this workaround?
There was a problem hiding this comment.
All instances of EuiProvider (4 right now; unlikely to increase) are in mount-point components maintained by the core team. They all use the same pattern and I can leave comments in the 3 that do not need global styles explaining the difference.
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5497/ |
cchaos
left a comment
There was a problem hiding this comment.
Ok, I tried to re-word that example text to better explain, based on your explanation.
| ## Global styles | ||
|
|
||
| A reset stylesheet and the global EUI styles are applied via Emotion. To prevent loading these styles from loading, pass `theme={null}` to the provider. | ||
| A reset stylesheet and the global EUI styles are applied via Emotion. To prevent loading these styles from loading, pass `globalStyles={false}` to the provider. If you are using the legacy theme, we recommend passing `theme={null}` to achieve similar results. |
There was a problem hiding this comment.
| A reset stylesheet and the global EUI styles are applied via Emotion. To prevent loading these styles from loading, pass `globalStyles={false}` to the provider. If you are using the legacy theme, we recommend passing `theme={null}` to achieve similar results. | |
| The provider includes general reset and global styles, applied via Emotion. These only need to be applied **once** so to prevent these styles from loading in nested instances of the provider, pass `globalStyles={false}`. |
There was a problem hiding this comment.
We also really need to move this doc to real docs example page so that we can change the provider setup example based on the currently selected theme. I don't think anyone will catch that sentence you added.
There was a problem hiding this comment.
Converted the docs and made the code blocks update based on the docs theme selections.
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5497/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5497/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5497/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5497/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5497/ |
chandlerprall
left a comment
There was a problem hiding this comment.
Changes LGTM! Pulled & tested locally
Summary
EuiGlobalStylesto allow for custom compositionglobalStylesprop toEuiProviderto enable custom or no global stylesEuiProviderinstances are loaded and we want to eliminate duplicating global styles@emotiondependenciesChecklist