-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
945c5a7
commit b53a53f
Showing
8 changed files
with
187 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export { Button } from './Button' | ||
export { buttonVariants } from './styles.css' | ||
export type { ButtonVariants } from './styles.css' | ||
export { Button, type ButtonProps } from './Button' | ||
export { buttonVariants } from './Button' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,23 @@ | ||
import { ComponentType, ElementType, forwardRef } from 'react' | ||
import type { VariantProps } from 'class-variance-authority' | ||
import { ComponentType, forwardRef } from 'react' | ||
|
||
import { | ||
PolymorphicComponent, | ||
PolymorphicProps, | ||
PolymorphicRef, | ||
} from '~/components/Box' | ||
import { Button, ButtonVariants } from '~/components/Button' | ||
import { Button, buttonVariants } from '~/components/Button' | ||
import { IconProps } from '~/icons/types' | ||
|
||
type IconButtonVariants = { variant?: (ButtonVariants & {})['variant'] } | ||
|
||
type IconButtonProps = IconButtonVariants & { | ||
export interface IconButtonProps | ||
extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'disabled'> { | ||
asChild?: boolean | ||
disabled?: boolean | ||
pending?: boolean | ||
size?: 'xs' | 'sm' | 'md' | 'lg' | ||
variant?: VariantProps<typeof buttonVariants>['variant'] | ||
icon: ComponentType<IconProps> | ||
} | ||
|
||
export const IconButton: PolymorphicComponent<IconButtonProps, 'button'> = | ||
forwardRef( | ||
<T extends ElementType>( | ||
props: PolymorphicProps<IconButtonProps, T>, | ||
ref: PolymorphicRef<T> | ||
) => { | ||
const { icon, size = 'md', ...rest } = props | ||
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>( | ||
(props, ref) => { | ||
const { icon, size = 'md', ...rest } = props | ||
|
||
return ( | ||
<Button | ||
leftIcon={icon} | ||
size={size} | ||
flexShrink="0" | ||
ref={ref} | ||
{...rest} | ||
/> | ||
) | ||
} | ||
) | ||
return <Button leftIcon={icon} size={size} ref={ref} {...rest} /> | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { IconButton } from './IconButton' | ||
export type { IconButtonProps } from './IconButton' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters