import clsx, { type ClassValue } from "clsx"; import { useTranslation } from "react-i18next"; import ContentSurface from "@components/surface/ContentSurface"; import LightSurface from "@components/surface/LightSurface"; import { motion, type HTMLMotionProps } from "motion/react"; import classes from "./SwitchInput.module.css"; import tg from "@/tg"; type Props = Omit, "className" | "onChange"> & { value?: boolean | null; onChange?: (value: boolean) => void; className?: ClassValue; }; export default function SwitchInput({ value, onChange, className, ...props }: Props) { const { t } = useTranslation(); const selectedIndex = value != null ? (value ? 0 : 1) : -1; return ( { tg.hapticFeedback.click(); onChange?.(!value); }} >
{t("common.on")} {t("common.off")}
{selectedIndex >= 0 && ( )}
); }