mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-11 12:32:55 +00:00
feat: user themes
[deploy]
This commit is contained in:
@@ -52,6 +52,10 @@ const config: IconsConfig = {
|
|||||||
"check_circle",
|
"check_circle",
|
||||||
"error",
|
"error",
|
||||||
"auto_delete",
|
"auto_delete",
|
||||||
|
"format_paint",
|
||||||
|
"dark_mode",
|
||||||
|
"light_mode",
|
||||||
|
"palette",
|
||||||
],
|
],
|
||||||
codePoints: {
|
codePoints: {
|
||||||
speed: "e9e4",
|
speed: "e9e4",
|
||||||
@@ -62,6 +66,7 @@ const config: IconsConfig = {
|
|||||||
counter_2: "f783",
|
counter_2: "f783",
|
||||||
counter_3: "f782",
|
counter_3: "f782",
|
||||||
ios_share: "e6b8",
|
ios_share: "e6b8",
|
||||||
|
light_mode: "e518",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ export interface UserPreferences {
|
|||||||
autoConnect: boolean
|
autoConnect: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const theme = writable({
|
||||||
|
color: "#6D81C7",
|
||||||
|
mode: "dark" as "light" | "dark" | "auto",
|
||||||
|
})
|
||||||
|
|
||||||
export const userPreferences = writable<UserPreferences>({
|
export const userPreferences = writable<UserPreferences>({
|
||||||
backup: false,
|
backup: false,
|
||||||
autoConnect: true,
|
autoConnect: true,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
import "tippy.js/animations/shift-away.css"
|
import "tippy.js/animations/shift-away.css"
|
||||||
import "tippy.js/dist/tippy.css"
|
import "tippy.js/dist/tippy.css"
|
||||||
import tippy from "tippy.js"
|
import tippy from "tippy.js"
|
||||||
import {userPreferences} from "$lib/preferences.js"
|
import {theme, userPreferences} from "$lib/preferences.js"
|
||||||
|
|
||||||
if (browser) {
|
if (browser) {
|
||||||
tippy.setDefaultProps({
|
tippy.setDefaultProps({
|
||||||
@@ -33,11 +33,11 @@
|
|||||||
export let data: LayoutServerData
|
export let data: LayoutServerData
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const theme = themeFromSourceColor(argbFromHex("#6D81C7"), [
|
theme.subscribe(it => {
|
||||||
{name: "success", value: argbFromHex("#00ff00"), blend: true},
|
const theme = themeFromSourceColor(argbFromHex(it.color))
|
||||||
])
|
const dark = it.mode === "dark" // window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||||
const dark = true // window.matchMedia("(prefers-color-scheme: dark)").matches
|
|
||||||
applyTheme(theme, {target: document.body, dark})
|
applyTheme(theme, {target: document.body, dark})
|
||||||
|
})
|
||||||
initLocalStorage()
|
initLocalStorage()
|
||||||
|
|
||||||
if (pwaInfo) {
|
if (pwaInfo) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
import {canAutoConnect} from "$lib/serial/device"
|
import {canAutoConnect} from "$lib/serial/device"
|
||||||
import {browser} from "$app/environment"
|
import {browser} from "$app/environment"
|
||||||
import {userPreferences} from "$lib/preferences"
|
import {userPreferences} from "$lib/preferences"
|
||||||
|
import Theme from "./Theme.svelte"
|
||||||
|
|
||||||
const training = [
|
const training = [
|
||||||
{slug: "cpm", title: "CPM - Characters Per Minute", icon: "music_note"},
|
{slug: "cpm", title: "CPM - Characters Per Minute", icon: "music_note"},
|
||||||
@@ -70,6 +71,7 @@
|
|||||||
>
|
>
|
||||||
cable
|
cable
|
||||||
</button>
|
</button>
|
||||||
|
<button title="Theme" use:popup={Theme} class="icon">format_paint</button>
|
||||||
<a href="/stats/" title="Statistics" class="icon account">person</a>
|
<a href="/stats/" title="Statistics" class="icon account">person</a>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
57
src/routes/Theme.svelte
Normal file
57
src/routes/Theme.svelte
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<script>
|
||||||
|
import {theme} from "$lib/preferences"
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<input type="color" bind:value={$theme.color} />
|
||||||
|
<button
|
||||||
|
class="icon"
|
||||||
|
on:click={() => {
|
||||||
|
$theme.mode = $theme.mode === "light" ? "dark" : "light"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{#if $theme.mode === "light"}
|
||||||
|
light_mode
|
||||||
|
{:else if $theme.mode === "dark"}
|
||||||
|
dark_mode
|
||||||
|
{:else}
|
||||||
|
TODO
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
section {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button,
|
||||||
|
input[type="color"] {
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
inline-size: 24px;
|
||||||
|
block-size: 24px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
|
color: inherit;
|
||||||
|
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-radius: 50%;
|
||||||
|
|
||||||
|
&::-webkit-color-swatch-wrapper {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-color-swatch {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user