import React from 'react'; import { useEditor } from '@craftjs/core'; import { BG_COLORS, RADIUS_PRESETS, } from '../../../constants/presets'; import { StylePanelProps, SectionLabel, ColorSwatchGrid, PresetButtonGrid, CollapsibleSection, ColorPickerField, ArrayPropEditor, SizeControl, AspectRatioControl, labelStyle, inputStyle, smallInputStyle, sectionGap, useNodeProp, } from './shared'; import { AssetPicker } from '../../../ui/AssetPicker'; import { BoxModelSection, BorderEffectsSection, AnimVisSection } from './mediaBoxModel'; const GALLERY_COLUMN_PRESETS = [ { label: '2', value: '2' }, { label: '3', value: '3' }, { label: '4', value: '4' }, { label: '5', value: '5' }, ]; /* ---------- MEDIA (Video / Gallery / Map / Slider) ---------- */ export const MediaStylePanel: React.FC = ({ selectedId, nodeProps }) => { const { actions } = useEditor(); const { setProp, setPropStyle } = useNodeProp(selectedId); const style = nodeProps.style || {}; return ( <> {/* Video source -- upload/browse/paste-URL (paste-URL still handles YouTube/Vimeo; upload/browse handle files via detectVideoType's serve_asset resolution). */} {nodeProps.videoUrl !== undefined && (
Video Source setProp('videoUrl', url)} variant="full" placeholder="Or paste a YouTube/Vimeo/.mp4 URL..." />
)} {/* Video size -- width + aspect ratio for the video frame. */} {nodeProps.videoUrl !== undefined && ( <> setPropStyle('width', v)} /> setPropStyle('aspectRatio', v)} /> )} {/* Poster image (optional, file-type videos only in practice but harmless to offer whenever the component has a poster prop). */} {nodeProps.poster !== undefined && (
Poster Image (optional) setProp('poster', url)} variant="full" />
)} {/* Map URL */} {nodeProps.embedUrl !== undefined && nodeProps.videoUrl === undefined && (
setProp('embedUrl', e.target.value)} placeholder="Google Maps embed URL" style={inputStyle} />
)} {/* Map address */} {nodeProps.address !== undefined && (
setProp('address', e.target.value)} placeholder="123 Main St..." style={inputStyle} />
)} {/* Video options */} {nodeProps.autoplay !== undefined && (
)} {nodeProps.loop !== undefined && (
)} {nodeProps.controls !== undefined && (
)} {/* Gallery layout -- columns + lightbox (existing-but-previously-unexposed props). */} {nodeProps.images !== undefined && Array.isArray(nodeProps.images) && ( <>
Columns setProp('columns', Number(v))} />
)} {/* Gallery items */} {nodeProps.images !== undefined && Array.isArray(nodeProps.images) && ( (
{item.src !== undefined && ( { actions.setProp(selectedId, (props: any) => { const updated = [...(props.images || [])]; updated[index] = { ...updated[index], src: url }; props.images = updated; }); }} /> )} {item.caption !== undefined && ( { actions.setProp(selectedId, (props: any) => { const updated = [...(props.images || [])]; updated[index] = { ...updated[index], caption: e.target.value }; props.images = updated; }); }} placeholder="Caption" style={smallInputStyle} /> )}
)} emptyItem={{ src: '', caption: '' }} />
)} {/* Slides */} {nodeProps.slides !== undefined && Array.isArray(nodeProps.slides) && ( (
{item.heading !== undefined && ( { actions.setProp(selectedId, (props: any) => { const updated = [...(props.slides || [])]; updated[index] = { ...updated[index], heading: e.target.value }; props.slides = updated; }); }} placeholder="Heading" style={smallInputStyle} /> )} {item.text !== undefined && (