/* * Copyright (c) 2021 - 2024, Ludvig Lundgren and the autobrr contributors. * SPDX-License-Identifier: GPL-2.0-or-later */ import { Switch, Field, Label, Description } from "@headlessui/react"; import { classNames } from "@utils"; interface CheckboxProps { value: boolean; setValue: (newValue: boolean) => void; label?: string; description?: string; className?: string; disabled?: boolean; } export const Checkbox = ({ label, description, value, className, setValue, disabled }: CheckboxProps) => ( { e.stopPropagation(); e.nativeEvent.stopImmediatePropagation(); }} > {(label || description) ? (
{label ? ( ) : null} {description ? ( {description} ) : null}
) : null} { !disabled && setValue(newValue); }} className={classNames( disabled ? "cursor-not-allowed bg-gray-450 dark:bg-gray-700 border-gray-375 dark:border-gray-800" : ( value ? "cursor-pointer bg-blue-600 border-blue-525" : "cursor-pointer bg-gray-300 dark:bg-gray-700 border-gray-375 dark:border-gray-600" ), "border relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors" )} > {value ? ( ) : ( )}
);