From b9e7661b6d0a5a8861c6a46bffd66f57766955f2 Mon Sep 17 00:00:00 2001 From: wukko Date: Thu, 20 Jun 2024 18:05:17 +0600 Subject: [PATCH] web: basic settings page needed for testing typescript cries about types but i don't care at this point --- ...extButton.svelte => SettingsButton.svelte} | 0 .../buttons/SettingsCheckbox.svelte | 31 ++++++++++++++ web/src/components/save/Omnibox.svelte | 14 +++---- web/src/lib/settings/defaults.ts | 13 +++++- web/src/routes/settings/+page.svelte | 42 +++++++++++++++++-- 5 files changed, 89 insertions(+), 11 deletions(-) rename web/src/components/buttons/{SettingsContextButton.svelte => SettingsButton.svelte} (100%) create mode 100644 web/src/components/buttons/SettingsCheckbox.svelte diff --git a/web/src/components/buttons/SettingsContextButton.svelte b/web/src/components/buttons/SettingsButton.svelte similarity index 100% rename from web/src/components/buttons/SettingsContextButton.svelte rename to web/src/components/buttons/SettingsButton.svelte diff --git a/web/src/components/buttons/SettingsCheckbox.svelte b/web/src/components/buttons/SettingsCheckbox.svelte new file mode 100644 index 00000000..81c8c00a --- /dev/null +++ b/web/src/components/buttons/SettingsCheckbox.svelte @@ -0,0 +1,31 @@ + + +
+ + updateSetting({ + [settingContext]: { + [settingId]: isChecked, + }, + })} + /> + +
diff --git a/web/src/components/save/Omnibox.svelte b/web/src/components/save/Omnibox.svelte index 5686764d..3a4e6d58 100644 --- a/web/src/components/save/Omnibox.svelte +++ b/web/src/components/save/Omnibox.svelte @@ -12,7 +12,7 @@ import IconMute from "$lib/icons/Mute.svelte"; import IconClipboard from "$lib/icons/Clipboard.svelte"; - import SettingsContextButton from "../buttons/SettingsContextButton.svelte"; + import SettingsButton from "../buttons/SettingsButton.svelte"; let link: string = ""; let isFocused = false; @@ -68,15 +68,15 @@
- + auto - - + + audio - - + + mute - + diff --git a/web/src/lib/settings/defaults.ts b/web/src/lib/settings/defaults.ts index ddaa83be..124e8751 100644 --- a/web/src/lib/settings/defaults.ts +++ b/web/src/lib/settings/defaults.ts @@ -31,5 +31,16 @@ const defaultSettings: CobaltSettings = { trafficAnalytics: true } } - export default defaultSettings; + +export const settingArrays = { + appearance: { + theme: ["auto", "light", "dark"] + }, + save: { + audioFormat: ["best", "mp3", "ogg", "wav", "opus"], + filenameStyle: ["classic", "basic", "pretty", "nerdy"], + videoQuality: ["max", "2160", "1440", "1080", "720", "480", "360", "240", "144"], + youtubeVideoCodec: ["h264", "av1", "vp9"], + }, +} diff --git a/web/src/routes/settings/+page.svelte b/web/src/routes/settings/+page.svelte index d6a792fb..5f94bc32 100644 --- a/web/src/routes/settings/+page.svelte +++ b/web/src/routes/settings/+page.svelte @@ -1,5 +1,41 @@ - - +
+
settings (placeholder)
+
+ {#each Object.entries(switchers) as [context, settingIdParent]} +
+
{context} context:
+
+
+ {#each Object.entries(settingIdParent) as [settingId, settingValue]} + {#if settingValue instanceof Array} +
{settingId}
+ + {#each settingValue as value} + + {value} + + {/each} + +
+ {/if} + + {#if typeof settingValue === "boolean"} + + {settingId} + +
+ {/if} + {/each} + {/each} +