From 60d061804a7f9010c7f25ba59eea716adc685406 Mon Sep 17 00:00:00 2001 From: lerte smith Date: Thu, 21 Nov 2024 00:28:58 +0800 Subject: [PATCH] IconButton use react-aria-component --- .../src/components/Buttons/IconButton.tsx | 39 +++++++------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/packages/actify/src/components/Buttons/IconButton.tsx b/packages/actify/src/components/Buttons/IconButton.tsx index ddf648d..37a2986 100644 --- a/packages/actify/src/components/Buttons/IconButton.tsx +++ b/packages/actify/src/components/Buttons/IconButton.tsx @@ -1,42 +1,32 @@ 'use client' import { - AriaButtonProps, - mergeProps, - useButton, - useFocusRing -} from 'react-aria' + Button as AriaButton, + ButtonProps as AriaButtonProps +} from 'react-aria-components' import React, { useId } from 'react' +import { mergeProps, useButton, useFocusRing } from 'react-aria' import { FocusRing } from './../FocusRing' import { Ripple } from './../Ripple' import clsx from 'clsx' import styles from './icon-button.module.css' -type IconButtonProps = { +interface IconButtonProps extends AriaButtonProps { + ref?: React.RefObject ripple?: boolean - type?: 'submit' | 'reset' | 'button' variant?: 'standard' | 'outlined' | 'filled' | 'filled-tonal' -} & Omit, 'disabled'> & - AriaButtonProps +} const IconButton = (props: IconButtonProps) => { - const { id, ref, ripple = true, children, className, isDisabled } = props - - const buttonRef = ref || React.useRef(null) - const { buttonProps } = useButton( - props, - buttonRef as React.RefObject - ) - const iconButtonId = id || `actify-icon-button${useId()}` + const { ref, ripple = true, children, className, isDisabled } = props const { focusProps, isFocusVisible } = useFocusRing() return ( - + ) }