update: setup layouts and basic ui
This commit is contained in:
67
src/components/window/Nav.tsx
Normal file
67
src/components/window/Nav.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
"use client"
|
||||
import { RocketOne, Minus, Close, Square } from "@icon-park/react";
|
||||
import { relaunch, exit } from "@tauri-apps/plugin-process";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
// import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
const Nav = () => {
|
||||
const close = async () => {
|
||||
// (await window.hideOnClose) ? getCurrent().hide() : exit();
|
||||
await exit();
|
||||
};
|
||||
|
||||
const minimize = () => {
|
||||
getCurrentWindow()
|
||||
.minimize()
|
||||
.then(() => {
|
||||
console.log("minimized");
|
||||
})
|
||||
.catch((err: unknown) => {
|
||||
console.error(err);
|
||||
});
|
||||
};
|
||||
|
||||
const toggleMaximize = async () => {
|
||||
const current = getCurrentWindow()
|
||||
const maximized = await current.isMaximized()
|
||||
maximized ? current.unmaximize() : current.maximize()
|
||||
}
|
||||
|
||||
const reset = async () => {
|
||||
await relaunch();
|
||||
};
|
||||
|
||||
return (
|
||||
<nav
|
||||
className="absolute top-0 right-0 flex flex-row h-16 gap-0.5 p-4"
|
||||
data-tauri-drag-region
|
||||
>
|
||||
<button
|
||||
className="px-2 py-0 transition rounded hover:bg-zinc-200/80 active:scale-95"
|
||||
onClick={reset}
|
||||
>
|
||||
<RocketOne size={16} />
|
||||
</button>
|
||||
<button
|
||||
className="px-2 py-0 transition rounded hover:bg-zinc-200/80 active:scale-95"
|
||||
onClick={minimize}
|
||||
>
|
||||
<Minus size={16} />
|
||||
</button>
|
||||
<button
|
||||
className="px-2 py-0 transition rounded hover:bg-zinc-200/80 active:scale-95"
|
||||
onClick={toggleMaximize}
|
||||
>
|
||||
<Square size={16} />
|
||||
</button>
|
||||
<button
|
||||
className="px-2 py-0 transition rounded hover:bg-zinc-200/80 active:scale-95"
|
||||
onClick={close}
|
||||
>
|
||||
<Close size={16} />
|
||||
</button>
|
||||
</nav>
|
||||
);
|
||||
};
|
||||
|
||||
export default Nav;
|
||||
Reference in New Issue
Block a user