Mark the message (and a request's name) as required on the forms

The send button waits for 10 characters of message; the field now says
Required, and a note under it counts down what's still needed. The
request form's name field is marked too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-30 00:09:22 -05:00
parent f983ecf26c
commit 110b655d5e
2 changed files with 29 additions and 4 deletions

View file

@ -51,6 +51,26 @@ export function OptionalTag() {
);
}
/* On a field the send button waits for. */
export function RequiredTag() {
return (
<span className="ml-2 rounded-full bg-danger-tint px-2 py-0.5 text-xs font-medium text-danger">
Required
</span>
);
}
/* Under a message box: how many more characters it needs, until it
has them (the send button stays off until then). */
export function MinimumNote({ length, min }: { length: number; min: number }) {
if (length >= min) return null;
return (
<span className="text-xs" style={{ color: MUTED }}>
{length === 0 ? `At least ${min} characters` : `${min - length} more character${min - length === 1 ? "" : "s"} needed`}
</span>
);
}
export function FieldError({ id, children }) {
if (!children) return null;
return (
@ -356,6 +376,7 @@ export default function FeedbackForm({ fixedType }: { fixedType?: string } = {})
className="text-base font-semibold text-body"
>
{request ? "Your request" : "Tell us more"}
<RequiredTag />
</label>
<p className="mt-1 text-sm" style={{ color: MUTED }}>
{request
@ -381,6 +402,7 @@ export default function FeedbackForm({ fixedType }: { fixedType?: string } = {})
/>
<div className="mt-2 flex items-start justify-between gap-4">
<FieldError id="feedback-message-error">{fieldErrors.message}</FieldError>
{!fieldErrors.message && <MinimumNote length={message.trim().length} min={MIN_MESSAGE} />}
<span
className="ml-auto shrink-0 text-xs tabular-nums"
style={{ color: MUTED }}
@ -482,8 +504,8 @@ export default function FeedbackForm({ fixedType }: { fixedType?: string } = {})
{!ready && !sending && (
<p className="text-sm" style={{ color: MUTED }}>
{request
? "Write at least a sentence and give an email address to send."
: "Choose a type and write at least a sentence to send."}
? `Write at least ${MIN_MESSAGE} characters and give an email address to send.`
: `Choose a type and write at least ${MIN_MESSAGE} characters to send.`}
</p>
)}
</div>