import React, { FC } from 'react' import Link from '../Link' import { ColorType, IconProps } from '../interfaces' import { buildClassName } from '../Util' import Image from '../Image' import css from './Button.module.styl' interface Props { outline?: boolean nomargintop?: boolean color?: ColorType children?: React.ReactNode icon?: FC | string size?: 'large' | 'small' | 'block' href?: string as?: string disabled?: boolean loading?: boolean onClick?: (event: React.MouseEvent) => void } export default class Button extends React.Component { public render = () => { let inner: any = this.props.children if (!this.props.loading && this.props.icon) { const Icon = this.props.icon inner = ( <> {typeof Icon === 'string' ? ( ) : ( )} {this.props.children && ( {this.props.children} )} ) } const classes = buildClassName( [css.button], [css[this.props.color as string], this.props.color], [css.outline, this.props.outline], [css[this.props.size as string], this.props.size], [css.nomargintop, this.props.nomargintop], [css.loading, this.props.loading] ) if (this.props.href) { return ( {inner} ) } return ( ) } }