Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: PWA support #4

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<meta name="description" content="A web installer for Vencord" />
<meta name="author" content="Vencord Contributors" />
<meta name="theme-color" content="#dd7878" />
<meta name="theme-color" content="#1e2021" />

<meta name="og:type" content="website" />
<meta name="og:title" content="Vencord Installer" />
Expand All @@ -19,6 +19,8 @@
<meta name="og:image" content="https://beta.install.vencord.dev/icon.png" />

<meta name="darkreader-lock" />

<link rel="manifest" href="/app.webmanifest" />
</head>

<body>
Expand Down
46 changes: 42 additions & 4 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-->

<script lang="ts">
import VencordIcon from "./components/icons/VencordIcon.svelte";
import { windowStore } from "./windows";
import Launcher from "./windows/Launcher.svelte";
import { launchers } from "./windows/launchers";
Expand All @@ -16,10 +17,18 @@
(launchers[autolaunch] ?? launchers[0]).onClick();
</script>

<div class="launchers">
{#each launchers as launcher}
<Launcher {launcher} />
{/each}
<div>
<div class="pwa-titlebar">
<div class="icon">
<VencordIcon />
</div>
<div class="title body sm">Vencord Desktop Environment</div>
</div>
<div class="launchers">
{#each launchers as launcher}
<Launcher {launcher} />
{/each}
</div>
</div>

{#each windows as window (window.props.id)}
Expand All @@ -32,4 +41,33 @@
.launchers {
padding: 1em;
}

.pwa-titlebar {
display: none;
}

@media (display-mode: window-controls-overlay) {
.pwa-titlebar {
display: flex;
align-items: center;
background: #1e2021;
cursor: default;

width: env(titlebar-area-width, 100vw);
height: env(titlebar-area-height);
left: env(titlebar-area-x, 0);
top: env(titlebar-area-y, 0);

-webkit-app-region: drag;
}

.icon {
display: flex;
align-items: center;
justify-content: center;
width: 1.25rem;
height: 1.25rem;
margin: 0 1rem;
}
}
</style>
44 changes: 39 additions & 5 deletions src/windows/Window.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<button on:click={close} title="Close" class="close"><XIcon size="1.5x" /></button>
{/if}
</div>
<div class="pwa-draggable"></div>
</div>
<div class="content">
<slot />
Expand All @@ -155,7 +156,7 @@
position: absolute;
resize: both;
overflow: hidden;
outline: 1px solid var(--bg-3);
outline: 1px solid #3c3836;
}
.frame:not(.maximized) {
border-radius: 0.5rem;
Expand All @@ -177,11 +178,13 @@
.titlebar {
display: flex;
align-items: center;
background: var(--bg-0);
background: #1e2021;
color: #d4be98;
cursor: default;
height: 2rem;
user-select: none;
}

.icon {
display: flex;
align-items: center;
Expand All @@ -190,6 +193,7 @@
height: 1.25rem;
margin: 0 1rem;
}

.spacer {
flex: 1;
}
Expand All @@ -209,11 +213,11 @@
width: 2.5rem;
}
.buttons button:hover {
background-color: var(--bg-3);
background-color: #3c3836;
}
.buttons button.close:hover {
background-color: var(--bg-accent-red);
color: var(--bg-0);
background-color: #ea6962;
color: #1e2021;
}
.titlebar:hover .buttons {
opacity: 1;
Expand All @@ -222,4 +226,34 @@
.content {
flex: 1;
}

.pwa-draggable {
display: none;
}

/* only bother applying these if we're in PWA mode */
@media (display-mode: window-controls-overlay) {
.frame.maximized .titlebar,
.frame.maximized .pwa-draggable {
height: env(titlebar-area-height, 2rem);
left: env(titlebar-area-x, 0);
top: env(titlebar-area-y, 0);
}

.frame.maximized .titlebar {
width: env(titlebar-area-width, 100vw);
}

.frame.maximized .pwa-draggable {
display: block;
position: absolute;
/* 2.5rem is the width of the buttons, and there's 2, so subtract 2 buttons' worth */
width: calc(env(titlebar-area-width, 100vw) - (2.5rem * 2));
-webkit-app-region: drag;
}

.buttons {
-webkit-app-region: no-drag;
}
}
</style>
Loading