From e166b97b8f7ccba57eb55495f849fb9dd1aec500 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 29 Aug 2025 01:07:11 +0300 Subject: [PATCH] feat(react/widgets): port a few more global menu items --- apps/client/src/layouts/mobile_layout.tsx | 7 +++- .../src/widgets/buttons/global_menu.tsx | 40 +++++++++++++++++-- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/apps/client/src/layouts/mobile_layout.tsx b/apps/client/src/layouts/mobile_layout.tsx index 18c3d4a2e..e80c605fe 100644 --- a/apps/client/src/layouts/mobile_layout.tsx +++ b/apps/client/src/layouts/mobile_layout.tsx @@ -162,7 +162,12 @@ export default class MobileLayout { .contentSized() .id("mobile-bottom-bar") .child(new TabRowWidget().css("height", "40px")) - .child(new FlexContainer("row").class("horizontal").css("height", "53px").child(new LauncherContainer(true)).child(new GlobalMenuWidget(true)).id("launcher-pane")) + .child(new FlexContainer("row") + .class("horizontal") + .css("height", "53px") + .child(new LauncherContainer(true)) + .child() + .id("launcher-pane")) ) .child(new CloseZenButton()); applyModals(rootContainer); diff --git a/apps/client/src/widgets/buttons/global_menu.tsx b/apps/client/src/widgets/buttons/global_menu.tsx index 344572c1c..5d07aec66 100644 --- a/apps/client/src/widgets/buttons/global_menu.tsx +++ b/apps/client/src/widgets/buttons/global_menu.tsx @@ -10,7 +10,7 @@ import { KeyboardActionNames } from "@triliumnext/commons"; import { ComponentChildren } from "preact"; import Component from "../../components/component"; import { ParentComponent } from "../react/react_utils"; -import { dynamicRequire, isElectron } from "../../services/utils"; +import { dynamicRequire, isElectron, isMobile } from "../../services/utils"; interface MenuItemProps { icon: string, @@ -18,6 +18,8 @@ interface MenuItemProps { title?: string, command: T, disabled?: boolean + active?: boolean; + outsideChildren?: ComponentChildren; } export default function GlobalMenu({ isHorizontalLayout }: { isHorizontalLayout: boolean }) { @@ -34,21 +36,32 @@ export default function GlobalMenu({ isHorizontalLayout }: { isHorizontalLayout: - + + + + + {isMobile() ? ( + + ) : ( + + )} + ) } -function MenuItem({ icon, text, title, command, disabled }: MenuItemProps void)>) { +function MenuItem({ icon, text, title, command, disabled, active, outsideChildren }: MenuItemProps void)>) { return {text} } @@ -56,7 +69,8 @@ function KeyboardAction({ text, command, ...props }: MenuItemProps{text} } + text={text} + outsideChildren={} /> } @@ -131,3 +145,21 @@ function ZoomControls({ parentComponent }: { parentComponent?: Component | null ); } + +function ToggleWindowOnTop() { + const focusedWindow = isElectron() ? dynamicRequire("@electron/remote").BrowserWindow.getFocusedWindow() : null; + const [ isAlwaysOnTop, setIsAlwaysOnTop ] = useState(focusedWindow?.isAlwaysOnTop()); + + return (isElectron() && + { + const newState = !isAlwaysOnTop; + focusedWindow?.setAlwaysOnTop(newState); + setIsAlwaysOnTop(newState); + }} + /> + ) +} \ No newline at end of file