Prevent warning for rounded buttons (#12357)

feature/default_network_editable
David Walsh 3 years ago committed by GitHub
parent fa52753d00
commit 9fa1e42031
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      ui/components/ui/button/button.component.js

@ -27,22 +27,22 @@ const typeHash = {
const Button = ({ const Button = ({
type, type,
submit, submit = false,
large, large,
children, children,
icon, icon,
className, className,
rounded = true,
...buttonProps ...buttonProps
}) => { }) => {
const doRounding = rounded && type !== 'link';
// To support using the Button component to render styled links that are semantic html // To support using the Button component to render styled links that are semantic html
// we swap the html tag we use to render this component and delete any buttonProps that // we swap the html tag we use to render this component and delete any buttonProps that
// we know to be erroneous attributes for a link. We will likely want to extract Link // we know to be erroneous attributes for a link. We will likely want to extract Link
// to its own component in the future. // to its own component in the future.
let Tag = 'button'; let Tag = 'button';
let rounded = true;
if (type === 'link') { if (type === 'link') {
Tag = 'a'; Tag = 'a';
rounded = false;
} else if (submit) { } else if (submit) {
buttonProps.type = 'submit'; buttonProps.type = 'submit';
} }
@ -59,7 +59,7 @@ const Button = ({
<Tag <Tag
className={classnames( className={classnames(
'button', 'button',
rounded && CLASSNAME_ROUNDED, doRounding && CLASSNAME_ROUNDED,
typeHash[type] || CLASSNAME_DEFAULT, typeHash[type] || CLASSNAME_DEFAULT,
large && CLASSNAME_LARGE, large && CLASSNAME_LARGE,
className, className,
@ -79,10 +79,7 @@ Button.propTypes = {
className: PropTypes.string, className: PropTypes.string,
children: PropTypes.node, children: PropTypes.node,
icon: PropTypes.node, icon: PropTypes.node,
}; rounded: PropTypes.bool,
Button.defaultProps = {
submit: false,
}; };
export default Button; export default Button;

Loading…
Cancel
Save