2023-01-16 10:26:19 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { ThemeColors } from '~/composables/settings'
|
|
|
|
|
|
|
|
const themes = await import('~/constants/themes.json').then(r => r.default) as [string, ThemeColors][]
|
2024-02-21 15:20:08 +00:00
|
|
|
const settings = useUserSettings()
|
2023-01-16 10:26:19 +00:00
|
|
|
|
2024-02-21 15:20:08 +00:00
|
|
|
const currentTheme = computed(() => settings.value.themeColors?.['--theme-color-name'] || themes[0][1]['--theme-color-name'])
|
2023-01-16 10:26:19 +00:00
|
|
|
|
|
|
|
function updateTheme(theme: ThemeColors) {
|
2024-02-21 15:20:08 +00:00
|
|
|
settings.value.themeColors = theme
|
2023-01-16 10:26:19 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-04-13 11:39:59 +01:00
|
|
|
<div flex="~ gap4 wrap" p2 role="group" aria-labelledby="interface-tc">
|
2023-01-16 10:26:19 +00:00
|
|
|
<button
|
|
|
|
v-for="[key, theme] in themes" :key="key"
|
|
|
|
:style="{
|
|
|
|
'background': key,
|
|
|
|
'--local-ring-color': key,
|
|
|
|
}"
|
2024-04-13 11:39:59 +01:00
|
|
|
type="button"
|
2023-12-22 12:25:34 +00:00
|
|
|
:class="currentTheme === theme['--theme-color-name'] ? 'ring-2' : 'scale-90'"
|
2024-04-13 11:39:59 +01:00
|
|
|
:aria-pressed="currentTheme === theme['--theme-color-name'] ? 'true' : 'false'"
|
2023-12-22 12:25:34 +00:00
|
|
|
:title="theme['--theme-color-name']"
|
2023-01-16 10:26:19 +00:00
|
|
|
w-8 h-8 rounded-full transition-all
|
|
|
|
ring="$local-ring-color offset-3 offset-$c-bg-base"
|
|
|
|
@click="updateTheme(theme)"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|