From 7779fe06967bf58550dfcac805ec166200de1087 Mon Sep 17 00:00:00 2001 From: LyAhn Date: Mon, 6 Apr 2026 14:05:45 +0100 Subject: [PATCH] feat: add custom TitleBar component with window controls --- src/components/TitleBar.tsx | 114 ++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/components/TitleBar.tsx diff --git a/src/components/TitleBar.tsx b/src/components/TitleBar.tsx new file mode 100644 index 0000000..592078d --- /dev/null +++ b/src/components/TitleBar.tsx @@ -0,0 +1,114 @@ +import { useState, useEffect } from "react"; +import { getCurrentWindow } from "@tauri-apps/api/window"; + +// SVG icons for window controls +function MinimizeIcon() { + return ( + + + + ); +} + +function MaximizeIcon() { + return ( + + + + ); +} + +function RestoreIcon() { + return ( + + + + + ); +} + +function CloseIcon() { + return ( + + + + ); +} + +export function TitleBar() { + const [isMaximized, setIsMaximized] = useState(false); + const appWindow = getCurrentWindow(); + + useEffect(() => { + // Get initial maximized state + appWindow.isMaximized().then(setIsMaximized); + + // Listen for resize events to update maximized state + const unlisten = appWindow.onResized(() => { + appWindow.isMaximized().then(setIsMaximized); + }); + + return () => { + unlisten.then((fn) => fn()); + }; + }, []); + + const handleMinimize = () => appWindow.minimize(); + const handleMaximize = () => appWindow.toggleMaximize(); + const handleClose = () => appWindow.close(); + + return ( +
+ {/* App icon + name — left side */} +
+
+ {/* Phokus logo placeholder — replace with if you have an SVG */} + + + + +
+ Phokus +
+ + {/* Spacer — draggable region fills here */} +
+ + {/* Window control buttons — right side, non-draggable */} +
+ {/* Minimize */} + + + {/* Maximize / Restore */} + + + {/* Close */} + +
+
+ ); +}