-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Create a theming React context provider integration for applications #108972
Comments
Pinging @elastic/kibana-core (Team:Core) |
To summarize our previous sync discussions:
An example of using the theme context provider when mounting an app could look like: public setup(core: CoreSetup, deps: {}) {
core.application.register({
id: 'foo',
title: 'Foo',
mount: async ({ element }: AppMountParameters) => {
const [{ theme }] = await core.getStartServices()
ReactDOM.render(wrapWithTheme(<MyApp {...myParameters} />, theme.getTheme$()), element);
return () => unmountComponentAtNode(element);
},
});
} Ideally, we could even expose this theme information from the If we can't, we may want to investigate the option to expose this Note: If we choose to expose this API from the In that case, the API would look like: public setup(core: CoreSetup, deps: {}) {
core.application.register({
id: 'foo',
title: 'Foo',
mount: async ({ element, theme$ }: AppMountParameters) => {
ReactDOM.render(wrapWithTheme(<MyApp {...myParameters} />, theme$), element);
return () => unmountComponentAtNode(element);
},
});
} The context provider component could also directly be exposed from public setup(core: CoreSetup, deps: {}) {
core.application.register({
id: 'foo',
title: 'Foo',
mount: async ({ element, theme$ }: AppMountParameters) => {
ReactDOM.render(<KibanaThemeContextProvider theme={theme$}><MyApp {...myParameters} /></>, element);
return () => unmountComponentAtNode(element);
},
});
} Also, some parts of the applications rely on The best we can do would be to add a new const toMountPoint = (node: React.ReactNode): MountPoint would become const toMountPoint = (node: React.ReactNode, options?: { theme$: Obvervable<CoreTheme>} ): MountPoint when the option is provided, we would wrap the provided react node with the new EDIT: After thinking about it, I'm not sure the cc @chandlerprall @thompsongl @cchaos Does that seems alright? any comment or addition? |
We'll have the ability to ask a context for a complete representation/snapshot of its themed values, maybe that can be forwarded to the new mount point as the starting point for that subsequent mounted context? |
Yea, that's what I was thinking about. But in that case, we'll be working with the 'raw' EUI context, not the const toMountPoint = (node: React.ReactNode, options?: { theme$: Obvervable<CoreTheme>} ): MountPoint should probably instead be const toMountPoint = (node: React.ReactNode, options?: { theme: EuiTheme} ): MountPoint or it could even accept both. The implementation is fairly trivial either way, I guess we'll see with the first usages. |
#110998 will be the EUI bump that will expose the new |
#110998 has been merged, we should be ready to start this one. |
@pgayvallet Let us know if the EUI team can help in any way here! |
@thompsongl thanks, will do. FYI, this is planned for our next sprint. If we have extra capacity, we'll try to fit it into the current. |
I created #118866 to track the integration of the |
Closed because core's work on the issue is done. Meta issue to track each team's usage of the new provider is here: #118866 |
EUI is close to merging our theming layer (elastic/eui#4511) which relies on React's context to give applications means of overriding theme values for the application and at specific nodes/branches in its component tree. When this has landed in EUI (with emotion functionality coming later), we'll be ready for the application mount points in Kibana to be updated to include this new context provider.
The text was updated successfully, but these errors were encountered: