mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 02:06:19 +01:00
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
import ReactTooltip from 'react-tooltip';
|
|
import classNames from 'classnames';
|
|
import Icon from './Icon';
|
|
import styles from './Button.module.css';
|
|
|
|
export default function Button({
|
|
type = 'button',
|
|
icon,
|
|
size,
|
|
variant,
|
|
children,
|
|
className,
|
|
tooltip,
|
|
tooltipId,
|
|
disabled = false,
|
|
onClick = () => {},
|
|
...props
|
|
}) {
|
|
return (
|
|
<button
|
|
data-tip={tooltip}
|
|
data-effect="solid"
|
|
data-for={tooltipId}
|
|
type={type}
|
|
className={classNames(styles.button, className, {
|
|
[styles.large]: size === 'large',
|
|
[styles.small]: size === 'small',
|
|
[styles.xsmall]: size === 'xsmall',
|
|
[styles.action]: variant === 'action',
|
|
[styles.danger]: variant === 'danger',
|
|
[styles.light]: variant === 'light',
|
|
[styles.disabled]: disabled,
|
|
})}
|
|
disabled={disabled}
|
|
onClick={!disabled ? onClick : null}
|
|
{...props}
|
|
>
|
|
{icon && <Icon icon={icon} size={size} />}
|
|
{children}
|
|
{tooltip && <ReactTooltip id={tooltipId}>{tooltip}</ReactTooltip>}
|
|
</button>
|
|
);
|
|
}
|