Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
fix: make background opaque on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
doinkythederp committed Dec 21, 2023
1 parent a89b914 commit 0b56ab2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" context="module">
import { isWindows10 } from "./detectWindows10.js";
const windows10 = isWindows10();
import { requiresOpaqueBackground } from "./detectTransparencySupport.js";
const opaque = requiresOpaqueBackground();
</script>

<script lang="ts">
Expand Down Expand Up @@ -46,14 +46,14 @@
}
onMount(() => {
windows10.then((isWindows10) => {
if (isWindows10) {
document.body.classList.add("windows10");
opaque.then((opaque) => {
if (opaque) {
document.body.classList.add("opaque");
}
});
return () => {
document.body.classList.remove("windows10");
document.body.classList.remove("opaque");
};
});
</script>
Expand Down
16 changes: 16 additions & 0 deletions src/detectWindows10.js → src/detectTransparencySupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,19 @@ export async function isWindows10() {
return false;
}
}

export function isLinux() {
return navigator.platform.includes("Linux");
}

export async function requiresOpaqueBackground() {
if (isLinux()) {
return true;
}

if (await isWindows10()) {
return true;
}

return false;
}
2 changes: 1 addition & 1 deletion src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ progress:indeterminate::-webkit-progress-value {
color-scheme: dark;
}

.windows10 {
.opaque {
@apply bg-neutral-300 dark:bg-stone-900;
}

0 comments on commit 0b56ab2

Please sign in to comment.