import clsx from "clsx"; import "./FormToggle.css"; import HelpButton from "./HelpButton"; import { useEffect, useState } from "preact/hooks"; interface FormToggleProps { currentValue: boolean | null; onChange(newValue: boolean): void; switchOnName: string; switchOnTooltip?: string; switchOffName: string; switchOffTooltip?: string; helpPage?: string; disabled?: boolean; } export default function FormToggle({ currentValue, helpPage, switchOnName, switchOnTooltip, switchOffName, switchOffTooltip, onChange, disabled }: FormToggleProps) { const [ disableTransition, setDisableTransition ] = useState(true); useEffect(() => { const timeout = setTimeout(() => { setDisableTransition(false); }, 100); return () => clearTimeout(timeout); }, []); return (
{ currentValue ? switchOffName : switchOnName } { helpPage && }
); }