Import source: src/components/TitleBar
Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality.
This commit is contained in:
@@ -0,0 +1,66 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
|
import { Minus, Square, Copy, X } from "lucide-react";
|
||||||
|
|
||||||
|
const appWindow = getCurrentWindow();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom Windows title bar (window has decorations: false).
|
||||||
|
* Height 40px; the drag region spans everything except the buttons.
|
||||||
|
*/
|
||||||
|
export default function TitleBar() {
|
||||||
|
const [maximized, setMaximized] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
appWindow.isMaximized().then(setMaximized);
|
||||||
|
const unlisten = appWindow.onResized(async () => {
|
||||||
|
setMaximized(await appWindow.isMaximized());
|
||||||
|
});
|
||||||
|
return () => {
|
||||||
|
unlisten.then((f) => f());
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-tauri-drag-region
|
||||||
|
className="flex h-10 shrink-0 items-center justify-between border-b border-divider bg-bg"
|
||||||
|
>
|
||||||
|
<div data-tauri-drag-region className="flex items-center gap-2 pl-3">
|
||||||
|
<span
|
||||||
|
data-tauri-drag-region
|
||||||
|
className="text-[13px] font-medium text-text-secondary"
|
||||||
|
>
|
||||||
|
Notara
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex h-full">
|
||||||
|
<button
|
||||||
|
aria-label="Minimize"
|
||||||
|
onClick={() => appWindow.minimize()}
|
||||||
|
className="flex h-full w-12 items-center justify-center text-text-secondary hover:bg-bg-hover"
|
||||||
|
>
|
||||||
|
<Minus size={16} strokeWidth={1.5} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
aria-label={maximized ? "Restore" : "Maximize"}
|
||||||
|
onClick={() => appWindow.toggleMaximize()}
|
||||||
|
className="flex h-full w-12 items-center justify-center text-text-secondary hover:bg-bg-hover"
|
||||||
|
>
|
||||||
|
{maximized ? (
|
||||||
|
<Copy size={14} strokeWidth={1.5} className="-scale-x-100" />
|
||||||
|
) : (
|
||||||
|
<Square size={13} strokeWidth={1.5} />
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
aria-label="Close"
|
||||||
|
onClick={() => appWindow.close()}
|
||||||
|
className="flex h-full w-12 items-center justify-center text-text-secondary hover:bg-[#e81123] hover:text-white"
|
||||||
|
>
|
||||||
|
<X size={16} strokeWidth={1.5} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user