From 042d2e9cc8c2bfb5fbb3308afee543b97043b977 Mon Sep 17 00:00:00 2001 From: wukko Date: Mon, 24 Jun 2024 23:05:51 +0600 Subject: [PATCH] web: settings ui & const for settings type options --- .../buttons/SettingsCheckbox.svelte | 31 ++++++++- web/src/components/buttons/Switcher.svelte | 11 ++- .../settings/SettingsCategory.svelte | 60 ++++------------ .../components/settings/SettingsTab.svelte | 55 +++++++++++++++ web/src/lib/types/settings.ts | 21 ++++-- web/src/routes/+layout.svelte | 18 ++++- web/src/routes/settings/+layout.svelte | 69 ++++++++++--------- .../general/accessibility/+page.svelte | 1 - .../settings/general/appearance/+page.svelte | 34 ++++++++- .../routes/settings/save/audio/+page.svelte | 43 +++++++++++- .../settings/save/metadata/+page.svelte | 41 ++++++++++- .../routes/settings/save/video/+page.svelte | 59 +++++++++++++++- 12 files changed, 346 insertions(+), 97 deletions(-) create mode 100644 web/src/components/settings/SettingsTab.svelte delete mode 100644 web/src/routes/settings/general/accessibility/+page.svelte diff --git a/web/src/components/buttons/SettingsCheckbox.svelte b/web/src/components/buttons/SettingsCheckbox.svelte index 81c8c00a..eee4f9e9 100644 --- a/web/src/components/buttons/SettingsCheckbox.svelte +++ b/web/src/components/buttons/SettingsCheckbox.svelte @@ -11,11 +11,14 @@ export let settingContext: Context; export let settingId: Id; + export let title: string; + export let description: string = ""; + $: setting = $settings[settingContext][settingId]; $: isChecked = !!setting; -
+
- +
+

{title}

+ + {#if description.length > 0} +
{description}
+ {/if} +
+ + \ No newline at end of file diff --git a/web/src/components/buttons/Switcher.svelte b/web/src/components/buttons/Switcher.svelte index afcfeba3..0a6749c3 100644 --- a/web/src/components/buttons/Switcher.svelte +++ b/web/src/components/buttons/Switcher.svelte @@ -1,4 +1,8 @@ -
+ + +
@@ -23,6 +27,11 @@ border-bottom-left-radius: 0; } + .switcher.big :global(.button) { + width: 100%; + height: 40px; + } + .switcher > :global(:not(.button:first-child):not(.button:last-child)) { border-radius: 0; } diff --git a/web/src/components/settings/SettingsCategory.svelte b/web/src/components/settings/SettingsCategory.svelte index 3ce80a54..9707f920 100644 --- a/web/src/components/settings/SettingsCategory.svelte +++ b/web/src/components/settings/SettingsCategory.svelte @@ -1,55 +1,21 @@ - -
- -
- {categoryName} -
+
+

{title}

+ + + {#if description.length > 0} +
{description}
+ {/if} +
diff --git a/web/src/components/settings/SettingsTab.svelte b/web/src/components/settings/SettingsTab.svelte new file mode 100644 index 00000000..3ce80a54 --- /dev/null +++ b/web/src/components/settings/SettingsTab.svelte @@ -0,0 +1,55 @@ + + + +
+ +
+ {categoryName} +
+ + diff --git a/web/src/lib/types/settings.ts b/web/src/lib/types/settings.ts index c17e65a1..bb3f8da3 100644 --- a/web/src/lib/types/settings.ts +++ b/web/src/lib/types/settings.ts @@ -1,10 +1,17 @@ -type CobaltSettingsAccessibility = { +export type CobaltSettingsAccessibility = { reduceAnimations: boolean, reduceTransparency: boolean, }; +export const themeOptions = ["auto", "light", "dark"] as const; +export const audioFormatOptions = ["best", "mp3", "ogg", "wav", "opus"] as const; +export const downloadModeOptions = ["auto", "audio", "mute"] as const; +export const filenameStyleOptions = ["classic", "basic", "pretty", "nerdy"] as const; +export const videoQualityOptions = ["max", "2160", "1440", "1080", "720", "480", "360", "240", "144"] as const; +export const youtubeVideoCodecOptions = ["h264", "av1", "vp9"] as const; + type CobaltSettingsAppearance = { - theme: "auto" | "light" | "dark", + theme: typeof themeOptions[number], }; type CobaltSettingsGeneral = { @@ -14,16 +21,16 @@ type CobaltSettingsGeneral = { }; type CobaltSettingsSave = { - audioFormat: "best" | "mp3" | "ogg" | "wav" | "opus", + audioFormat: typeof audioFormatOptions[number], disableMetadata: boolean, - downloadMode: "auto" | "audio" | "mute", + downloadMode: typeof downloadModeOptions[number], downloadPopup: boolean, - filenameStyle: "classic" | "basic" | "pretty" | "nerdy", + filenameStyle: typeof filenameStyleOptions[number], tiktokH265: boolean, tiktokFullAudio: boolean, twitterGif: boolean, - videoQuality: "max" | "2160" | "1440" | "1080" | "720" | "480" | "360" | "240" | "144", - youtubeVideoCodec: "h264" | "av1" | "vp9", + videoQuality: typeof videoQualityOptions[number], + youtubeVideoCodec: typeof youtubeVideoCodecOptions[number], youtubeDubBrowserLang: boolean, }; diff --git a/web/src/routes/+layout.svelte b/web/src/routes/+layout.svelte index 58fed3e6..931c283f 100644 --- a/web/src/routes/+layout.svelte +++ b/web/src/routes/+layout.svelte @@ -16,6 +16,7 @@ --primary: #ffffff; --secondary: #000000; + --white: #ffffff; --gray: #8d8d95; --blue: #2f8af9; --green: #51cf5e; @@ -55,11 +56,14 @@ :global(:root) { --primary: #000000; --secondary: #e1e1e1; + --gray: #6e6e6e; + --blue: #2a7ce1; + --green: #37aa42; --button: #191919; --button-hover: #2a2a2a; - --button-hover-transparent: rgba(225, 225, 225, 0.04); + --button-hover-transparent: rgba(225, 225, 225, 0.1); --button-stroke: rgba(255, 255, 255, 0.08); --button-text: #e1e1e1; @@ -154,7 +158,7 @@ justify-content: center; } - :global(button, .subtext) { + :global(button) { font-weight: 500; } @@ -177,10 +181,18 @@ font-size: 16px; } - :global(h4, h5, h6) { + :global(h4) { + font-size: 14.5px; + } + + :global(h5) { font-size: 12px; } + :global(h6) { + font-size: 11px; + } + :global(.subtext) { font-size: 13px; color: var(--gray); diff --git a/web/src/routes/settings/+layout.svelte b/web/src/routes/settings/+layout.svelte index 7b0b4ee8..1d949672 100644 --- a/web/src/routes/settings/+layout.svelte +++ b/web/src/routes/settings/+layout.svelte @@ -1,9 +1,8 @@
-

settings

+

settings

-
+