UNPKG

@wix/design-system

Version:

@wix/design-system

28 lines 1.12 kB
import React from 'react'; import kebabCase from 'lodash/kebabCase'; import { ThemeContext } from './ThemeContext'; /** ThemeProvider */ class ThemeProvider extends React.PureComponent { _parseTheme(theme) { const style = {}; for (const [key, value] of Object.entries(theme)) { if (key !== 'className' && key !== 'icons' && key !== 'componentWrapper') { style[`--wsr-${kebabCase(key)}`] = value; } } return style; } render() { const { dataHook, theme = {}, children } = this.props; return (React.createElement("div", { className: theme.className, style: this._parseTheme(theme), "data-hook": dataHook }, React.createElement(ThemeContext.Provider, { value: { icons: theme.icons, className: theme.className } }, theme.componentWrapper ? theme.componentWrapper({ children }) : children))); } } ThemeProvider.displayName = 'ThemeProvider'; ThemeProvider.defaultProps = {}; export default ThemeProvider; //# sourceMappingURL=ThemeProvider.js.map