From 355363a80a5f6bb68c5ae3d900a2d4e0cca15e40 Mon Sep 17 00:00:00 2001 From: AtsushiM Date: Thu, 5 Sep 2024 07:50:51 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20Swith=E3=81=AE=E5=9E=8B=E3=82=92?= =?UTF-8?q?=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../smarthr-ui/src/components/Switch/Switch.tsx | 13 +++++++++---- .../VisuallyHiddenText/VisuallyHiddenText.tsx | 17 ++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/packages/smarthr-ui/src/components/Switch/Switch.tsx b/packages/smarthr-ui/src/components/Switch/Switch.tsx index ef84fa9f30..2b12292d95 100644 --- a/packages/smarthr-ui/src/components/Switch/Switch.tsx +++ b/packages/smarthr-ui/src/components/Switch/Switch.tsx @@ -55,14 +55,19 @@ type Props = InputHTMLAttributes & { export const Switch = forwardRef( ({ children, dangerouslyLabelHidden, className, id, ...props }, ref) => { const { wrapper, input, icon, iconWrapper } = useMemo(() => switchStyle(), []) - const ActualLabel = dangerouslyLabelHidden ? VisuallyHiddenText : Text const inputId = useId(id) return ( - - {children} - + {dangerouslyLabelHidden ? ( + + {children} + + ) : ( + + )} {/* eslint-disable-next-line smarthr/a11y-input-has-name-attribute */} - } & ComponentProps<'span'> - > -> = ({ as: Component = 'span', className, ...props }) => { +type Props = PropsWithChildren<{ + as?: T +}> & + ComponentProps + +export const VisuallyHiddenText = ({ + as: Component = 'span', + className, + ...props +}: Props) => { const styles = useMemo(() => visuallyHiddenText({ className }), [className]) return