From cfa4d4d157bd6a6a4d4c3ec3d6e2b0fc16e501c5 Mon Sep 17 00:00:00 2001 From: lerte smith Date: Tue, 5 Nov 2024 01:05:30 +0800 Subject: [PATCH] button isDisabled props --- apps/docs/src/usages/buttons/button.tsx | 10 +++++----- .../actify/src/components/Button/Button.tsx | 11 +++++----- packages/actify/src/components/Button/Fab.tsx | 9 +++------ .../src/components/Button/IconButton.tsx | 20 ++++++------------- 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/apps/docs/src/usages/buttons/button.tsx b/apps/docs/src/usages/buttons/button.tsx index 5d0fdb20..8f10d7ce 100644 --- a/apps/docs/src/usages/buttons/button.tsx +++ b/apps/docs/src/usages/buttons/button.tsx @@ -17,7 +17,7 @@ export default () => { - @@ -33,7 +33,7 @@ export default () => { - @@ -49,7 +49,7 @@ export default () => { - @@ -65,7 +65,7 @@ export default () => { - @@ -81,7 +81,7 @@ export default () => { - diff --git a/packages/actify/src/components/Button/Button.tsx b/packages/actify/src/components/Button/Button.tsx index 1c3b4e05..af7d9575 100644 --- a/packages/actify/src/components/Button/Button.tsx +++ b/packages/actify/src/components/Button/Button.tsx @@ -24,7 +24,7 @@ type ButtonProps = { popoverTargetAction?: 'show' | 'toggle' | 'hide' color?: 'primary' | 'secondary' | 'tertiary' | 'error' variant?: 'elevated' | 'filled' | 'tonal' | 'outlined' | 'text' -} & React.ComponentProps<'button'> & +} & Omit, 'disabled'> & AriaButtonProps const Button = (props: ButtonProps) => { @@ -36,7 +36,7 @@ const Button = (props: ButtonProps) => { ripple = true, color = 'primary', variant = 'elevated', - disabled = false, + isDisabled = false, className, children } = props @@ -50,7 +50,7 @@ const Button = (props: ButtonProps) => { buttons['btn'], colors[color], variants[variant], - disabled && buttons['disabled'], + isDisabled && buttons['disabled'], className ) @@ -58,13 +58,12 @@ const Button = (props: ButtonProps) => { return (
- + {variant == 'outlined' &&
} - {ripple && } + {ripple && } ) } diff --git a/packages/actify/src/components/Button/IconButton.tsx b/packages/actify/src/components/Button/IconButton.tsx index 7fbabf86..3d081d73 100644 --- a/packages/actify/src/components/Button/IconButton.tsx +++ b/packages/actify/src/components/Button/IconButton.tsx @@ -11,6 +11,7 @@ import { VariantProps, tv } from 'tailwind-variants' import { FocusRing } from './../FocusRing' import { Ripple } from './../Ripple' +import clsx from 'clsx' const root = tv({ base: [ @@ -39,21 +40,13 @@ const root = tv({ type IconButtonProps = { ripple?: boolean - disabled?: boolean type?: 'submit' | 'reset' | 'button' variant?: VariantProps['variant'] -} & React.ComponentProps<'button'> & +} & Omit, 'disabled'> & AriaButtonProps const IconButton = (props: IconButtonProps) => { - const { - id, - ref, - disabled, - children, - className, - ripple = !disabled && true - } = props + const { id, ref, ripple, children, className, isDisabled } = props const buttonRef = React.useRef(null) const { buttonProps } = useButton(props, buttonRef) @@ -63,15 +56,14 @@ const IconButton = (props: IconButtonProps) => { return (