import React, { ReactNode } from 'react' interface ButtonProps { disabled?: boolean children?: ReactNode className?: string icon?: ReactNode onKeyDown?: () => void onClick?: () => void onDown?: (ev: PointerEvent) => void onUp?: (ev: PointerEvent) => void style?: React.CSSProperties } const Button: React.FC = props => { const { children, className, disabled, icon, onKeyDown, onClick, onDown, onUp, style, } = props const blurOnClick = (e: React.MouseEvent) => { e.currentTarget.blur() onClick?.() } return (
) => { onDown?.(ev.nativeEvent) }} onPointerUp={(ev: React.PointerEvent) => { onUp?.(ev.nativeEvent) }} tabIndex={-1} className={[ 'btn-primary', children ? 'btn-primary-content' : '', disabled === true ? 'btn-primary-disabled' : '', className, ].join(' ')} > {icon} {children ? {children} : null}
) } Button.defaultProps = { disabled: false, } export default Button