morethanadiagnosis-hub/web/components/common/Checkbox.tsx
Claude 9232ebe294
feat(web): complete Phase 1 - foundation components, layouts, and hooks
Implemented complete design system and foundational infrastructure:

**Design System Components:**
- Button (all variants: primary, secondary, ghost, danger)
- Input & Textarea (with validation and error states)
- Card (elevated, outlined, flat variants)
- Modal/Dialog (with focus trap and accessibility)
- Avatar (with fallback initials)
- Badge (all color variants)
- Form helpers (FormField, Checkbox, Select)
- Link component with Next.js integration
- Navigation (Header, Footer with responsive design)

**Layouts:**
- MainLayout (with Header/Footer for public pages)
- AuthLayout (minimal layout for auth flows)
- DashboardLayout (with sidebar navigation)

**Hooks & Utilities:**
- useAuth() - authentication state management
- useApi() - API calls with loading/error states
- useLocalStorage() - persistent state management
- apiClient - Axios instance with token refresh
- authStore - Zustand store for auth state

**Configuration:**
- Tailwind config with design tokens
- Dark mode support via CSS variables
- Global styles with accessibility focus
- WCAG 2.2 AA+ compliant focus indicators

All components follow accessibility best practices with proper ARIA labels,
keyboard navigation, and screen reader support.

Job ID: MTAD-IMPL-2025-11-18-CL
2025-11-18 01:02:05 +00:00

50 lines
1.5 KiB
TypeScript

'use client'
import React from 'react'
export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'> {
label?: string
error?: string
}
export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
({ label, error, className = '', id, ...props }, ref) => {
const checkboxId = id || `checkbox-${Math.random().toString(36).substr(2, 9)}`
const errorId = `${checkboxId}-error`
const hasError = Boolean(error)
const baseStyles = 'h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500 dark:border-gray-600 dark:bg-gray-800 dark:ring-offset-gray-900'
const errorStyles = hasError ? 'border-error-500' : ''
return (
<div className="flex items-start">
<div className="flex items-center h-5">
<input
ref={ref}
type="checkbox"
id={checkboxId}
className={`${baseStyles} ${errorStyles} ${className}`.trim()}
aria-invalid={hasError}
aria-describedby={hasError ? errorId : undefined}
{...props}
/>
</div>
{label && (
<div className="ml-3 text-sm">
<label htmlFor={checkboxId} className="text-gray-700 dark:text-gray-200">
{label}
</label>
{error && (
<p className="text-error-500 mt-1" id={errorId} role="alert">
{error}
</p>
)}
</div>
)}
</div>
)
}
)
Checkbox.displayName = 'Checkbox'