manifold/web/components/button.tsx

33 lines
970 B
TypeScript
Raw Normal View History

2021-12-10 06:11:45 +00:00
export function Button(props: {
className?: string
onClick?: () => void
color: 'green' | 'red' | 'deemphasized'
hideFocusRing?: boolean
children?: any
}) {
const { className, onClick, children, color, hideFocusRing } = props
return (
<button
type="button"
className={classNames(
'inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white',
!hideFocusRing && 'focus:outline-none focus:ring-2 focus:ring-offset-2',
color === 'green' &&
'bg-green-500 hover:bg-green-600 focus:ring-green-500',
color === 'red' && 'bg-red-500 hover:bg-red-600 focus:ring-red-500',
color === 'deemphasized' &&
2021-12-10 07:01:39 +00:00
'bg-transparent hover:bg-gray-500 focus:ring-gray-400',
2021-12-10 06:11:45 +00:00
className
)}
onClick={onClick}
>
{children}
</button>
)
}
function classNames(...classes: any[]) {
return classes.filter(Boolean).join(' ')
}