import { h, type FunctionComponent } from 'preact' import cn from 'classnames' type Styles = { base?: string touched?: string element?: string label?: string icon?: string autoHeight?: string fullWidth?: string invert?: string } & Record & Record & Record type Options = { defaults: Pick, 'autoHeight' | 'color' | 'design' | 'fullWidth' | 'icon' | 'invert' | 'size'> icons: Record styles: Styles } type Props = { autoHeight?: boolean className?: string color?: C design?: D href?: string fullWidth?: boolean icon?: I iconSize?: string invert?: boolean size?: S tabIndex?: number title?: string } export default function linkButtonFactory< C extends string = never, D extends string = never, I extends string = never, S extends string = never, >({ defaults, icons, styles }: Options) { const LinkButton: FunctionComponent> = ({ autoHeight = defaults?.autoHeight, children, className, color = defaults?.color, design = defaults?.design, href, fullWidth = defaults?.fullWidth, icon = defaults?.icon, iconSize, invert = defaults?.invert, size = defaults?.size, tabIndex, title, }) => ( {icon && } {children && {children}} ) return LinkButton }