import React from 'react'; import clsx from 'clsx'; export type LinkArrowVariant = 'internal' | 'external'; export type LinkArrowSize = 'small' | 'medium' | 'large'; export interface LinkArrowProps extends React.SVGProps { /** * Arrow variant - internal (→) or external (↗) * Both variants animate on hover (horizontal line shrinks to show chevron) * @default 'internal' */ variant?: LinkArrowVariant; /** * Size of the arrow icon * @default 'medium' */ size?: LinkArrowSize; /** * Color of the arrow (hex color or CSS color value) * @default 'currentColor' (inherits from parent) */ color?: string; /** * Disabled state - reduces opacity and prevents hover animation * @default false */ disabled?: boolean; /** * Additional CSS classes */ className?: string; } // Size mappings for internal arrow (viewBox 0 0 26 22) const internalSizeMap: Record = { small: { width: 15, height: 14 }, medium: { width: 17, height: 16 }, large: { width: 26, height: 22 }, }; // Size mappings for external arrow (viewBox 0 0 21 21, square aspect ratio) const externalSizeMap: Record = { small: { width: 14, height: 14 }, medium: { width: 16, height: 16 }, large: { width: 21, height: 21 }, }; /** * LinkArrow Component * * A customizable SVG arrow icon for use in link components. * Supports internal (→) and external (↗) variants with three size options. * Both variants animate on hover - horizontal line shrinks to reveal chevron shape. * * @example * ```tsx * * * * ``` */ export const LinkArrow: React.FC = ({ variant = 'internal', size = 'medium', color = 'currentColor', disabled = false, className, ...svgProps }) => { const dimensions = variant === 'external' ? externalSizeMap[size] : internalSizeMap[size]; const classes = clsx( 'bds-link-icon', `bds-link-icon--${variant}`, `bds-link-icon--${size}`, { 'bds-link-icon--disabled': disabled, }, className ); // Internal arrow (→) - horizontal arrow pointing right // Horizontal line animates away on hover to show chevron const renderInternalArrow = () => ( ); // External arrow (↗) - diagonal arrow with corner bracket // Diagonal line animates away on hover, leaving just the chevron bracket const renderExternalArrow = () => ( ); return ( {variant === 'external' ? renderExternalArrow() : renderInternalArrow()} ); }; LinkArrow.displayName = 'LinkArrow';