import { Link, LinkProps } from 'react-router-dom'; import { FC, ReactNode, useEffect, useRef } from 'react'; import { classNames } from '@/shared/lib/classNames/classNames'; import cls from './AppLink.module.scss'; export enum AppLinkTheme { PRIMARY = 'primary', NAVIGATION = 'navigation', } export enum AppLinkSize { XL = 'xl', L = 'l', M = 'm', S = 's', XS = 'xs', } interface AppLinkProps extends LinkProps { className?: string; theme?: AppLinkTheme; icon?: ReactNode; reverse?: boolean; width?: string; size?: AppLinkSize; } export const AppLink: FC = props => { const { to, className, children, reverse, theme = '', icon, width = 'auto', size = '', ...otherProps } = props; const $link = useRef(null); useEffect(() => { if ($link.current) $link.current.style.setProperty('--custom-width', width); }, []); const mods = { [cls.reverse]: reverse, }; return ( {icon && {icon}} {children && {children}} ); };