import cx from "classnames"; import React from "react"; import { Icon } from "../Icon"; const CLASS_ROOT = "social-button"; export type SocialName = | "x" | "facebook-2" | "linkedin-2" | "instagram" | "pinterest" | "snapchat" | "tiktok" | "whatsapp" | "youtube" | "email"; type CommonProps = { name: SocialName; className?: string; }; type ButtonProps = CommonProps & Omit< React.ButtonHTMLAttributes, "type" | keyof CommonProps >; type LinkProps = CommonProps & Omit, keyof CommonProps> & { href: string; }; export type SocialButtonProps = ButtonProps | LinkProps; export const SocialButton = React.forwardRef< HTMLButtonElement | HTMLAnchorElement, SocialButtonProps >(({ name, className, ...rest }, ref) => { const props = rest as any; const classes = cx(CLASS_ROOT, `${CLASS_ROOT}--${name}`, className); if (!("href" in props)) { return ( ); } else { return ( } className={classes} {...props} > ); } }); SocialButton.displayName = "SocialButton";