diff --git a/apps/client/src/layouts/desktop_layout.tsx b/apps/client/src/layouts/desktop_layout.tsx
index 8c2df7dda..ab189f90d 100644
--- a/apps/client/src/layouts/desktop_layout.tsx
+++ b/apps/client/src/layouts/desktop_layout.tsx
@@ -28,7 +28,6 @@ import UploadAttachmentsDialog from "../widgets/dialogs/upload_attachments.js";
import ScrollPadding from "../widgets/scroll_padding.js";
import options from "../services/options.js";
import utils from "../services/utils.js";
-import CloseZenButton from "../widgets/close_zen_button.js";
import type { AppContext } from "../components/app_context.js";
import type { WidgetsByParent } from "../services/bundle.js";
import { applyModals } from "./layout_commons.js";
@@ -42,6 +41,7 @@ import SqlTableSchemas from "../widgets/sql_table_schemas.js";
import TitleBarButtons from "../widgets/title_bar_buttons.jsx";
import LeftPaneToggle from "../widgets/buttons/left_pane_toggle.js";
import ApiLog from "../widgets/api_log.jsx";
+import CloseZenModeButton from "../widgets/close_zen_button.jsx";
export default class DesktopLayout {
@@ -162,7 +162,7 @@ export default class DesktopLayout {
)
)
)
- .child(new CloseZenButton())
+ .child()
// Desktop-specific dialogs.
.child()
diff --git a/apps/client/src/layouts/mobile_layout.tsx b/apps/client/src/layouts/mobile_layout.tsx
index e75a7b6ba..2a1322276 100644
--- a/apps/client/src/layouts/mobile_layout.tsx
+++ b/apps/client/src/layouts/mobile_layout.tsx
@@ -16,13 +16,12 @@ import type AppContext from "../components/app_context.js";
import TabRowWidget from "../widgets/tab_row.js";
import MobileEditorToolbar from "../widgets/type_widgets/ckeditor/mobile_editor_toolbar.js";
import { applyModals } from "./layout_commons.js";
-import CloseZenButton from "../widgets/close_zen_button.js";
import FilePropertiesTab from "../widgets/ribbon/FilePropertiesTab.jsx";
import { useNoteContext } from "../widgets/react/hooks.jsx";
import FloatingButtons from "../widgets/FloatingButtons.jsx";
import { MOBILE_FLOATING_BUTTONS } from "../widgets/FloatingButtonsDefinitions.jsx";
import ToggleSidebarButton from "../widgets/mobile_widgets/toggle_sidebar_button.jsx";
-import MobileDetailMenu from "../widgets/mobile_widgets/mobile_detail_menu.js";
+import CloseZenModeButton from "../widgets/close_zen_button.js";
const MOBILE_CSS = `
-
-`;
-
-export default class CloseZenButton extends BasicWidget {
-
- doRender(): void {
- this.$widget = $(TPL);
- }
-
- zenChangedEvent() {
- this.toggleInt(true);
- }
-
-}
diff --git a/apps/client/src/widgets/close_zen_button.tsx b/apps/client/src/widgets/close_zen_button.tsx
new file mode 100644
index 000000000..21b364da4
--- /dev/null
+++ b/apps/client/src/widgets/close_zen_button.tsx
@@ -0,0 +1,25 @@
+import { useState } from "preact/hooks";
+import { t } from "../services/i18n";
+import ActionButton from "./react/ActionButton";
+import { useTriliumEvent } from "./react/hooks";
+import "./close_zen_button.css";
+
+export default function CloseZenModeButton() {
+ const [ zenModeEnabled, setZenModeEnabled ] = useState(false);
+
+ useTriliumEvent("zenModeChanged", ({ isEnabled }) => {
+ setZenModeEnabled(isEnabled);
+ });
+
+ return (
+
+ {zenModeEnabled && (
+
+ )}
+
+ )
+}