import React from 'react'; /** * Props for the Link component. * * The Link component renders accessible anchor elements with enhanced security, * styling variants, and WCAG 2.1 AA compliance. It supports both traditional * text links and button-styled links for call-to-action scenarios. * * ## Accessibility Considerations * * - External links automatically include `rel="noopener noreferrer"` for security * - Links should have descriptive text or `aria-label` for screen readers * - Focus indicators must meet WCAG 2.4.7 contrast requirements (3:1 minimum) * - Button-styled links maintain semantic `` element for proper navigation * * @example * ```tsx * // Basic link * About Us * * // External link with prefetch * * Visit Example * * * // Button-styled link * * Sign Up Now * * ``` */ type LinkProps = { /** * The URL that the hyperlink points to. * Can be relative or absolute, internal or external. * * @example * ```tsx * href="/products" * href="https://example.com" * href="mailto:hello@example.com" * href="tel:+1234567890" * ``` */ href?: string; /** * Where to display the linked URL. * * - `_self` (default): Current browsing context * - `_blank`: New tab/window (automatically adds security attributes) * - `_parent`: Parent browsing context * - `_top`: Top-level browsing context * * Note: When `target="_blank"`, `rel="noopener noreferrer"` is automatically * added for security unless explicitly overridden. * * @example * ```tsx * target="_blank" // Opens in new tab with security * ``` */ target?: string; /** * Relationship between current document and linked URL. * * Common values: * - `noopener`: Prevents window.opener access (security) * - `noreferrer`: Prevents referrer header (privacy) * - `nofollow`: Hints search engines not to follow (SEO) * - `prefetch`: Hints to prefetch the resource (performance) * * Note: For `target="_blank"`, this component automatically merges * `noopener noreferrer` with any user-provided values for security. * * @example * ```tsx * rel="nofollow noopener" * rel="author" * ``` */ rel?: string; /** * Content to display inside the link. * * For accessibility, ensure link text is descriptive and meaningful. * Avoid generic text like "click here" or "read more" without context. * * @example * ```tsx * // ✅ Good: Descriptive link text * View all products * * // ❌ Bad: Generic link text without context * Click here * * // ✅ Good: Icon with accessible label * * ` elements with automatic security * attributes for external links, customizable styling variants, and full WCAG 2.1 * AA compliance. It supports traditional text links, button-styled links, and * programmatic focus management via ref forwarding. * * ## Features * * - 🔒 **Automatic Security**: External links get `rel="noopener noreferrer"` * - ♿ **WCAG 2.1 AA Compliant**: Accessible focus indicators and semantic HTML * - 🎨 **Flexible Styling**: Text links, button links, and pill variants * - ⚡ **Performance**: Optional prefetch hints for faster navigation * - 🎯 **Ref Forwarding**: Direct DOM access for focus management and scroll * - 🧪 **Type-Safe**: Full TypeScript support with comprehensive prop types * * ## Accessibility * * - ✅ Semantic `` element for proper keyboard navigation * - ✅ Focus indicators meet WCAG 2.4.7 (3:1 contrast ratio) * - ✅ Screen readers announce link purpose and destination * - ✅ External links include security attributes automatically * - ✅ Supports `aria-label` for icon-only or ambiguous links * - ✅ Ref forwarding enables skip-link patterns * * @example * // Basic internal link * About Us * * @example * // External link with automatic security * * Visit Example * * * @example * // Button-styled call-to-action link * * Get Started * * * @example * // Icon-only link with accessible label * *