import React, { CSSProperties } from 'react'; import { BG_COLORS, SPACING_PRESETS, RADIUS_PRESETS, } from '../../../constants/presets'; import { StylePanelProps, SectionLabel, ColorSwatchGrid, GradientSwatchGrid, PresetButtonGrid, NumericUnitInput, labelStyle, inputStyle, sectionGap, useNodeProp, } from './shared'; import { BoxModelSection, BorderEffectsSection, AnimVisSection } from './containerBoxModel'; // Vertical Alignment options shown to the user identically regardless of // which CSS property they end up mapped to (align-items for the Columns // flex ROW vs. justify-content for Container/Section's flex COLUMN root -- // see the per-type branch below). const VERTICAL_ALIGN_OPTIONS: { label: string; value: string }[] = [ { label: 'Top', value: 'flex-start' }, { label: 'Center', value: 'center' }, { label: 'Bottom', value: 'flex-end' }, { label: 'Stretch', value: 'stretch' }, ]; /* ---------- CONTAINER / SECTION / COLUMNS ---------- */ export const ContainerStylePanel: React.FC = ({ selectedId, nodeProps }) => { const style: CSSProperties = nodeProps.style || {}; const { setProp, setPropStyle } = useNodeProp(selectedId); // ColumnLayout only ever carries `columns`/`split` props -- Container and // Section never set them -- so checking either alone distinguishes the // flex-ROW case (align its columns via align-items, aligning uneven // column heights) from the flex-COLUMN case (Container/Section, which // vertically center/position their OWN content via justify-content, // paired with a Min Height control so centering is meaningful). const isColumns = nodeProps.columns !== undefined || nodeProps.split !== undefined; const vAlignKey = isColumns ? 'alignItems' : 'justifyContent'; return ( <> {nodeProps.cssId !== undefined && (
setProp('cssId', e.target.value)} placeholder="my-element-id" style={inputStyle} />
)} {nodeProps.cssClass !== undefined && (
setProp('cssClass', e.target.value)} placeholder="my-custom-class" style={inputStyle} />
)}
Background Color setPropStyle('backgroundColor', v)} />
Background Gradient setPropStyle('background', v)} />
Padding setPropStyle('padding', v)} />
Border Radius setPropStyle('borderRadius', v)} />
Alignment
{(['left', 'center', 'right', 'justify'] as const).map((a) => ( ))}
Vertical Alignment setPropStyle(vAlignKey, v)} />
{!isColumns && (
Min Height setPropStyle('minHeight', v)} units={['px', 'vh', '%']} placeholder="auto" />
)} {/* Box model + border/effects + animation/visibility rollout */} ); };