spaCy/website/src/components/button.js

39 lines
1.0 KiB
JavaScript
Raw Normal View History

import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import Link from './link'
import Icon from './icon'
import classes from '../styles/button.module.sass'
2020-08-06 02:22:49 +03:00
export default function Button({
to,
variant = 'secondary',
large = false,
icon,
className,
children,
...props
}) {
const buttonClassNames = classNames(classes.root, className, {
[classes.large]: large,
[classes.primary]: variant === 'primary',
[classes.secondary]: variant === 'secondary',
[classes.tertiary]: variant === 'tertiary',
})
return (
<Link to={to} className={buttonClassNames} hideIcon={true} {...props}>
{icon && <Icon name={icon} width={large ? 16 : 14} inline />}
{children}
</Link>
)
}
Button.propTypes = {
2020-07-01 16:02:55 +03:00
to: PropTypes.string,
variant: PropTypes.oneOf(['primary', 'secondary', 'tertiary']),
large: PropTypes.bool,
icon: PropTypes.string,
className: PropTypes.string,
}