2026-07-12 15:13:35 -07:00
|
|
|
import React, { CSSProperties } from 'react';
|
2026-04-05 18:31:16 -07:00
|
|
|
import {
|
|
|
|
|
TEXT_COLORS,
|
|
|
|
|
FONT_FAMILIES,
|
|
|
|
|
TEXT_SIZES,
|
|
|
|
|
FONT_WEIGHTS,
|
|
|
|
|
} from '../../../constants/presets';
|
|
|
|
|
import {
|
|
|
|
|
StylePanelProps,
|
|
|
|
|
SectionLabel,
|
|
|
|
|
ColorSwatchGrid,
|
|
|
|
|
PresetButtonGrid,
|
2026-07-12 15:13:35 -07:00
|
|
|
useNodeProp,
|
2026-04-05 18:31:16 -07:00
|
|
|
} from './shared';
|
|
|
|
|
|
|
|
|
|
/* ---------- TEXT ---------- */
|
|
|
|
|
export const TextStylePanel: React.FC<StylePanelProps> = ({ selectedId, nodeProps }) => {
|
|
|
|
|
const style: CSSProperties = nodeProps.style || {};
|
|
|
|
|
|
2026-07-12 15:13:35 -07:00
|
|
|
const { setPropStyle } = useNodeProp(selectedId);
|
2026-04-05 18:31:16 -07:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div className="guided-section">
|
|
|
|
|
<SectionLabel>Text Color</SectionLabel>
|
|
|
|
|
<ColorSwatchGrid
|
|
|
|
|
colors={TEXT_COLORS}
|
|
|
|
|
activeValue={style.color as string}
|
|
|
|
|
onSelect={(v) => setPropStyle('color', v)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="guided-section">
|
|
|
|
|
<SectionLabel>Font Family</SectionLabel>
|
|
|
|
|
<PresetButtonGrid
|
|
|
|
|
presets={FONT_FAMILIES}
|
|
|
|
|
activeValue={style.fontFamily as string}
|
|
|
|
|
onSelect={(v) => setPropStyle('fontFamily', v)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="guided-section">
|
|
|
|
|
<SectionLabel>Text Size</SectionLabel>
|
|
|
|
|
<PresetButtonGrid
|
|
|
|
|
presets={TEXT_SIZES}
|
|
|
|
|
activeValue={style.fontSize as string}
|
|
|
|
|
onSelect={(v) => setPropStyle('fontSize', v)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="guided-section">
|
|
|
|
|
<SectionLabel>Font Weight</SectionLabel>
|
|
|
|
|
<PresetButtonGrid
|
|
|
|
|
presets={FONT_WEIGHTS}
|
|
|
|
|
activeValue={String(style.fontWeight || '')}
|
|
|
|
|
onSelect={(v) => setPropStyle('fontWeight', v)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="guided-section">
|
|
|
|
|
<SectionLabel>Alignment</SectionLabel>
|
|
|
|
|
<div className="preset-grid align-grid">
|
|
|
|
|
{(['left', 'center', 'right', 'justify'] as const).map((a) => (
|
|
|
|
|
<button
|
|
|
|
|
key={a}
|
|
|
|
|
className={`preset-btn ${style.textAlign === a ? 'active' : ''}`}
|
|
|
|
|
onClick={() => setPropStyle('textAlign', a)}
|
|
|
|
|
title={a}
|
|
|
|
|
>
|
|
|
|
|
<i className={`fa fa-align-${a}`} />
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|