From 1af1f259d07291e5474c517be219d378034f03db Mon Sep 17 00:00:00 2001 From: JWittmeyer Date: Tue, 9 Sep 2025 08:40:22 +0200 Subject: [PATCH 1/2] Adds disabled flag for switch with label --- components/SwitchWithLabel.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/SwitchWithLabel.tsx b/components/SwitchWithLabel.tsx index b6e386b..515e51f 100644 --- a/components/SwitchWithLabel.tsx +++ b/components/SwitchWithLabel.tsx @@ -2,7 +2,7 @@ import { combineClassNames } from "@/submodules/javascript-functions/general"; import { Switch } from "@headlessui/react"; import { Tooltip } from "@nextui-org/react"; import { useMemo } from "react"; -import { MemoIconAlertCircle, MemoIconAlertTriangle } from "./kern-icons/icons"; +import { MemoIconAlertTriangle } from "./kern-icons/icons"; type Props = { @@ -14,17 +14,17 @@ type Props = { colorInactive?: string; addClassesGroup?: string; tooltip?: string; + disabled?: boolean; } export default function SwitchWithLabel(props: Props) { - const finalColorActive = props.colorActive || 'bg-green-600'; const finalColorInactive = props.colorInactive || 'bg-gray-200'; const finalColorLabel = props.colorLabel || 'text-gray-700'; const tooltip = useMemo(() => props.tooltip ? : null, [props.tooltip]) - return + return {props.label} @@ -34,8 +34,9 @@ export default function SwitchWithLabel(props: Props) { onChange={props.onChange} className={combineClassNames( props.checked ? finalColorActive : finalColorInactive, - 'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2' + 'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer disabled:cursor-not-allowed rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2' )} + disabled={props.disabled} >