( props: ButtonHTMLType<C> & ButtonProps<C> )
| 57 | // Our Button component is built thinking of it as a button, |
| 58 | // but it can also be used as a link and include the anchor props |
| 59 | export const Button = <C extends ButtonComponentType = 'button'>( |
| 60 | props: ButtonHTMLType<C> & ButtonProps<C> |
| 61 | ) => { |
| 62 | const { |
| 63 | width, |
| 64 | active, |
| 65 | children, |
| 66 | variant = 'primary', |
| 67 | Component = 'button', |
| 68 | loading = false, |
| 69 | style = {}, |
| 70 | size = 'md', |
| 71 | className, |
| 72 | ...rest |
| 73 | } = props |
| 74 | |
| 75 | const Compt: any = Component |
| 76 | const rootClassName = clsx( |
| 77 | 'relative inline-flex items-center justify-center cursor pointer no-underline px-3.5 rounded-md', |
| 78 | 'font-medium outline-0 select-none align-middle whitespace-nowrap', |
| 79 | 'transition-colors ease-in duration-200', |
| 80 | variant !== 'ghost' && 'border border-solid', |
| 81 | variants[variant], |
| 82 | sizes[size], |
| 83 | { 'cursor-not-allowed': loading }, |
| 84 | className |
| 85 | ) |
| 86 | |
| 87 | return ( |
| 88 | <Compt |
| 89 | aria-pressed={active} |
| 90 | data-variant={variant} |
| 91 | className={rootClassName} |
| 92 | style={{ |
| 93 | width, |
| 94 | ...style, |
| 95 | }} |
| 96 | {...rest} |
| 97 | > |
| 98 | {loading ? ( |
| 99 | <i className="m-0 flex"> |
| 100 | <LoadingDots /> |
| 101 | </i> |
| 102 | ) : ( |
| 103 | children |
| 104 | )} |
| 105 | </Compt> |
| 106 | ) |
| 107 | } |
nothing calls this directly
no outgoing calls
no test coverage detected