diff --git a/apps/client/src/widgets/dialogs/delete_notes.tsx b/apps/client/src/widgets/dialogs/delete_notes.tsx index 786e60f1db..99a5437329 100644 --- a/apps/client/src/widgets/dialogs/delete_notes.tsx +++ b/apps/client/src/widgets/dialogs/delete_notes.tsx @@ -3,7 +3,7 @@ import "./delete_notes.css"; import { useRef, useState, useEffect } from "preact/hooks"; import { t } from "../../services/i18n.js"; import Modal from "../react/Modal.js"; -import Toggle from "../react/Toggle.js"; +import FormToggle from "../react/FormToggle.js"; import type { DeleteNotesPreview } from "@triliumnext/commons"; import server from "../../services/server.js"; import froca from "../../services/froca.js"; @@ -147,7 +147,7 @@ export default function DeleteNotesDialog() { label={t("delete_notes.erase_notes_label")} description={t("delete_notes.erase_notes_description")} > - - diff --git a/apps/client/src/widgets/react/FormToggle.tsx b/apps/client/src/widgets/react/FormToggle.tsx index e08c1e3c2e..ac29f1fb7a 100644 --- a/apps/client/src/widgets/react/FormToggle.tsx +++ b/apps/client/src/widgets/react/FormToggle.tsx @@ -7,17 +7,22 @@ import { ComponentChildren } from "preact"; interface FormToggleProps { currentValue: boolean | null; onChange(newValue: boolean): void; - switchOnName: string; + /** Label shown when toggle is off. If omitted along with switchOffName, no label is shown. */ + switchOnName?: string; switchOnTooltip?: string; - switchOffName: string; + /** Label shown when toggle is on. If omitted along with switchOnName, no label is shown. */ + switchOffName?: string; switchOffTooltip?: string; helpPage?: string; disabled?: boolean; afterName?: ComponentChildren; + /** ID for the input element, useful for accessibility with external labels */ + id?: string; } -export default function FormToggle({ currentValue, helpPage, switchOnName, switchOnTooltip, switchOffName, switchOffTooltip, onChange, disabled, afterName }: FormToggleProps) { +export default function FormToggle({ currentValue, helpPage, switchOnName, switchOnTooltip, switchOffName, switchOffTooltip, onChange, disabled, afterName, id }: FormToggleProps) { const [ disableTransition, setDisableTransition ] = useState(true); + const hasLabel = switchOnName || switchOffName; useEffect(() => { const timeout = setTimeout(() => { @@ -28,7 +33,7 @@ export default function FormToggle({ currentValue, helpPage, switchOnName, switc return (
- { currentValue ? switchOffName : switchOnName } + {hasLabel && { currentValue ? switchOffName : switchOnName }} { afterName }