| 209 | }; |
| 210 | |
| 211 | export const useGetIconWithSize = ( |
| 212 | size: ButtonSize, |
| 213 | iconOnly: boolean, |
| 214 | iconPosition: ButtonIconPosition, |
| 215 | ): (( |
| 216 | icon: React.ReactElement<IconProps>, |
| 217 | iconSecondaryOnHover?: boolean, |
| 218 | ) => React.ReactElement<IconProps>) => { |
| 219 | return (icon: React.ReactElement<IconProps>, iconSecondaryOnHover = false) => |
| 220 | React.cloneElement(icon, { |
| 221 | secondary: iconSecondaryOnHover |
| 222 | ? !icon.props?.secondary |
| 223 | : icon.props?.secondary, |
| 224 | size: icon.props?.size ?? buttonSizeToIconSize[size], |
| 225 | className: classNames( |
| 226 | icon.props.className, |
| 227 | 'btn-icon', |
| 228 | !iconOnly && 'text-base', |
| 229 | !iconOnly && |
| 230 | iconPosition === ButtonIconPosition.Left && |
| 231 | 'btn-icon-left', |
| 232 | !iconOnly && |
| 233 | iconPosition === ButtonIconPosition.Right && |
| 234 | 'btn-icon-right', |
| 235 | !iconOnly && iconPosition === ButtonIconPosition.Top && 'btn-icon-top', |
| 236 | ), |
| 237 | }); |
| 238 | }; |
| 239 | |
| 240 | // CardAction bypasses this map and sets its icon size per density. |
| 241 | const buttonSizeToIconSizeV2: Record<ButtonSize, IconSize> = { |