diff --git a/src/components/editor/BadgeEditorModal.tsx b/src/components/editor/BadgeEditorModal.tsx index dcbbb60..6e17418 100644 --- a/src/components/editor/BadgeEditorModal.tsx +++ b/src/components/editor/BadgeEditorModal.tsx @@ -108,7 +108,11 @@ const FONTS: Array<{ name: string; source: 'google' | 'system' }> = [ { name: 'Impact', source: 'system' } ]; -const COLORS = ['#ffffff', '#000000', '#e2001a', '#ffde00', '#ffd100', '#003399', '#001a33', '#16a34a']; +const COLORS: Array<[string, string]> = [ + ['#000000', 'Čierna'], + ['#ffffff', 'Biela'] +]; +const HEX_RE = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i; const WEIGHTS = [ ['400', 'Normal'], @@ -207,6 +211,36 @@ const NumberSlider: React.FC<{ ); +// Vlastná farba ako HEX kód (#rrggbb); uloží sa až platná hodnota +const HexColorInput: React.FC<{ value: string; onChange: (hex: string) => void }> = ({ value, onChange }) => { + const [text, setText] = useState(value); + // farba zmenená zvonka (čierna/biela, krok späť) → prepíše text v poli + const [prevValue, setPrevValue] = useState(value); + if (value !== prevValue) { + setPrevValue(value); + setText(value); + } + const valid = HEX_RE.test(text); + return ( +
+ + { + const v = e.target.value.trim(); + const hex = v.startsWith('#') ? v : `#${v}`; + setText(hex); + if (HEX_RE.test(hex)) onChange(hex.toLowerCase()); + }} + placeholder="#e2001a" + maxLength={7} + className={`w-full min-w-0 text-[11px] font-mono uppercase border rounded-lg px-1.5 py-1 ${valid ? 'border-gray-300' : 'border-red-300 bg-red-50'}`} + title="Vlastná farba ako HEX kód, napr. #E2001A" + /> +
+ ); +}; + // --------------------------------------------------------------------------- // Editor // --------------------------------------------------------------------------- @@ -750,12 +784,11 @@ export const BadgeEditorModal: React.FC = ({
{badge && ( <> -
+
- commit({ ...badge, width: v }, false)} />
@@ -867,17 +900,18 @@ export const BadgeEditorModal: React.FC = ({ updateLayer(layer.id, { fontSize: v })} />
- {COLORS.map((c) => ( + Farba textu + {COLORS.map(([c, name]) => (