import React, { useCallback } from 'react'; import { useEditor } from '@craftjs/core'; import { BG_COLORS, SPACING_PRESETS, } from '../../../constants/presets'; import { StylePanelProps, SectionLabel, ColorSwatchGrid, PresetButtonGrid, CollapsibleSection, ColorPickerField, labelStyle, inputStyle, smallInputStyle, btnActiveStyle, sectionGap, } from './shared'; /* ---------- SOCIAL / ICON / STAR RATING ---------- */ export const SocialStylePanel: React.FC = ({ selectedId, nodeProps }) => { const { actions } = useEditor(); const setProp = useCallback((key: string, value: any) => { actions.setProp(selectedId, (props: any) => { props[key] = value; }); }, [actions, selectedId]); const setPropStyle = useCallback((key: string, value: string) => { actions.setProp(selectedId, (props: any) => { props.style = { ...props.style, [key]: value }; }); }, [actions, selectedId]); const style = nodeProps.style || {}; return ( <> {/* Social Links list */} {nodeProps.links !== undefined && Array.isArray(nodeProps.links) && (
{(nodeProps.links || []).map((link: any, i: number) => (
{link.platform || 'link'} { actions.setProp(selectedId, (props: any) => { const updated = [...(props.links || [])]; updated[i] = { ...updated[i], url: e.target.value }; props.links = updated; }); }} placeholder="URL" style={{ ...smallInputStyle, flex: 1 }} />
))}
)} {/* Icon name */} {nodeProps.iconName !== undefined && (
setProp('iconName', e.target.value)} placeholder="fa-star" style={inputStyle} />
)} {nodeProps.icon !== undefined && typeof nodeProps.icon === 'string' && (
setProp('icon', e.target.value)} placeholder="fa-star or emoji" style={inputStyle} />
)} {/* Star rating */} {nodeProps.rating !== undefined && (
setProp('rating', parseFloat(e.target.value))} style={{ width: '100%' }} />
)} {nodeProps.maxStars !== undefined && (
setProp('maxStars', parseInt(e.target.value) || 5)} style={inputStyle} />
)} {/* Colors */} {nodeProps.iconColor !== undefined && ( setProp('iconColor', v)} /> )} {nodeProps.iconBgColor !== undefined && ( setProp('iconBgColor', v)} /> )} {nodeProps.starColor !== undefined && ( setProp('starColor', v)} /> )} {nodeProps.color !== undefined && typeof nodeProps.color === 'string' && ( setProp('color', v)} /> )} {/* Size */} {nodeProps.iconSize !== undefined && (
setProp('iconSize', e.target.value)} style={inputStyle} />
)} {nodeProps.size !== undefined && typeof nodeProps.size === 'string' && (
setProp('size', e.target.value)} style={inputStyle} />
)} {/* Alignment */} {nodeProps.alignment !== undefined && (
{(['left', 'center', 'right'] as const).map((a) => ( ))}
)} {/* Background & padding */}
Background setPropStyle('backgroundColor', v)} />
Padding setPropStyle('padding', v)} />
); };