From 82f7fa6e7a9d8dbb6bbd13cf551c04c76901e6ec Mon Sep 17 00:00:00 2001 From: April Smith Date: Thu, 5 Dec 2024 17:06:58 +0000 Subject: [PATCH] Change the size default and remove the component not necessary to display Update based on review and add type --- src/core/Toggle.tsx | 16 ++++++++----- src/core/Toggle/Toggle.stories.tsx | 9 ++------ .../__snapshots__/Toggle.stories.tsx.snap | 23 +++---------------- 3 files changed, 15 insertions(+), 33 deletions(-) diff --git a/src/core/Toggle.tsx b/src/core/Toggle.tsx index 39bce1d5d..87e094590 100644 --- a/src/core/Toggle.tsx +++ b/src/core/Toggle.tsx @@ -4,23 +4,24 @@ import cn from "./utils/cn"; type ToggleProps = { id: string; - size?: "default" | "small"; + 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" + 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]"; + : "h-[28px] w-[28px] translate-x-2 data-[state=checked]:translate-x-[26px]"; return (
@@ -34,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 978f98217..6e05d4b33 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 b2ac92808..298f7f77d 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`] = ` -
-