fix onClick check
This commit is contained in:
parent
8185468bd2
commit
9acea28a35
@ -5,16 +5,6 @@ import classnames from 'classnames';
|
|||||||
const baseClasses =
|
const baseClasses =
|
||||||
'text-center items-center justify-center outline-none transition duration-300 ease-in-out font-bold focus:outline-none';
|
'text-center items-center justify-center outline-none transition duration-300 ease-in-out font-bold focus:outline-none';
|
||||||
|
|
||||||
const defaults = {
|
|
||||||
color: 'default',
|
|
||||||
disabled: false,
|
|
||||||
fullWidth: false,
|
|
||||||
rounded: 'medium',
|
|
||||||
size: 'medium',
|
|
||||||
type: 'button',
|
|
||||||
variant: 'contained',
|
|
||||||
};
|
|
||||||
|
|
||||||
const roundedClasses = {
|
const roundedClasses = {
|
||||||
none: '',
|
none: '',
|
||||||
small: 'rounded',
|
small: 'rounded',
|
||||||
@ -80,13 +70,13 @@ const fullWidthClasses = {
|
|||||||
|
|
||||||
const IconButton = ({
|
const IconButton = ({
|
||||||
children,
|
children,
|
||||||
variant = defaults.variant,
|
variant,
|
||||||
color = defaults.color,
|
color,
|
||||||
size = defaults.size,
|
size,
|
||||||
rounded = defaults.rounded,
|
rounded,
|
||||||
disabled = defaults.disabled,
|
disabled,
|
||||||
type = defaults.type,
|
type,
|
||||||
fullWidth = defaults.fullWidth,
|
fullWidth,
|
||||||
onClick,
|
onClick,
|
||||||
className,
|
className,
|
||||||
...rest
|
...rest
|
||||||
@ -95,9 +85,7 @@ const IconButton = ({
|
|||||||
|
|
||||||
const handleOnClick = (e) => {
|
const handleOnClick = (e) => {
|
||||||
buttonElement.current.blur();
|
buttonElement.current.blur();
|
||||||
if (onClick) {
|
onClick(e);
|
||||||
onClick(e);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -123,8 +111,19 @@ const IconButton = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IconButton.defaultProps = {
|
||||||
|
onClick: () => {},
|
||||||
|
color: 'default',
|
||||||
|
disabled: false,
|
||||||
|
fullWidth: false,
|
||||||
|
rounded: 'medium',
|
||||||
|
size: 'medium',
|
||||||
|
type: 'button',
|
||||||
|
variant: 'contained',
|
||||||
|
};
|
||||||
|
|
||||||
IconButton.propTypes = {
|
IconButton.propTypes = {
|
||||||
children: PropTypes.node,
|
children: PropTypes.node.isRequired,
|
||||||
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
||||||
rounded: PropTypes.oneOf(['none', 'small', 'medium', 'large', 'full']),
|
rounded: PropTypes.oneOf(['none', 'small', 'medium', 'large', 'full']),
|
||||||
variant: PropTypes.oneOf(['text', 'outlined', 'contained']),
|
variant: PropTypes.oneOf(['text', 'outlined', 'contained']),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user