import React, { CSSProperties } from 'react'; import { useEditor } from '@craftjs/core'; import { IMAGE_RADIUS_PRESETS, OBJECT_FIT, } from '../../../constants/presets'; import { StylePanelProps, SectionLabel, PresetButtonGrid, TextInputField, SizeControl, AspectRatioControl, FocalPointGrid, useNodeProp, } from './shared'; import { AssetPicker } from '../../../ui/AssetPicker'; import { PLACEHOLDER_SRC } from '../../../components/media/ImageBlock'; import { BoxModelSection, BorderEffectsSection, AnimVisSection } from './mediaBoxModel'; /* ---------- IMAGE (with upload/browse/drop) ---------- */ export const ImageStylePanel: React.FC = ({ selectedId, nodeProps }) => { const { actions } = useEditor(); const style: CSSProperties = nodeProps.style || {}; const { setProp, setPropStyle } = useNodeProp(selectedId); return ( <> {/* Image source */}
Image Source actions.setProp(selectedId, (props: any) => { props.src = url || PLACEHOLDER_SRC; })} variant="full" />
{/* Alt Text */} { actions.setProp(selectedId, (props: any) => { props.alt = v; }); }} /> {/* Size -- Width absorbs the historical maxWidth presets (25/50/75/100% are a subset of SizeControl's default preset row), Height is new. */} setPropStyle('maxWidth', v)} /> setPropStyle('height', v)} /> {/* Crop & Framing -- aspect-ratio + object-fit + object-position on the itself is a CSS framing crop (no server-side image processing needed). */} setPropStyle('aspectRatio', v)} />
Object Fit setPropStyle('objectFit', v)} />
setPropStyle('objectPosition', v)} /> {/* Border Radius */}
Border Radius setPropStyle('borderRadius', v)} />
{/* Box model + animation/visibility rollout */} ); };