From 101852c7d1b8e84402cba6a40913b6e15de686ab Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Fri, 7 Mar 2025 17:16:45 +0530 Subject: [PATCH] (feat:toggle) add id, aria props --- frontend/src/components/ToggleSwitch.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/ToggleSwitch.tsx b/frontend/src/components/ToggleSwitch.tsx index a6fe0c64..3a4ed7db 100644 --- a/frontend/src/components/ToggleSwitch.tsx +++ b/frontend/src/components/ToggleSwitch.tsx @@ -8,6 +8,8 @@ type ToggleSwitchProps = { disabled?: boolean; size?: 'small' | 'medium' | 'large'; labelPosition?: 'left' | 'right'; + id?: string; + ariaLabel?: string; }; const ToggleSwitch: React.FC = ({ @@ -18,13 +20,15 @@ const ToggleSwitch: React.FC = ({ disabled = false, size = 'medium', labelPosition = 'left', + id, + ariaLabel, }) => { // Size configurations const sizeConfig = { small: { - box: 'h-6 w-10', - toggle: 'h-4 w-4 left-1 top-1', - translate: 'translate-x-4', + box: 'h-5 w-9', + toggle: 'h-4 w-4 left-0.5 top-0.5', + translate: 'translate-x-full', }, medium: { box: 'h-8 w-14', @@ -58,14 +62,16 @@ const ToggleSwitch: React.FC = ({
onChange(e.target.checked)} className="sr-only" disabled={disabled} + aria-label={ariaLabel} />