From 84d6f05191102e4e9354d245d9b7828ea6369bad Mon Sep 17 00:00:00 2001 From: April Smith Date: Thu, 5 Dec 2024 15:19:09 +0000 Subject: [PATCH] Change the size default and remove the component not necessary to display Update based on review and add type add default value for Toogle size --- src/core/Toggle.tsx | 16 +++++++++---- src/core/Toggle/Toggle.stories.tsx | 9 ++------ .../__snapshots__/Toggle.stories.tsx.snap | 23 +++---------------- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/core/Toggle.tsx b/src/core/Toggle.tsx index 5e9ba71a..87e09459 100644 --- a/src/core/Toggle.tsx +++ b/src/core/Toggle.tsx @@ -4,21 +4,24 @@ import cn from "./utils/cn"; type ToggleProps = { id: string; - size?: string; + size?: "sm" | "lg"; label?: string; className?: string; + onCheckedChange?: (checked: boolean) => void; } & React.ButtonHTMLAttributes; const Toggle: React.FC = ({ id, - size, + size = "lg", label, className, ...props }) => { - const rootSize = size === "small" ? "w-[42px] h-[24px]" : "w-[56px] h-32"; + const rootSize = size === "sm" ? "w-[42px] h-[24]" : "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]"; + size === "sm" + ? "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 (
@@ -32,7 +35,10 @@ const Toggle: React.FC = ({ {...props} > {label ? ( diff --git a/src/core/Toggle/Toggle.stories.tsx b/src/core/Toggle/Toggle.stories.tsx index 978f9821..6e05d4b3 100644 --- a/src/core/Toggle/Toggle.stories.tsx +++ b/src/core/Toggle/Toggle.stories.tsx @@ -15,17 +15,12 @@ Default.args = {}; export const Checked = Template.bind({}); Checked.args = { - checked: true, + defaultChecked: true, disabled: false, }; export const Disabled = Template.bind({}); Disabled.args = { - checked: false, + defaultChecked: false, disabled: true, }; - -export const Small = Template.bind({}); -Small.args = { - size: "small", -}; diff --git a/src/core/Toggle/__snapshots__/Toggle.stories.tsx.snap b/src/core/Toggle/__snapshots__/Toggle.stories.tsx.snap index b2ac9280..298f7f77 100644 --- a/src/core/Toggle/__snapshots__/Toggle.stories.tsx.snap +++ b/src/core/Toggle/__snapshots__/Toggle.stories.tsx.snap @@ -10,7 +10,7 @@ exports[`Components/Toggle Checked smoke-test 1`] = ` class="p-0 bg-neutral-600 rounded-full relative inline-block transition-colors data-[disabled]:bg-gui-unavailable data-[disabled]:cursor-not-allowed data-[state=checked]:bg-orange-600 focus:outline-none focus-visible:outline-offset-0 focus-visible:outline-4 focus-visible:outline-gui-focus w-[56px] h-32" > @@ -27,7 +27,7 @@ exports[`Components/Toggle Default smoke-test 1`] = ` class="p-0 bg-neutral-600 rounded-full relative inline-block transition-colors data-[disabled]:bg-gui-unavailable data-[disabled]:cursor-not-allowed data-[state=checked]:bg-orange-600 focus:outline-none focus-visible:outline-offset-0 focus-visible:outline-4 focus-visible:outline-gui-focus w-[56px] h-32" > @@ -47,24 +47,7 @@ exports[`Components/Toggle Disabled smoke-test 1`] = ` > - - -
-`; - -exports[`Components/Toggle Small smoke-test 1`] = ` -
-