morethanadiagnosis-hub/web/components/common/Link.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

49 lines
1.3 KiB
TypeScript

'use client'
import NextLink from 'next/link'
import React from 'react'
export interface LinkProps {
href: string
children: React.ReactNode
variant?: 'primary' | 'secondary' | 'neutral'
external?: boolean
className?: string
}
const variantStyles = {
primary: 'text-primary-600 hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300',
secondary: 'text-secondary-600 hover:text-secondary-700 dark:text-secondary-400 dark:hover:text-secondary-300',
neutral: 'text-gray-700 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100',
}
export const Link = ({
href,
children,
variant = 'primary',
external = false,
className = '',
}: LinkProps) => {
const baseStyles = 'underline decoration-1 underline-offset-2 hover:decoration-2 transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 rounded-sm'
const combinedClassName = `${baseStyles} ${variantStyles[variant]} ${className}`.trim()
if (external) {
return (
<a
href={href}
className={combinedClassName}
target="_blank"
rel="noopener noreferrer"
>
{children}
</a>
)
}
return (
<NextLink href={href} className={combinedClassName}>
{children}
</NextLink>
)
}