UNPKG

@onesy/style-react

Version:

Onesy CSS in JS styling solution for React

22 lines (20 loc) 732 B
import _extends from "@babel/runtime/helpers/extends"; import React from 'react'; import { style } from '.'; const withStyle = Element => function (value) { let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; // Name options.name = options.name !== undefined ? options.name : `${Element?.displayName || Element?.type?.displayName || ''}WithStyle`; // Use styles const useStyle = style(value, options); // Element const element = /*#__PURE__*/React.forwardRef((props, ref) => { const styles = useStyle(props); return /*#__PURE__*/React.createElement(Element, _extends({ ref: ref, styles: styles }, props)); }); return element; }; export default withStyle;