import React from 'react'; import { cn } from '@/lib/utils'; import { Section } from '../../store/usePageEditorStore'; interface ImageTextRendererProps { section: Section; className?: string; } const COLOR_SCHEMES: Record = { default: { bg: '', text: 'text-gray-900' }, primary: { bg: 'wn-primary-bg', text: 'text-white' }, secondary: { bg: 'wn-secondary-bg', text: 'text-white' }, muted: { bg: 'bg-gray-50', text: 'text-gray-700' }, gradient: { bg: 'wn-gradient-bg', text: 'text-white' }, }; export function ImageTextRenderer({ section, className }: ImageTextRendererProps) { const scheme = COLOR_SCHEMES[section.colorScheme || 'default']; const layout = section.layoutVariant || 'image-left'; const isImageRight = layout === 'image-right'; const title = section.props?.title?.value || 'Section Title'; const text = section.props?.text?.value || 'Your descriptive text goes here. Edit this section to add your own content.'; const image = section.props?.image?.value; const isDynamicTitle = section.props?.title?.type === 'dynamic'; const isDynamicText = section.props?.text?.type === 'dynamic'; const isDynamicImage = section.props?.image?.type === 'dynamic'; const cta_text = section.props?.cta_text?.value; const cta_url = section.props?.cta_url?.value; // Helper to get text styles (including font family) const getTextStyles = (elementName: string) => { const styles = section.elementStyles?.[elementName] || {}; return { classNames: cn( styles.fontSize, styles.fontWeight, { 'font-sans': styles.fontFamily === 'secondary', 'font-serif': styles.fontFamily === 'primary', } ), style: { color: styles.color, textAlign: styles.textAlign, backgroundColor: styles.backgroundColor } }; }; const titleStyle = getTextStyles('title'); const textStyle = getTextStyles('text'); const imageStyle = section.elementStyles?.['image'] || {}; const buttonStyle = getTextStyles('button'); // Helper to get background style for dynamic schemes const getBackgroundStyle = () => { if (scheme.bg === 'wn-gradient-bg') { return { backgroundImage: 'linear-gradient(135deg, var(--wn-gradient-start, #9333ea), var(--wn-gradient-end, #3b82f6))' }; } if (scheme.bg === 'wn-primary-bg') { return { backgroundColor: 'var(--wn-primary, #1a1a1a)' }; } if (scheme.bg === 'wn-secondary-bg') { return { backgroundColor: 'var(--wn-secondary, #6b7280)' }; } return undefined; }; return (
{/* Image */}
{image ? ( {title} ) : (
{isDynamicImage ? ( {section.props?.image?.source} ) : ( 'Add Image' )}
)}
{/* Content */}

{isDynamicTitle && } {title}

{isDynamicText && } {text}

{cta_text && cta_url && (
{cta_text}
)}
); }