2022-12-28 02:03:50 +03:00
|
|
|
<script setup lang="ts">
|
2023-01-12 20:52:52 +03:00
|
|
|
import type { ColorMode } from '~/composables/settings'
|
2022-12-28 04:06:54 +03:00
|
|
|
|
2022-12-29 15:26:08 +03:00
|
|
|
const colorMode = useColorMode()
|
2022-12-28 04:06:54 +03:00
|
|
|
|
|
|
|
function setColorMode(mode: ColorMode) {
|
2022-12-29 15:26:08 +03:00
|
|
|
colorMode.preference = mode
|
2022-12-28 02:03:50 +03:00
|
|
|
}
|
2023-04-28 10:42:23 +03:00
|
|
|
|
|
|
|
const modes = [
|
|
|
|
{
|
|
|
|
icon: 'i-ri-moon-line',
|
|
|
|
label: 'settings.interface.dark_mode',
|
|
|
|
mode: 'dark',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: 'i-ri-sun-line',
|
|
|
|
label: 'settings.interface.light_mode',
|
|
|
|
mode: 'light',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: 'i-ri-computer-line',
|
|
|
|
label: 'settings.interface.system_mode',
|
|
|
|
mode: 'system',
|
|
|
|
},
|
|
|
|
] as const
|
2022-12-28 02:03:50 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-04-14 21:06:25 +03:00
|
|
|
<section space-y-2>
|
|
|
|
<h2 id="interface-cm" font-medium>
|
|
|
|
{{ $t('settings.interface.color_mode') }}
|
|
|
|
</h2>
|
|
|
|
<div flex="~ gap4 wrap" w-full role="group" aria-labelledby="interface-cm">
|
|
|
|
<button
|
|
|
|
v-for="{ icon, label, mode } in modes"
|
|
|
|
:key="mode"
|
|
|
|
type="button"
|
|
|
|
btn-text flex-1 flex="~ gap-1 center" p4 border="~ base rounded" bg-base ws-nowrap
|
|
|
|
:aria-pressed="colorMode.preference === mode ? 'true' : 'false'"
|
|
|
|
:class="colorMode.preference === mode ? 'pointer-events-none' : 'filter-saturate-0'"
|
|
|
|
@click="setColorMode(mode)"
|
|
|
|
>
|
|
|
|
<span :class="`${icon}`" />
|
|
|
|
{{ $t(label) }}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</section>
|
2022-12-28 02:03:50 +03:00
|
|
|
</template>
|