From 77ce6fe2bb4faddd307fa6286207a7cfbdbaebe4 Mon Sep 17 00:00:00 2001 From: Rafael Youakeem Date: Fri, 13 Sep 2024 11:37:51 +0200 Subject: [PATCH] Add IconButton component --- packages/ui/src/components/Button/Button.tsx | 4 +++- .../ui/src/components/Button/IconButton.tsx | 17 +++++++++++++++++ packages/ui/src/index.ts | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 packages/ui/src/components/Button/IconButton.tsx diff --git a/packages/ui/src/components/Button/Button.tsx b/packages/ui/src/components/Button/Button.tsx index 940f5c73ad..8090ab9611 100644 --- a/packages/ui/src/components/Button/Button.tsx +++ b/packages/ui/src/components/Button/Button.tsx @@ -23,6 +23,7 @@ type BaseProps = { loading?: boolean Icon?: ReactNode iconPosition?: 'left' | 'right' + isIconButton?: boolean } export type ButtonProps = PolymorphicComponentPropsWithRef< @@ -51,6 +52,7 @@ export const Button: PolymorphicComponent = forwardRef(function Button< children, Icon, iconPosition = 'left', + isIconButton, ...props }: ButtonProps, ref?: PolymorphicRef, @@ -83,7 +85,7 @@ export const Button: PolymorphicComponent = forwardRef(function Button< > {iconPosition === 'left' && Icon} - {children && {children}} + {children && {children}} {iconPosition === 'right' && Icon} {hiddenText && hiddenText} diff --git a/packages/ui/src/components/Button/IconButton.tsx b/packages/ui/src/components/Button/IconButton.tsx new file mode 100644 index 0000000000..405d76d30e --- /dev/null +++ b/packages/ui/src/components/Button/IconButton.tsx @@ -0,0 +1,17 @@ +import { type ComponentProps, forwardRef } from 'react' +import { Button } from './Button' + +type ButtonProps = Omit>, 'size'> + +export const IconButton = forwardRef((props, forwardedRef) => ( +