From 13d3430948e93ff48a46b6ee9322d03ee6df49c4 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 18 Feb 2025 15:57:30 +0800 Subject: [PATCH] chore: switch ref change --- web/app/components/base/switch/index.tsx | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/web/app/components/base/switch/index.tsx b/web/app/components/base/switch/index.tsx index dacf2aeb72..6cd6852044 100644 --- a/web/app/components/base/switch/index.tsx +++ b/web/app/components/base/switch/index.tsx @@ -12,17 +12,9 @@ type SwitchProps = { } const Switch = ( - { - ref: propRef, - onChange, - size = 'md', - defaultValue = false, - disabled = false, - className, - }: SwitchProps & { + { ref: propRef, onChange, size = 'md', defaultValue = false, disabled = false, className }: SwitchProps & { ref?: React.RefObject; - }, -) => { + }) => { const [enabled, setEnabled] = useState(defaultValue) useEffect(() => { setEnabled(defaultValue) @@ -65,6 +57,7 @@ const Switch = ( enabled ? 'bg-components-toggle-bg' : 'bg-components-toggle-bg-unchecked', 'relative inline-flex flex-shrink-0 cursor-pointer rounded-[5px] border-2 border-transparent transition-colors duration-200 ease-in-out', disabled ? '!opacity-50 !cursor-not-allowed' : '', + size === 'xs' && 'rounded-sm', className, )} > @@ -73,6 +66,7 @@ const Switch = ( className={classNames( circleStyle[size], enabled ? translateLeft[size] : 'translate-x-0', + size === 'xs' && 'rounded-[1px]', 'pointer-events-none inline-block transform rounded-[3px] bg-components-toggle-knob shadow ring-0 transition duration-200 ease-in-out', )} />