mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
This makes the interface overall more legible. Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
90 lines
2.0 KiB
Svelte
90 lines
2.0 KiB
Svelte
<script lang="ts">
|
|
import type { CodeFont, Theme } from "@app/lib/appearance";
|
|
|
|
import {
|
|
codeFont,
|
|
codeFonts,
|
|
storeCodeFont,
|
|
storeTheme,
|
|
theme,
|
|
} from "@app/lib/appearance";
|
|
|
|
import Icon from "@app/components/Icon.svelte";
|
|
import Radio from "@app/components/Radio.svelte";
|
|
import Button from "@app/components/Button.svelte";
|
|
|
|
$: document.documentElement.setAttribute("data-codefont", $codeFont);
|
|
$: document.documentElement.setAttribute("data-theme", $theme);
|
|
|
|
function switchFont(font: CodeFont) {
|
|
codeFont.set(font);
|
|
storeCodeFont(font);
|
|
}
|
|
|
|
function switchTheme(newTheme: Theme) {
|
|
theme.set(newTheme);
|
|
storeTheme(newTheme);
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 1.5rem;
|
|
font-size: var(--font-size-small);
|
|
}
|
|
|
|
.item {
|
|
display: flex;
|
|
width: 100%;
|
|
align-items: center;
|
|
}
|
|
|
|
.right {
|
|
display: flex;
|
|
margin-left: auto;
|
|
}
|
|
</style>
|
|
|
|
<div class="container">
|
|
<div class="item">
|
|
<div>Theme</div>
|
|
<div class="right">
|
|
<Radio>
|
|
<Button
|
|
ariaLabel="Light Mode"
|
|
styleBorderRadius="0"
|
|
variant={$theme === "light" ? "gray-white" : "dim"}
|
|
on:click={() => switchTheme("light")}>
|
|
<Icon name="sun" />
|
|
</Button>
|
|
<Button
|
|
ariaLabel="Dark Mode"
|
|
styleBorderRadius="0"
|
|
variant={$theme === "dark" ? "gray-white" : "dim"}
|
|
on:click={() => switchTheme("dark")}>
|
|
<Icon name="moon" />
|
|
</Button>
|
|
</Radio>
|
|
</div>
|
|
</div>
|
|
<div class="item">
|
|
<div>Code Font</div>
|
|
<div class="right">
|
|
<Radio>
|
|
{#each codeFonts as font}
|
|
<Button
|
|
styleBorderRadius="0"
|
|
styleFontFamily={font.fontFamily}
|
|
on:click={() => switchFont(font.storedName)}
|
|
variant={$codeFont === font.storedName ? "gray-white" : "dim"}>
|
|
{font.displayName}
|
|
</Button>
|
|
{/each}
|
|
</Radio>
|
|
</div>
|
|
</div>
|
|
</div>
|