import * as classNames from 'classnames'; import * as React from 'react'; import { OptionalComponentPropAndHTMLAttributes } from '../../types'; export type ButtonProps = { /** * Set the style `display: block;`. */ block?: boolean; /** * Make the button large */ large?: boolean; /** * Make the button small */ small?: boolean; } & React.ButtonHTMLAttributes & OptionalComponentPropAndHTMLAttributes; /** * Used in place of a standard `button` tag, this component adds additional styles and effects. */ const Button = (props: ButtonProps) => { const { children, className, block, large, small, component: Component = 'button', ...remainingProps } = props; const myClassNames = [ 'button', block ? 'block' : null, small ? 'small' : null, large ? 'large' : null, className, ]; // Cast necessary otherwise types are too complex const CastComponent = Component as 'button'; return ( {children} ); }; export default React.memo(Button);