Merge pull request #15 from damjan1996/auto-claude/012-contact-form-message-character-counter

auto-claude: 012-contact-form-message-character-counter
This commit is contained in:
Damjan Savic
2026-01-25 19:44:31 +01:00
committed by GitHub
4 changed files with 21 additions and 0 deletions
+18
View File
@@ -15,6 +15,8 @@ interface FormData {
export function ContactForm() {
const t = useTranslations('pages.contact');
const MAX_MESSAGE_LENGTH = 1000;
const [isSubmitting, setIsSubmitting] = useState(false);
const [submitStatus, setSubmitStatus] = useState<'idle' | 'success' | 'error'>('idle');
const [errorMessage, setErrorMessage] = useState<string>('');
@@ -26,6 +28,8 @@ export function ContactForm() {
const [errors, setErrors] = useState<Partial<FormData>>({});
const [remainingAttempts, setRemainingAttempts] = useState<number | null>(null);
const messageLength = formData.message.length;
const validateForm = () => {
const newErrors: Partial<FormData> = {};
@@ -319,6 +323,7 @@ export function ContactForm() {
onChange={handleChange}
placeholder={t('contactForm.message.placeholder')}
rows={6}
maxLength={MAX_MESSAGE_LENGTH}
disabled={isSubmitting}
aria-required="true"
aria-invalid={!!errors.message}
@@ -328,6 +333,19 @@ export function ContactForm() {
{errors.message && (
<p id="message-error" role="alert" className="text-sm text-red-400">{errors.message}</p>
)}
<div className="flex justify-end">
<p
className={`text-xs transition-colors ${
messageLength > MAX_MESSAGE_LENGTH
? 'text-red-500'
: messageLength >= MAX_MESSAGE_LENGTH * 0.8
? 'text-yellow-500'
: 'text-zinc-500'
}`}
>
{t('contactForm.characterCounter', { current: messageLength, max: MAX_MESSAGE_LENGTH })}
</p>
</div>
</div>
</div>
+1
View File
@@ -394,6 +394,7 @@
"label": "Nachricht",
"placeholder": "Ihre Nachricht an mich..."
},
"characterCounter": "{current}/{max} Zeichen",
"submit": "Nachricht senden",
"submitting": "Nachricht wird gesendet...",
"successMessage": "Vielen Dank für Ihre Nachricht! Ich werde mich so schnell wie möglich bei Ihnen melden.",
+1
View File
@@ -409,6 +409,7 @@
"label": "Message",
"placeholder": "Your message to me..."
},
"characterCounter": "{current}/{max} characters",
"submit": "Send Message",
"submitting": "Sending message...",
"successMessage": "Thank you for your message! I will get back to you as soon as possible.",
+1
View File
@@ -416,6 +416,7 @@
"label": "Poruka",
"placeholder": "Vasa poruka za mene..."
},
"characterCounter": "{current}/{max} karaktera",
"submit": "Posalji poruku",
"submitting": "Slanje poruke...",
"successMessage": "Hvala vam na poruci! Javicu vam se sto je pre moguce.",