37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import type { ButtonHTMLAttributes } from 'react'
|
|
import { cx } from './cx'
|
|
|
|
type Variant = 'primary' | 'secondary' | 'icon'
|
|
|
|
const BASE =
|
|
'inline-flex items-center justify-center gap-1.5 whitespace-nowrap transition-colors cursor-pointer ' +
|
|
'disabled:opacity-45 disabled:cursor-not-allowed'
|
|
|
|
const VARIANTS: Record<Variant, string> = {
|
|
primary: 'h-8 px-3 rounded-md bg-ink-2 text-white text-[13px] font-semibold shadow-primary hover:bg-ink active:bg-black',
|
|
secondary: 'h-8 px-3 rounded-md bg-surface text-ink text-[13px] font-medium shadow-secondary hover:bg-surface-2 active:bg-rule',
|
|
icon: 'w-7 h-7 rounded-md text-ink-3 hover:bg-rule',
|
|
}
|
|
|
|
type Props = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
variant?: Variant
|
|
block?: boolean
|
|
mobile?: boolean
|
|
}
|
|
|
|
export function Button({ variant = 'primary', block = false, mobile = false, className, type = 'button', ...rest }: Props) {
|
|
return (
|
|
<button
|
|
type={type}
|
|
className={cx(
|
|
BASE,
|
|
VARIANTS[variant],
|
|
mobile && variant !== 'icon' && 'h-12 rounded-xl text-sm',
|
|
block && 'w-full',
|
|
className,
|
|
)}
|
|
{...rest}
|
|
/>
|
|
)
|
|
}
|