import React, { useContext, Fragment, useRef, useLayoutEffect } from 'react' import { each } from '@designable/shared' import { DesignerLayoutContext } from '../context' import { IDesignerLayoutProps } from '../types' import cls from 'classnames' export const Layout: React.FC = (props) => { const layout = useContext(DesignerLayoutContext) const ref = useRef() useLayoutEffect(() => { if (ref.current) { each(props.variables, (value, key) => { ref.current.style.setProperty(`--${key}`, value) }) } }, []) if (layout) { return {props.children} } return (
{props.children}
) } Layout.defaultProps = { theme: 'light', prefixCls: 'dn-', position: 'fixed', }