Skip to content

Commit

Permalink
Update to remove provider composer; prep for commit
Browse files Browse the repository at this point in the history
  • Loading branch information
clintandrewhall committed Jul 11, 2023
1 parent 07103a0 commit 50f0d3a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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

interface CoreContextProviderProps {
Expand All @@ -18,19 +18,19 @@ interface CoreContextProviderProps {
}

/**
* Utility component exposing all the context providers required by core when integrating with React.
* Utility component exposing all the context providers required by Kibana when integrating with React.
**/
export const CoreContextProvider: FC<CoreContextProviderProps> = ({
i18n,
children,
theme,
globalStyles = false,
}) => {
const Provider = composeProviders([i18n.Context, KibanaThemeProvider]);

return (
<Provider theme$={theme.theme$} {...{ globalStyles }}>
{children}
</Provider>
<i18n.Context>
<KibanaThemeProvider theme$={theme.theme$} {...{ globalStyles }}>
{children}
</KibanaThemeProvider>
</i18n.Context>
);
};
2 changes: 0 additions & 2 deletions packages/react/kibana_context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ export {
withKibanaContextProvider,
type KibanaContextProviderProps,
} from './provider';

export { composeProviders } from './utils';
6 changes: 1 addition & 5 deletions packages/react/kibana_context/provider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@
* Side Public License, v 1.
*/

export {
KibanaContextProvider,
withKibanaContextProvider,
type KibanaContextProviderProps,
} from './kibana_provider';
export { KibanaContextProvider, type KibanaContextProviderProps } from './kibana_provider';
20 changes: 0 additions & 20 deletions packages/react/kibana_context/provider/kibana_provider.ts

This file was deleted.

28 changes: 28 additions & 0 deletions packages/react/kibana_context/provider/kibana_provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React, { FC } from 'react';
import { I18nProvider } from '@kbn/i18n-react';

import { KibanaThemeProvider, type KibanaThemeProviderProps } from '../theme';

/** Props for the KibanaContextProvider */
export type KibanaContextProviderProps = KibanaThemeProviderProps;

/**
* The `KibanaContextProvider` provides the necessary context for Kibana's React components, including
* the theme and i18n context. In almost all cases, this provider should appear early in any plugin's
* React trees.
*/
export const KibanaContextProvider: FC<KibanaContextProviderProps> = ({ children, ...props }) => {
return (
<I18nProvider>
<KibanaThemeProvider {...props}>{children}</KibanaThemeProvider>
</I18nProvider>
);
};
38 changes: 0 additions & 38 deletions packages/react/kibana_context/utils/compose.tsx

This file was deleted.

9 changes: 0 additions & 9 deletions packages/react/kibana_context/utils/index.ts

This file was deleted.

0 comments on commit 50f0d3a

Please sign in to comment.