/** * Tailwind CSS implementation of Link component * Uses Seeds link CSS classes from link.css */ import * as React from "react"; import type { TypeLinkProps } from "./LinkTypes"; // Utility for merging class names properly function cn( ...inputs: (string | undefined | null | false | Record)[] ): string { const classes: string[] = []; for (const input of inputs) { if (!input) continue; if (typeof input === "string") { classes.push(input); } else if (typeof input === "object") { for (const [key, value] of Object.entries(input)) { if (value) { classes.push(key); } } } } return classes.join(" "); } export const LinkTailwind = React.forwardRef< HTMLAnchorElement | HTMLButtonElement, TypeLinkProps >( ( { href, external, children, disabled, onClick, as, underline = true, qa = {}, className, ...rest }, ref ) => { const type = as || (href ? "a" : "button"); const Component = type as any; const classes = cn( "seeds-link", { "seeds-link-underline": !!underline, "seeds-link-disabled": !!disabled, "seeds-link-no-href": !href, }, className ); return ( {children} ); } ); LinkTailwind.displayName = "LinkTailwind";