/**
*
* Button
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import {
LoadingIndicator,
Button as StyledButton,
colors,
} from '@buffetjs/styles';
import { Plus } from '@buffetjs/icons';
import Flex from '../Flex';
import PrefixIcon from '../PrefixIcon';
function Button({
children,
color,
disabled,
icon,
label,
isLoading,
...rest
}) {
const content = label || children;
const img =
icon === true ? (
) : (
);
if (isLoading) {
return (
{
// Preventing the user from clicking the button when loading
e.preventDefault();
}}
>
);
}
return (
{img}
{content}
);
}
Button.defaultProps = {
children: null,
color: 'primary',
disabled: false,
icon: false,
isLoading: false,
label: null,
type: 'button',
};
Button.propTypes = {
children: PropTypes.node,
color: PropTypes.oneOf([
'primary',
'secondary',
'cancel',
'success',
'delete',
'none',
]),
disabled: PropTypes.bool,
icon: PropTypes.oneOfType([PropTypes.node, PropTypes.bool]),
isLoading: PropTypes.bool,
label: PropTypes.string,
type: PropTypes.oneOf(['submit', 'reset', 'button', 'menu']),
};
export default Button;