Skip to content

Commit

Permalink
Added a successIconSize property calculated based on the button size …
Browse files Browse the repository at this point in the history
…if the icon is a function (#331)
  • Loading branch information
yardenli authored Nov 14, 2021
1 parent 7f4be66 commit 650e81c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/Button/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ const Button = forwardRef(
return "24";
}, [rightIcon, size]);

const successIconSize = useMemo(() => {
if (typeof successIcon !== "function") return;
if (size === SIZES.SMALL) return "20";
if (size === SIZES.MEDIUM) return "24";
return "24";
}, [successIcon, size]);

if (loading) {
return (
<button {...buttonProps}>
Expand All @@ -239,6 +246,7 @@ const Button = forwardRef(
iconType={Icon.type.ICON_FONT}
clickable={false}
icon={successIcon}
iconSize={successIconSize}
className={cx({
"monday-style-button--left-icon": !!successText
})}
Expand Down

0 comments on commit 650e81c

Please sign in to comment.