UNPKG

@snappmarket/config

Version:
46 lines (43 loc) • 1.28 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import React from 'react'; import PropTypes from 'prop-types'; import { ThemeProvider } from 'styled-components'; import { makeTheme } from '../theme'; import ToolboxContext from './context'; import faIR from '../languages/fa-IR'; import GlobalConfig from './config'; const Provider = ({ theme, language, options, children }) => { const unifiedOptions = _extends({}, GlobalConfig.options, options); const unifiedTheme = makeTheme(theme); GlobalConfig.language = language; GlobalConfig.theme = unifiedTheme; GlobalConfig.options = unifiedOptions; return /*#__PURE__*/React.createElement(ToolboxContext.Provider, { value: GlobalConfig }, /*#__PURE__*/React.createElement(ThemeProvider, { theme: unifiedTheme }, children)); }; process.env.NODE_ENV !== "production" ? Provider.propTypes = { theme: PropTypes.object, language: PropTypes.object, options: PropTypes.shape({ SSR: PropTypes.bool, importSpriteSVG: PropTypes.bool, useSpriteFile: PropTypes.bool, publicPath: PropTypes.string, spriteSvgName: PropTypes.string }), children: PropTypes.node } : void 0; Provider.defaultProps = { language: faIR, options: {}, theme: {} }; export default Provider;