import { forwardRef, isValidElement } from "react"; import { StyledLinkIconButton } from "./link-icon-button.styled"; import type { IconProps } from "../icons/withSharedIconProps"; import type { ColorKey } from "../../theme"; import type { WithTestId } from "../../types"; interface LinkIconButtonProps extends WithTestId> { /** * Icon to display */ Icon: React.FC | React.ReactElement; /** * The redirect url of the LinkButton */ href: string; } /** * Icon button component */ export const LinkIconButton = forwardRef((props, ref) => { const { Icon, variant = "primary", ...rest } = props; const iconColor: ColorKey = variant === "primary" ? "$light-chromia-dark" : "$light-off-white"; return ( {/* @ts-expect-error ts unable to correctly type narrow else branch */} {isValidElement(Icon) ? Icon : } ); }); LinkIconButton.displayName = "IconButton";