016b7cfb91
Phase 1: Accessibility Optimizations - Add proper label associations and ARIA attributes to form inputs - Implement aria-required, aria-invalid, aria-describedby for better form accessibility - Add role='alert' for error messages - Enhance keyboard navigation with aria-expanded, aria-controls - Add aria-label for mobile menu button - Implement aria-current for active navigation items - Add semantic HTML with aria-labelledby for sections Phase 2: UX Optimizations - Create loading skeleton components for better loading states - Add FormSkeleton, SectionSkeleton, and LoadingSkeleton components - Prepare for lazy loading implementation Files modified: - src/components/ui/input.tsx: Enhanced with ARIA attributes - src/components/ui/textarea.tsx: Enhanced with ARIA attributes - src/components/layout/header.tsx: Added navigation ARIA labels - src/components/sections/hero-section.tsx: Added section labels - src/components/sections/services-section.tsx: Added section labels - src/components/ui/loading-skeleton.tsx: New loading state components Impact: - WCAG 2.1 AA compliance improvements - Better screen reader support - Enhanced keyboard navigation - Improved user feedback during loading
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
import * as React from "react"
|
|
import { cn } from "@/lib/utils"
|
|
|
|
export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
label?: string
|
|
error?: string
|
|
}
|
|
|
|
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
({ className, label, error, id, ...props }, ref) => {
|
|
const generatedId = React.useId()
|
|
const textareaId = id || generatedId
|
|
const errorId = `${textareaId}-error`
|
|
|
|
return (
|
|
<div className="w-full">
|
|
{label && (
|
|
<label
|
|
htmlFor={textareaId}
|
|
className="block text-sm font-medium text-[#3D3D3D] mb-2"
|
|
>
|
|
{label}
|
|
{props.required && <span className="text-[#C41E3A] ml-1">*</span>}
|
|
</label>
|
|
)}
|
|
<textarea
|
|
id={textareaId}
|
|
data-slot="textarea"
|
|
className={cn(
|
|
"placeholder:text-[#8C8C8C] selection:bg-[#1C1C1C] selection:text-white min-h-16 w-full rounded-lg border border-[#E5E5E5] bg-[#FAFAFA] px-4 py-3 text-base text-[#1C1C1C] shadow-sm transition-all duration-300 outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm resize-none",
|
|
"focus-visible:border-[#1C1C1C] focus-visible:ring-2 focus-visible:ring-[#1C1C1C]/50 focus-visible:shadow-lg focus-visible:shadow-[#1C1C1C]/20",
|
|
"hover:border-[#3D3D3D]",
|
|
error && "border-[#C41E3A] focus-visible:border-[#C41E3A] focus-visible:ring-[#C41E3A]/50",
|
|
className
|
|
)}
|
|
ref={ref}
|
|
aria-required={props.required ? "true" : undefined}
|
|
aria-invalid={error ? "true" : "false"}
|
|
aria-describedby={error ? errorId : undefined}
|
|
{...props}
|
|
/>
|
|
{error && (
|
|
<p id={errorId} className="mt-1 text-sm text-[#C41E3A]" role="alert">
|
|
{error}
|
|
</p>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
)
|
|
Textarea.displayName = "Textarea"
|
|
|
|
export { Textarea }
|