import React, { useState, useEffect } from 'react'; import { Stack, TextInput, Select, Combobox, useCombobox, Group, Box } from '@mantine/core'; import { useTranslation } from 'react-i18next'; import { ColorPicker } from './ColorPicker'; interface TextInputWithFontProps { text: string; onTextChange: (text: string) => void; fontSize: number; onFontSizeChange: (size: number) => void; fontFamily: string; onFontFamilyChange: (family: string) => void; textColor?: string; onTextColorChange?: (color: string) => void; disabled?: boolean; label?: string; placeholder?: string; } export const TextInputWithFont: React.FC = ({ text, onTextChange, fontSize, onFontSizeChange, fontFamily, onFontFamilyChange, textColor = '#000000', onTextColorChange, disabled = false, label, placeholder }) => { const { t } = useTranslation(); const [fontSizeInput, setFontSizeInput] = useState(fontSize.toString()); const fontSizeCombobox = useCombobox(); const [isColorPickerOpen, setIsColorPickerOpen] = useState(false); // Sync font size input with prop changes useEffect(() => { setFontSizeInput(fontSize.toString()); }, [fontSize]); const fontOptions = [ { value: 'Helvetica', label: 'Helvetica' }, { value: 'Times-Roman', label: 'Times' }, { value: 'Courier', label: 'Courier' }, { value: 'Arial', label: 'Arial' }, { value: 'Georgia', label: 'Georgia' }, ]; const fontSizeOptions = ['8', '12', '16', '20', '24', '28', '32', '36', '40', '48', '56', '64', '72', '80', '96', '112', '128', '144', '160', '176', '192', '200']; return ( onTextChange(e.target.value)} disabled={disabled} required /> {/* Font Selection */}