import * as React from 'react'; import clsx from 'clsx'; import { Button } from '@tesseract-design/web-base'; /** * Derived HTML element of the {@link LinkButton} component. */ export type LinkButtonDerivedElement = HTMLAnchorElement; /** * Props of the {@link LinkButton} component. */ export interface LinkButtonProps extends Omit, 'size'> { /** * Should the component occupy the whole width of its parent? */ block?: boolean; /** * Variant of the component. */ variant?: Button.Variant; /** * Complementary content of the component. */ subtext?: React.ReactNode; /** * Short complementary content displayed at the edge of the component. */ badge?: React.ReactNode; /** * Is this component part of a menu? */ menuItem?: boolean; /** * Size of the component. */ size?: Button.Size; /** * Should the component's content use minimal space? */ compact?: boolean; /** * Component to use in rendering. */ component?: React.ElementType; /** * Is the component unable to receive activation? */ disabled?: boolean; } /** * Component for performing a navigation action. */ export const LinkButton = React.forwardRef(( { variant = 'bare' as const, subtext, badge, menuItem = false, children, size = 'medium' as const, compact = false, className, block = false, component: EnabledComponent = 'a', disabled = false, href, style, ...etcProps }, forwardedRef, ) => { const Component = disabled ? 'button' : EnabledComponent; return ( {children} {subtext && ( <> {' - '} {subtext} )} {badge && ( <> {' - '} {badge} )} {menuItem && ( )} ); }); LinkButton.displayName = 'LinkButton'; LinkButton.defaultProps = { variant: 'bare', size: 'medium', compact: false, menuItem: false, component: 'a', badge: undefined, subtext: undefined, block: false, disabled: false, };