import React, { CSSProperties } from 'react'; import { useNode, Element, UserComponent } from '@craftjs/core'; import { Container } from './Container'; import { cssPropsToString } from '../../utils/style-helpers'; interface HeaderZoneProps { style?: CSSProperties; children?: React.ReactNode; } export const HeaderZone: UserComponent = ({ style = {}, children }) => { const { connectors: { connect, drag } } = useNode(); return (
{ if (ref) connect(drag(ref)); }} data-zone="header" style={{ width: '100%', minHeight: '50px', borderBottom: '1px solid rgba(148,163,184,0.15)', ...style, }} > {children}
); }; const HeaderZoneSettings: React.FC = () => { const { actions: { setProp }, props } = useNode((node) => ({ props: node.data.props as HeaderZoneProps, })); const bgPresets = ['#ffffff', '#f9fafb', '#1f2937', '#111827', '#0f172a']; return (

Header Zone -- This section appears on all pages.

{bgPresets.map((c) => (
); }; HeaderZone.craft = { displayName: 'Header Zone', props: { style: { backgroundColor: '#ffffff' }, }, rules: { canDrag: () => false, // Header stays at the top, can't be moved canMoveIn: () => true, canMoveOut: () => true, }, related: { settings: HeaderZoneSettings, }, }; (HeaderZone as any).toHtml = (props: HeaderZoneProps, childrenHtml: string) => { const styleStr = cssPropsToString({ width: '100%', ...props.style, }); return { html: `${childrenHtml}` }; };