mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 07:38:53 +02:00
feat(react/widgets): port close zen button
This commit is contained in:
parent
b3a3196136
commit
3c9a8e38d3
@ -28,7 +28,6 @@ import UploadAttachmentsDialog from "../widgets/dialogs/upload_attachments.js";
|
|||||||
import ScrollPadding from "../widgets/scroll_padding.js";
|
import ScrollPadding from "../widgets/scroll_padding.js";
|
||||||
import options from "../services/options.js";
|
import options from "../services/options.js";
|
||||||
import utils from "../services/utils.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 { AppContext } from "../components/app_context.js";
|
||||||
import type { WidgetsByParent } from "../services/bundle.js";
|
import type { WidgetsByParent } from "../services/bundle.js";
|
||||||
import { applyModals } from "./layout_commons.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 TitleBarButtons from "../widgets/title_bar_buttons.jsx";
|
||||||
import LeftPaneToggle from "../widgets/buttons/left_pane_toggle.js";
|
import LeftPaneToggle from "../widgets/buttons/left_pane_toggle.js";
|
||||||
import ApiLog from "../widgets/api_log.jsx";
|
import ApiLog from "../widgets/api_log.jsx";
|
||||||
|
import CloseZenModeButton from "../widgets/close_zen_button.jsx";
|
||||||
|
|
||||||
export default class DesktopLayout {
|
export default class DesktopLayout {
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ export default class DesktopLayout {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.child(new CloseZenButton())
|
.child(<CloseZenModeButton />)
|
||||||
|
|
||||||
// Desktop-specific dialogs.
|
// Desktop-specific dialogs.
|
||||||
.child(<PasswordNoteSetDialog />)
|
.child(<PasswordNoteSetDialog />)
|
||||||
|
@ -16,13 +16,12 @@ import type AppContext from "../components/app_context.js";
|
|||||||
import TabRowWidget from "../widgets/tab_row.js";
|
import TabRowWidget from "../widgets/tab_row.js";
|
||||||
import MobileEditorToolbar from "../widgets/type_widgets/ckeditor/mobile_editor_toolbar.js";
|
import MobileEditorToolbar from "../widgets/type_widgets/ckeditor/mobile_editor_toolbar.js";
|
||||||
import { applyModals } from "./layout_commons.js";
|
import { applyModals } from "./layout_commons.js";
|
||||||
import CloseZenButton from "../widgets/close_zen_button.js";
|
|
||||||
import FilePropertiesTab from "../widgets/ribbon/FilePropertiesTab.jsx";
|
import FilePropertiesTab from "../widgets/ribbon/FilePropertiesTab.jsx";
|
||||||
import { useNoteContext } from "../widgets/react/hooks.jsx";
|
import { useNoteContext } from "../widgets/react/hooks.jsx";
|
||||||
import FloatingButtons from "../widgets/FloatingButtons.jsx";
|
import FloatingButtons from "../widgets/FloatingButtons.jsx";
|
||||||
import { MOBILE_FLOATING_BUTTONS } from "../widgets/FloatingButtonsDefinitions.jsx";
|
import { MOBILE_FLOATING_BUTTONS } from "../widgets/FloatingButtonsDefinitions.jsx";
|
||||||
import ToggleSidebarButton from "../widgets/mobile_widgets/toggle_sidebar_button.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 = `
|
const MOBILE_CSS = `
|
||||||
<style>
|
<style>
|
||||||
@ -169,7 +168,7 @@ export default class MobileLayout {
|
|||||||
.child(<GlobalMenuWidget isHorizontalLayout />)
|
.child(<GlobalMenuWidget isHorizontalLayout />)
|
||||||
.id("launcher-pane"))
|
.id("launcher-pane"))
|
||||||
)
|
)
|
||||||
.child(new CloseZenButton());
|
.child(<CloseZenModeButton />);
|
||||||
applyModals(rootContainer);
|
applyModals(rootContainer);
|
||||||
return rootContainer;
|
return rootContainer;
|
||||||
}
|
}
|
||||||
|
26
apps/client/src/widgets/close_zen_button.css
Normal file
26
apps/client/src/widgets/close_zen_button.css
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
:root {
|
||||||
|
--zen-button-size: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-zen-container {
|
||||||
|
width: var(--zen-button-size);
|
||||||
|
height: var(--zen-button-size);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.zen .close-zen-container {
|
||||||
|
display: block;
|
||||||
|
position: fixed;
|
||||||
|
top: 2px;
|
||||||
|
right: 2px;
|
||||||
|
z-index: 9999;
|
||||||
|
-webkit-app-region: no-drag;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.zen.mobile .close-zen-container {
|
||||||
|
top: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.zen.electron:not(.platform-darwin):not(.native-titlebar) .close-zen-container {
|
||||||
|
left: calc(env(titlebar-area-width) - var(--zen-button-size) - 2px);
|
||||||
|
right: unset;
|
||||||
|
}
|
@ -1,54 +0,0 @@
|
|||||||
import BasicWidget from "./basic_widget.js";
|
|
||||||
import { t } from "../services/i18n.js";
|
|
||||||
import utils from "../services/utils.js";
|
|
||||||
|
|
||||||
const TPL = /*html*/`\
|
|
||||||
<div class="close-zen-container">
|
|
||||||
<button class="button-widget bx icon-action bxs-yin-yang"
|
|
||||||
data-trigger-command="toggleZenMode"
|
|
||||||
title="${t("zen_mode.button_exit")}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
:root {
|
|
||||||
--zen-button-size: 32px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-zen-container {
|
|
||||||
display: none;
|
|
||||||
width: var(--zen-button-size);
|
|
||||||
height: var(--zen-button-size);
|
|
||||||
}
|
|
||||||
|
|
||||||
body.zen .close-zen-container {
|
|
||||||
display: block;
|
|
||||||
position: fixed;
|
|
||||||
top: 2px;
|
|
||||||
right: 2px;
|
|
||||||
z-index: 9999;
|
|
||||||
-webkit-app-region: no-drag;
|
|
||||||
}
|
|
||||||
|
|
||||||
body.zen.mobile .close-zen-container {
|
|
||||||
top: -2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
body.zen.electron:not(.platform-darwin):not(.native-titlebar) .close-zen-container {
|
|
||||||
left: calc(env(titlebar-area-width) - var(--zen-button-size) - 2px);
|
|
||||||
right: unset;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
export default class CloseZenButton extends BasicWidget {
|
|
||||||
|
|
||||||
doRender(): void {
|
|
||||||
this.$widget = $(TPL);
|
|
||||||
}
|
|
||||||
|
|
||||||
zenChangedEvent() {
|
|
||||||
this.toggleInt(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
25
apps/client/src/widgets/close_zen_button.tsx
Normal file
25
apps/client/src/widgets/close_zen_button.tsx
Normal file
@ -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 (
|
||||||
|
<div class={`close-zen-container ${!zenModeEnabled ? "hidden-ext" : ""}`}>
|
||||||
|
{zenModeEnabled && (
|
||||||
|
<ActionButton
|
||||||
|
icon="bx bxs-yin-yang"
|
||||||
|
triggerCommand="toggleZenMode"
|
||||||
|
text={t("zen_mode.button_exit")}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user