UNPKG

@kubit-ui-web/react-components

Version:

Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience

30 lines (29 loc) 2.04 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import isPropValid from '@emotion/is-prop-valid'; import { StyleSheetManager, ThemeProvider as StyledComponentsThemeProvider, } from 'styled-components'; import { ErrorBoundaryProvider } from '../errorBoundary/errorBoundaryProvider'; import { GenericComponentsProvider } from '../genericComponents/genericComponentsProvider'; import { GlobalStyle } from '../global.style/global.style'; import { ThemeInformationProvider } from '../themeInformation/themeInformation'; /** * @name ThemeProvider * @description * ThemeProvider is a wrapper component that provides the theme to all components in its subtree via the context API. * It should be used once at the root of your React component tree. * @example * <ThemeProvider styles={theme}> * <App /> * </ThemeProvider> * @param {React.ReactNode} children - React children * @param {DefaultTheme} styles - Theme object * @param {GenericComponentsType} genericComponents - Generic components * @param {string} country - Country * @param {unknown} regex - Regex * @param {CSSProp} customGlobalStyles - Custom global styles * @param {ThemeInformation} themeInformation - Theme information * @returns {JSX.Element} - ThemeProvider component */ export const ThemeProvider = ({ children, styles, customGlobalStyles, genericComponents, themeInformation, customFonts, showErrors = false, idCreateModal = null, customFallback, }) => { return (_jsx(ThemeInformationProvider, { value: themeInformation, children: _jsxs(GenericComponentsProvider, { value: genericComponents, children: [_jsx(GlobalStyle, { custom: customGlobalStyles, customFonts: customFonts }), _jsx(StyleSheetManager, { enableVendorPrefixes: true, shouldForwardProp: isPropValid, children: _jsx(ErrorBoundaryProvider, { customFallback: customFallback, idCreateModal: idCreateModal, showErrorMessage: showErrors, children: _jsx(StyledComponentsThemeProvider, { theme: styles, children: children }) }) })] }) })); }; //# sourceMappingURL=themeProvider.js.map