import React, { useCallback, CSSProperties } from 'react'; import { useEditor } from '@craftjs/core'; import { TEXT_COLORS, FONT_FAMILIES, TEXT_SIZES, FONT_WEIGHTS, } from '../../../constants/presets'; import { StylePanelProps, SectionLabel, ColorSwatchGrid, PresetButtonGrid, } from './shared'; /* ---------- TEXT ---------- */ export const TextStylePanel: React.FC = ({ selectedId, nodeProps }) => { const { actions } = useEditor(); const style: CSSProperties = nodeProps.style || {}; const setPropStyle = useCallback( (property: string, value: string) => { actions.setProp(selectedId, (props: any) => { props.style = { ...props.style, [property]: value }; }); }, [actions, selectedId], ); return ( <>
Text Color setPropStyle('color', v)} />
Font Family setPropStyle('fontFamily', v)} />
Text Size setPropStyle('fontSize', v)} />
Font Weight setPropStyle('fontWeight', v)} />
Alignment
{(['left', 'center', 'right', 'justify'] as const).map((a) => ( ))}
); };