Skip to content

Commit ad59e1c

Browse files
Desktop: Add window control buttons for Linux (#3081)
* Add window buttons for linux * Code and design review --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
1 parent 82784b4 commit ad59e1c

3 files changed

Lines changed: 48 additions & 11 deletions

File tree

frontend/src/components/window/title-bar/TitleBar.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
99
import LayoutRow from "@graphite/components/layout/LayoutRow.svelte";
1010
import TextButton from "@graphite/components/widgets/buttons/TextButton.svelte";
11+
import WindowButtonsLinux from "@graphite/components/window/title-bar/WindowButtonsLinux.svelte";
1112
import WindowButtonsMac from "@graphite/components/window/title-bar/WindowButtonsMac.svelte";
1213
import WindowButtonsWeb from "@graphite/components/window/title-bar/WindowButtonsWeb.svelte";
1314
import WindowButtonsWindows from "@graphite/components/window/title-bar/WindowButtonsWindows.svelte";
@@ -82,8 +83,10 @@
8283
</LayoutRow>
8384
<!-- Window buttons (except on Mac) -->
8485
<LayoutRow class="right">
85-
{#if platform === "Windows" || platform === "Linux"}
86+
{#if platform === "Windows"}
8687
<WindowButtonsWindows {maximized} />
88+
{:else if platform === "Linux"}
89+
<WindowButtonsLinux {maximized} />
8790
{:else if platform === "Web"}
8891
<WindowButtonsWeb />
8992
{/if}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<script lang="ts">
2+
import { getContext } from "svelte";
3+
4+
import type { Editor } from "@graphite/editor";
5+
6+
import LayoutRow from "@graphite/components/layout/LayoutRow.svelte";
7+
import IconLabel from "@graphite/components/widgets/labels/IconLabel.svelte";
8+
9+
export let maximized;
10+
11+
const editor = getContext<Editor>("editor");
12+
</script>
13+
14+
<LayoutRow class="window-button linux" tooltip="Minimize" on:click={() => editor.handle.appWindowMinimize()}>
15+
<IconLabel icon={"WindowButtonWinMinimize"} />
16+
</LayoutRow>
17+
<LayoutRow class="window-button linux" tooltip={maximized ? "Unmaximize" : "Maximize"} on:click={() => editor.handle.appWindowMaximize()}>
18+
<IconLabel icon={maximized ? "WindowButtonWinRestoreDown" : "WindowButtonWinMaximize"} />
19+
</LayoutRow>
20+
<LayoutRow class="window-button linux" tooltip="Close" on:click={() => editor.handle.appWindowClose()}>
21+
<IconLabel icon={"WindowButtonWinClose"} />
22+
</LayoutRow>
23+
24+
<style lang="scss" global>
25+
.window-button.linux {
26+
flex: 0 0 auto;
27+
align-items: center;
28+
padding: 0 12px;
29+
30+
svg {
31+
fill: var(--color-e-nearwhite);
32+
}
33+
34+
&:hover {
35+
background: var(--color-6-lowergray);
36+
border-radius: 2px;
37+
38+
svg {
39+
fill: var(--color-f-white);
40+
}
41+
}
42+
}
43+
</style>

frontend/src/components/window/title-bar/WindowButtonsWeb.svelte

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
<script lang="ts">
22
import { getContext } from "svelte";
33
4-
import type { Editor } from "@graphite/editor";
54
import type { FullscreenState } from "@graphite/state-providers/fullscreen";
65
76
import LayoutRow from "@graphite/components/layout/LayoutRow.svelte";
87
import IconLabel from "@graphite/components/widgets/labels/IconLabel.svelte";
98
import TextLabel from "@graphite/components/widgets/labels/TextLabel.svelte";
109
11-
const editor = getContext<Editor>("editor");
1210
const fullscreen = getContext<FullscreenState>("fullscreen");
1311
1412
$: requestFullscreenHotkeys = fullscreen.keyboardLockApiSupported && !$fullscreen.keyboardLocked;
1513
16-
async function handleClick(e: MouseEvent) {
17-
// TODO: Remove this debugging option to switch from web to desktop window buttons
18-
if (e.ctrlKey && e.shiftKey && e.altKey) {
19-
editor.handle.appWindowMinimize();
20-
editor.handle.appWindowMinimize();
21-
return;
22-
}
23-
14+
async function handleClick() {
2415
if ($fullscreen.windowFullscreen) fullscreen.exitFullscreen();
2516
else fullscreen.enterFullscreen();
2617
}

0 commit comments

Comments
 (0)