Skip to content

Commit

Permalink
Remove defaultProps from Button and clean up some prop handling
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundito committed Jan 3, 2023
1 parent 617fca1 commit fa3ab45
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions airbyte-webapp/src/components/ui/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ import { ButtonProps } from "./types";

export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
const {
full = false,
size = "xs",
iconPosition = "left",
variant = "primary",
children,
className,
clickable,
full,
icon,
iconPosition,
isLoading,
size,
variant,
wasActive,
width,
disabled,
...buttonProps
} = props;

const buttonStyles = {
[styles.full]: full,
[styles.isLoading]: isLoading,
Expand All @@ -34,17 +36,16 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>((props, r
[styles.typeSecondary]: variant === "secondary",
[styles.typeDark]: variant === "dark",
};
const widthStyle: { width?: string } = {};
if (width) {
widthStyle.width = `${width}px`;
}

const widthStyle: React.CSSProperties = width ? { width: `${width}px` } : {};

return (
<button
ref={ref}
style={widthStyle}
className={classNames(styles.button, className, buttonStyles)}
disabled={disabled || isLoading}
{...buttonProps}
disabled={buttonProps.disabled || isLoading}
>
{isLoading && (
<FontAwesomeIcon
Expand Down Expand Up @@ -76,10 +77,3 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>((props, r
</button>
);
});

Button.defaultProps = {
full: false,
size: "xs",
variant: "primary",
iconPosition: "left",
};

0 comments on commit fa3ab45

Please sign in to comment.