Skip to content
Permalink
f681d64416
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
@Sticks
Latest commit 36bb82c Sep 14, 2024 History
1 contributor

Users who have contributed to this file

33 lines (30 sloc) 900 Bytes
<script
lang="ts"
generics="
Context extends Exclude<keyof CobaltSettings, 'schemaVersion'>,
Id extends keyof CobaltSettings[Context],
Value extends CobaltSettings[Context][Id]
"
>
import settings, { updateSetting } from "$lib/state/settings";
import type { CobaltSettings } from "$lib/types/settings";
export let settingContext: Context;
export let settingId: Id;
export let settingValue: Value;
$: setting = $settings[settingContext][settingId];
$: isActive = setting === settingValue;
</script>
<button
id="setting-button-{settingContext}-{String(settingId)}-{settingValue}"
class="button"
class:active={isActive}
aria-pressed={isActive}
on:click={() =>
updateSetting({
[settingContext]: {
[settingId]: settingValue,
},
})}
>
<slot></slot>
</button>