Added custom theme color support

This commit is contained in:
WardPearce
2024-03-09 17:02:34 +13:00
parent 8ebc59b0fa
commit 3e8d57f8b4
2 changed files with 21 additions and 3 deletions
+19 -2
View File
@@ -5,7 +5,7 @@
import 'material-dynamic-colors';
import { onMount } from 'svelte';
import { get } from 'svelte/store';
import { darkMode } from '../store';
import { darkMode, themeColor } from '../store';
const pages = [
{
@@ -35,6 +35,13 @@
}
];
async function setColor(color: any) {
const target = color.target;
const hex = (target as { value: string }).value;
await ui('theme', hex);
themeColor.set(hex);
}
function toggleDarkMode() {
const isDark = get(darkMode);
@@ -55,7 +62,7 @@
}
});
onMount(() => {
onMount(async () => {
const isDark = get(darkMode);
if (isDark === null) {
@@ -73,6 +80,11 @@
ui('mode', 'light');
}
}
const themeHex = get(themeColor);
if (themeHex) {
await ui('theme', themeHex);
}
});
</script>
@@ -121,6 +133,11 @@
<span>Light mode</span>
{/if}
</button>
<button>
<i>palette</i>
<span>Color</span>
<input on:change={setColor} type="color" />
</button>
</dialog>
<dialog class="right" id="dialog-notifications">
+2 -1
View File
@@ -3,4 +3,5 @@ import type { Writable } from 'svelte/store';
export const invidiousInstance = persisted('invidiousInstance', import.meta.env.VITE_DEFAULT_INVIDIOUS_INSTANCE);
export const returnYTDislikesInstance = persisted('returnYTDislikesInstance', import.meta.env.VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE);
export const darkMode: Writable<null | boolean> = persisted("darkMode", null);
export const darkMode: Writable<null | boolean> = persisted("darkMode", null);
export const themeColor: Writable<null | string> = persisted("themeColor", null);