umami/components/common/Button.js

32 lines
693 B
JavaScript
Raw Normal View History

import React from 'react';
import classNames from 'classnames';
import Icon from './Icon';
import styles from './Button.module.css';
2020-08-07 09:24:01 +02:00
export default function Button({
type = 'button',
icon,
size,
variant,
2020-08-07 09:24:01 +02:00
children,
className,
2020-08-08 05:36:57 +02:00
...props
2020-08-07 09:24:01 +02:00
}) {
return (
2020-08-07 09:24:01 +02:00
<button
type={type}
className={classNames(styles.button, className, {
2020-08-09 08:48:43 +02:00
[styles.large]: size === 'large',
2020-08-09 12:04:48 +02:00
[styles.small]: size === 'small',
[styles.xsmall]: size === 'xsmall',
[styles.action]: variant === 'action',
[styles.danger]: variant === 'danger',
2020-08-07 09:24:01 +02:00
})}
2020-08-08 05:36:57 +02:00
{...props}
2020-08-07 09:24:01 +02:00
>
{icon && <Icon icon={icon} size={size} />}
{children}
</button>
);
}