mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
web: basic settings page needed for testing
typescript cries about types but i don't care at this point
This commit is contained in:
parent
f2e74b681b
commit
b9e7661b6d
5 changed files with 89 additions and 11 deletions
31
web/src/components/buttons/SettingsCheckbox.svelte
Normal file
31
web/src/components/buttons/SettingsCheckbox.svelte
Normal file
|
@ -0,0 +1,31 @@
|
|||
<script
|
||||
lang="ts"
|
||||
generics="
|
||||
Context extends Exclude<keyof CobaltSettings, 'schemaVersion'>,
|
||||
Id extends keyof CobaltSettings[Context]
|
||||
"
|
||||
>
|
||||
import settings, { updateSetting } from "$lib/settings";
|
||||
import type { CobaltSettings } from "$lib/types/settings";
|
||||
|
||||
export let settingContext: Context;
|
||||
export let settingId: Id;
|
||||
|
||||
$: setting = $settings[settingContext][settingId];
|
||||
$: isChecked = !!setting;
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="setting-button-{settingContext}-{String(settingId)}"
|
||||
bind:checked={isChecked}
|
||||
on:change={() =>
|
||||
updateSetting({
|
||||
[settingContext]: {
|
||||
[settingId]: isChecked,
|
||||
},
|
||||
})}
|
||||
/>
|
||||
<slot></slot>
|
||||
</div>
|
|
@ -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 @@
|
|||
|
||||
<div id="action-container">
|
||||
<Switcher>
|
||||
<SettingsContextButton settingContext="save" settingId="downloadMode" settingKey="auto">
|
||||
<SettingsButton settingContext="save" settingId="downloadMode" settingKey="auto">
|
||||
<IconSparkles /> auto
|
||||
</SettingsContextButton>
|
||||
<SettingsContextButton settingContext="save" settingId="downloadMode" settingKey="audio">
|
||||
</SettingsButton>
|
||||
<SettingsButton settingContext="save" settingId="downloadMode" settingKey="audio">
|
||||
<IconMusic /> audio
|
||||
</SettingsContextButton>
|
||||
<SettingsContextButton settingContext="save" settingId="downloadMode" settingKey="mute">
|
||||
</SettingsButton>
|
||||
<SettingsButton settingContext="save" settingId="downloadMode" settingKey="mute">
|
||||
<IconMute /> mute
|
||||
</SettingsContextButton>
|
||||
</SettingsButton>
|
||||
</Switcher>
|
||||
<ActionButton id="paste" click={pasteClipboard}>
|
||||
<IconClipboard />
|
||||
|
|
|
@ -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"],
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,5 +1,41 @@
|
|||
<script>
|
||||
import Placeholder from "../../components/misc/Placeholder.svelte";
|
||||
<script lang="ts">
|
||||
import SettingsButton from "../../components/buttons/SettingsButton.svelte";
|
||||
import SettingsCheckbox from "../../components/buttons/SettingsCheckbox.svelte";
|
||||
import Switcher from "../../components/buttons/Switcher.svelte";
|
||||
|
||||
import { merge } from 'ts-deepmerge';
|
||||
import defaultSettings, { settingArrays } from "$lib/settings/defaults";
|
||||
|
||||
const switchers = merge(defaultSettings, settingArrays);
|
||||
</script>
|
||||
|
||||
<Placeholder pageName="settings" />
|
||||
<div>
|
||||
<div>settings (placeholder)</div>
|
||||
<br>
|
||||
{#each Object.entries(switchers) as [context, settingIdParent]}
|
||||
<div>
|
||||
<div>{context} context:</div>
|
||||
<br>
|
||||
</div>
|
||||
{#each Object.entries(settingIdParent) as [settingId, settingValue]}
|
||||
{#if settingValue instanceof Array}
|
||||
<div>{settingId}</div>
|
||||
<Switcher>
|
||||
{#each settingValue as value}
|
||||
<SettingsButton settingContext="{context}" settingId="{settingId}" settingKey="{value}">
|
||||
{value}
|
||||
</SettingsButton>
|
||||
{/each}
|
||||
</Switcher>
|
||||
<br>
|
||||
{/if}
|
||||
|
||||
{#if typeof settingValue === "boolean"}
|
||||
<SettingsCheckbox settingContext={context} settingId="{settingId}">
|
||||
{settingId}
|
||||
</SettingsCheckbox>
|
||||
<br>
|
||||
{/if}
|
||||
{/each}
|
||||
{/each}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue