Skip to content

Commit

Permalink
Provide React Context composition; new Kibana Context, consolidate/de…
Browse files Browse the repository at this point in the history
…precate.
  • Loading branch information
clintandrewhall committed Jun 1, 2023
1 parent 0e6b153 commit cd5d125
Show file tree
Hide file tree
Showing 62 changed files with 539 additions and 497 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ src/plugins/presentation_util @elastic/kibana-presentation
x-pack/plugins/profiling @elastic/profiling-ui
x-pack/packages/kbn-random-sampling @elastic/kibana-visualizations
packages/kbn-react-field @elastic/kibana-data-discovery
packages/react/kibana_context @elastic/appex-sharedux
packages/react/kibana_mount @elastic/appex-sharedux
x-pack/plugins/remote_clusters @elastic/platform-deployment-management
test/plugin_functional/plugins/rendering_plugin @elastic/kibana-core
packages/kbn-repo-file-maps @elastic/kibana-operations
Expand Down
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"newsfeed": "src/plugins/newsfeed",
"presentationUtil": "src/plugins/presentation_util",
"randomSampling": "x-pack/packages/kbn-random-sampling",
"reactPackages": "packages/react",
"textBasedEditor": "packages/kbn-text-based-editor",
"reporting": "packages/kbn-reporting/common",
"savedObjects": "src/plugins/saved_objects",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,8 @@
"@kbn/profiling-plugin": "link:x-pack/plugins/profiling",
"@kbn/random-sampling": "link:x-pack/packages/kbn-random-sampling",
"@kbn/react-field": "link:packages/kbn-react-field",
"@kbn/react-kibana-context": "link:packages/react/kibana_context",
"@kbn/react-kibana-mount": "link:packages/react/kibana_mount",
"@kbn/remote-clusters-plugin": "link:x-pack/plugins/remote_clusters",
"@kbn/rendering-plugin": "link:test/plugin_functional/plugins/rendering_plugin",
"@kbn/repo-info": "link:packages/kbn-repo-info",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,31 @@
* Side Public License, v 1.
*/

import React, { FC } from 'react';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import React, { FC, useMemo } from 'react';
import type { I18nStart } from '@kbn/core-i18n-browser';
import { CoreThemeProvider } from './core_theme_provider';
import { composeProviders, KibanaThemeProvider } from '@kbn/react-kibana-context';
import { ThemeServiceStart } from '@kbn/core-theme-browser/src/types';

interface CoreContextProviderProps {
theme: ThemeServiceStart;
i18n: I18nStart;
theme: ThemeServiceStart;
globalStyles?: boolean;
}

/**
* utility component exposing all the context providers required by core when integrating with react
* Utility component exposing all the context providers required by core when integrating with React.
**/
export const CoreContextProvider: FC<CoreContextProviderProps> = ({
i18n,
theme,
children,
theme,
globalStyles = false,
}) => {
// `globalStyles` and `utilityClasses` default values are inverted from that of `EuiProvider`.
// Default to `false` (does not add EUI global styles) because more instances use that value.
// A value of `true` (does add EUI global styles) will have `EuiProvider` use its default value.
const includeGlobalStyles = globalStyles === false ? false : undefined;
const Provider = useMemo(() => composeProviders([i18n.Context, KibanaThemeProvider]), [i18n]);

return (
<i18n.Context>
<CoreThemeProvider theme$={theme.theme$} globalStyles={includeGlobalStyles}>
{children}
</CoreThemeProvider>
</i18n.Context>
<Provider theme$={theme.theme$} {...{ globalStyles }}>
{children}
</Provider>
);
};
Loading

0 comments on commit cd5d125

Please sign in to comment.