Skip to content

Commit 968eba1

Browse files
committed
feat: add error icon to char count indicator over max
1 parent d0805ce commit 968eba1

File tree

1 file changed

+5
-4
lines changed
  • app/[locale]/enterprise/_components/ContactForm

1 file changed

+5
-4
lines changed

app/[locale]/enterprise/_components/ContactForm/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client"
22

33
import React, { useState } from "react"
4-
import { HeartHandshake } from "lucide-react"
4+
import { HeartHandshake, TriangleAlert } from "lucide-react"
55

66
import { Button } from "@/components/ui/buttons/Button"
77
import Input from "@/components/ui/input"
@@ -91,9 +91,9 @@ const sanitizeInput = (input: string): string =>
9191
const EnterpriseContactForm = ({ strings }: EnterpriseContactFormProps) => {
9292
const getCharacterCountClasses = (currentLength: number, maxLength: number) =>
9393
cn(
94-
currentLength >= Math.floor(maxLength * 0.9) && "block", // Show char count when within 10% remaining to limit
94+
currentLength >= Math.floor(maxLength * 0.9) && "flex", // Show char count when within 10% remaining to limit
9595
currentLength > maxLength - 64 && "text-warning-border", // Warning color within 64 chars (border version for proper contrast ratio),
96-
currentLength > maxLength && "text-error" // Error color over limit
96+
currentLength > maxLength && "text-error [&_svg]:inline" // Error color over limit
9797
)
9898

9999
const [formData, setFormData] = useState<FormState>({
@@ -250,13 +250,14 @@ const EnterpriseContactForm = ({ strings }: EnterpriseContactFormProps) => {
250250
/>
251251
<div
252252
className={cn(
253-
"absolute bottom-1 end-3 hidden rounded bg-background px-1 py-0.5 text-xs shadow",
253+
"absolute bottom-1 end-3 hidden items-center rounded bg-background px-1 py-0.5 text-xs shadow",
254254
getCharacterCountClasses(
255255
formData.message.length,
256256
MAX_MESSAGE_LENGTH
257257
)
258258
)}
259259
>
260+
<TriangleAlert className="mb-px me-1 hidden size-3" />
260261
{formData.message.length}/{MAX_MESSAGE_LENGTH}
261262
</div>
262263
</div>

0 commit comments

Comments
 (0)