import React, { useCallback, CSSProperties } from 'react'; import { useEditor } from '@craftjs/core'; import { BG_COLORS, RADIUS_PRESETS, SPACING_PRESETS, } from '../../../constants/presets'; import { StylePanelProps, SectionLabel, ColorSwatchGrid, PresetButtonGrid, TextInputField, autoTextColor, useNodeProp, } from './shared'; /* ---------- BUTTON ---------- */ export const ButtonStylePanel: React.FC = ({ selectedId, nodeProps }) => { const { actions } = useEditor(); const style: CSSProperties = nodeProps.style || {}; const { setPropStyle } = useNodeProp(selectedId); const setButtonColor = useCallback( (bgColor: string) => { actions.setProp(selectedId, (props: any) => { props.style = { ...props.style, backgroundColor: bgColor, color: autoTextColor(bgColor), }; }); }, [actions, selectedId], ); return ( <>
Button Color
{ actions.setProp(selectedId, (props: any) => { props.text = v; }); }} /> { actions.setProp(selectedId, (props: any) => { props.href = v; }); }} />
Border Radius setPropStyle('borderRadius', v)} />
Padding setPropStyle('padding', v)} />
); };