UNPKG

@braineet/ui

Version:

Braineet design system

38 lines (32 loc) 1.21 kB
/* eslint-disable global-require */ /* eslint-disable react/prop-types */ import * as React from 'react'; import { ThemeProvider as StyledComponentsProvider } from 'styled-components'; import buildTheme from '../theme'; import GlobalStyles from './GlobalStyles'; // eslint-disable-next-line import/prefer-default-export import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; export var Provider = /*#__PURE__*/React.memo(function (props) { var children = props.children, isStandalone = props.isStandalone, _theme = props.theme; /// ///////////////////////////////////////////// var _React$useState = React.useState(_theme), theme = _React$useState[0], setTheme = _React$useState[1]; React.useEffect(function () { setTheme(_theme); }, [_theme]); /// ///////////////////////////////////////////// var derivedTheme = React.useMemo(function () { if (theme && isStandalone) { return theme; } return buildTheme(theme); }, [isStandalone, theme]); /// ///////////////////////////////////////////// return /*#__PURE__*/_jsxs(StyledComponentsProvider, { theme: derivedTheme, children: [/*#__PURE__*/_jsx(GlobalStyles, {}), children] }); });