From b306377301ffce2466f8cd8d938390b9a42bae25 Mon Sep 17 00:00:00 2001 From: April Smith Date: Thu, 5 Dec 2024 15:03:40 +0000 Subject: [PATCH] Add Size small for toogle --- src/core/Toggle.tsx | 20 +++++++++++-- src/core/Toggle/Toggle.stories.tsx | 5 ++++ .../__snapshots__/Toggle.stories.tsx.snap | 29 +++++++++++++++---- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/core/Toggle.tsx b/src/core/Toggle.tsx index e52e6993c..5e9ba71a4 100644 --- a/src/core/Toggle.tsx +++ b/src/core/Toggle.tsx @@ -4,22 +4,36 @@ import cn from "./utils/cn"; type ToggleProps = { id: string; + size?: string; label?: string; className?: string; } & React.ButtonHTMLAttributes; -const Toggle: React.FC = ({ id, label, className, ...props }) => { +const Toggle: React.FC = ({ + id, + size, + label, + className, + ...props +}) => { + const rootSize = size === "small" ? "w-[42px] h-[24px]" : "w-[56px] h-32"; + const thumbSize = + size === "small" ? "w-[21px] h-[21px] translate-x-1 data-[state=checked]:translate-x-[20px]" : "h-[28px] w-[28px] translate-x-2 data-[state=checked]:translate-x-[26px]"; + return (
- + {label ? (
+`; + +exports[`Components/Toggle Small smoke-test 1`] = ` +
+