-
Notifications
You must be signed in to change notification settings - Fork 829
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] Add globalStyles
prop for customization
#5497
Conversation
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/ |
cache?: EmotionCache; | ||
} | ||
|
||
export const EuiProvider = <T extends {} = {}>({ | ||
cache, | ||
theme = EuiThemeAmsterdam, | ||
globalStyles: GlobalStyles = EuiGlobalStyles, |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
EuiProvider
instance - In the future,
EuiProvider
will likely also include i18n and other features- The Kibana provider that wraps
EuiProvider
will need access to all that data - That is,
EuiThemeProvider
isn'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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/ |
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.
Ok, I tried to re-word that example text to better explain, based on your explanation.
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/ |
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.
Changes LGTM! Pulled & tested locally
Summary
EuiGlobalStyles
to allow for custom compositionglobalStyles
prop toEuiProvider
to enable custom or no global stylesEuiProvider
instances are loaded and we want to eliminate duplicating global styles@emotion
dependenciesChecklist