From 9de00118b310c19c6ac6cf21cb425675acd99ef3 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Godde Date: Wed, 10 Jan 2024 14:15:48 +0100 Subject: [PATCH] feat(ui): add label prop to toggle component (#215) --- ui/src/components/buttons/Toggle.tsx | 106 ++++++++++++++----------- ui/src/components/misc/ThemeToggle.tsx | 7 +- ui/src/pages/layers/Layers.tsx | 39 ++++----- 3 files changed, 80 insertions(+), 72 deletions(-) diff --git a/ui/src/components/buttons/Toggle.tsx b/ui/src/components/buttons/Toggle.tsx index a8478b2a..73eccb72 100644 --- a/ui/src/components/buttons/Toggle.tsx +++ b/ui/src/components/buttons/Toggle.tsx @@ -9,6 +9,8 @@ export interface ToggleProps { className?: string; checked?: boolean; defaultChecked?: boolean; + label?: string; + labelPlacement?: "left" | "right"; onChange?: (e: React.ChangeEvent) => void; } @@ -16,6 +18,8 @@ const Toggle: React.FC = ({ className, checked, defaultChecked, + label, + labelPlacement = "left", onChange, }) => { const [internalChecked, setInternalChecked] = useState( @@ -27,51 +31,63 @@ const Toggle: React.FC = ({ }; return ( -