-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e804295
commit 73810de
Showing
8 changed files
with
154 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { appWindow } from "@tauri-apps/api/window"; | ||
import { type } from "@tauri-apps/api/os"; | ||
|
||
export const initWindowTitlebar = async () => { | ||
const closeButton = ` | ||
<div class="titlebar-button" id="titlebar-close"> | ||
<img src="https://api.iconify.design/mdi:close.svg" alt="close" /> | ||
</div> | ||
`; | ||
const maximizeButton = ` | ||
<div class="titlebar-button" id="titlebar-maximize"> | ||
<img | ||
src="https://api.iconify.design/mdi:window-maximize.svg" | ||
alt="maximize" | ||
/> | ||
</div> | ||
` | ||
const minimizeButton = ` | ||
<div class="titlebar-button" id="titlebar-minimize"> | ||
<img | ||
src="https://api.iconify.design/mdi:window-minimize.svg" | ||
alt="minimize" | ||
/> | ||
</div> | ||
` | ||
|
||
const osType = await type(); | ||
const titlebarElement = document.getElementById("titlebar"); | ||
|
||
if (!titlebarElement) { | ||
throw new Error("No titlebar element present in DOM"); | ||
} | ||
|
||
if (osType === "Darwin") | ||
titlebarElement.classList.add("titlebar-macos"); | ||
|
||
titlebarElement.innerHTML = osType === "Darwin" ? (closeButton + minimizeButton + maximizeButton) : (minimizeButton + maximizeButton + closeButton); | ||
} | ||
|
||
export const initWindowButtons = () => { | ||
document.getElementById('titlebar-minimize')?.addEventListener('click', () => appWindow.minimize()) | ||
document.getElementById('titlebar-maximize')?.addEventListener('click', () => appWindow.toggleMaximize()) | ||
document.getElementById('titlebar-close')?.addEventListener('click', () => appWindow.close()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters