import { Text } from "@prismicio/editor-ui"; import { clsx } from "clsx"; import { cloneElement, type FC, isValidElement, type ReactNode } from "react"; import styles from "./TextLink.module.css"; type IconProps = Readonly<{ className?: string; }>; interface TextLinkProps { children: string; color?: "primary" | "secondary"; endIcon?: ReactNode; href: string; textVariant?: "normal" | "smallBold" | "inherit"; } export const TextLink: FC = (props) => { const { children, color = "primary", endIcon, href, textVariant = "smallBold", ...otherProps } = props; return ( {children} {isValidElement(endIcon) ? cloneElement(endIcon, { className: clsx( endIcon.props.className, styles.endIcon, styles[`icon-${textVariant}`], ), }) : null} ); };