2022-12-27 23:03:50 +00:00
|
|
|
<script setup lang="ts">
|
2023-01-12 17:52:52 +00:00
|
|
|
import type { ColorMode } from '~/composables/settings'
|
2022-12-28 01:06:54 +00:00
|
|
|
|
2022-12-29 12:26:08 +00:00
|
|
|
const colorMode = useColorMode()
|
2022-12-28 01:06:54 +00:00
|
|
|
|
|
|
|
function setColorMode(mode: ColorMode) {
|
2022-12-29 12:26:08 +00:00
|
|
|
colorMode.preference = mode
|
2022-12-27 23:03:50 +00:00
|
|
|
}
|
2023-04-28 08:42:23 +01: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-27 23:03:50 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-04-13 11:39:59 +01:00
|
|
|
<div flex="~ gap4 wrap" w-full role="group" aria-labelledby="interface-cm">
|
2022-12-27 23:03:50 +00:00
|
|
|
<button
|
2023-04-28 08:42:23 +01:00
|
|
|
v-for="{ icon, label, mode } in modes"
|
|
|
|
:key="mode"
|
2024-04-13 11:39:59 +01:00
|
|
|
type="button"
|
2023-01-13 18:26:31 +00:00
|
|
|
btn-text flex-1 flex="~ gap-1 center" p4 border="~ base rounded" bg-base ws-nowrap
|
2024-04-13 11:39:59 +01:00
|
|
|
:aria-pressed="colorMode.preference === mode ? 'true' : 'false'"
|
2023-04-28 08:42:23 +01:00
|
|
|
:class="colorMode.preference === mode ? 'pointer-events-none' : 'filter-saturate-0'"
|
|
|
|
@click="setColorMode(mode)"
|
2023-01-12 18:29:10 +00:00
|
|
|
>
|
2023-04-28 08:42:23 +01:00
|
|
|
<span :class="`${icon}`" />
|
|
|
|
{{ $t(label) }}
|
2023-01-12 18:29:10 +00:00
|
|
|
</button>
|
2022-12-27 23:03:50 +00:00
|
|
|
</div>
|
|
|
|
</template>
|