forked from Mirrors/elk
refactor: button creation with v-for to remove redundancy (#2020)
This commit is contained in:
parent
5c3b8be055
commit
5dc136372b
1 changed files with 25 additions and 23 deletions
|
@ -6,36 +6,38 @@ const colorMode = useColorMode()
|
||||||
function setColorMode(mode: ColorMode) {
|
function setColorMode(mode: ColorMode) {
|
||||||
colorMode.preference = mode
|
colorMode.preference = mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div flex="~ gap4 wrap" w-full>
|
<div flex="~ gap4 wrap" w-full>
|
||||||
<button
|
<button
|
||||||
|
v-for="{ icon, label, mode } in modes"
|
||||||
|
:key="mode"
|
||||||
btn-text flex-1 flex="~ gap-1 center" p4 border="~ base rounded" bg-base ws-nowrap
|
btn-text flex-1 flex="~ gap-1 center" p4 border="~ base rounded" bg-base ws-nowrap
|
||||||
:tabindex="colorMode.preference === 'dark' ? 0 : -1"
|
:tabindex="colorMode.preference === mode ? 0 : -1"
|
||||||
:class="colorMode.preference === 'dark' ? 'pointer-events-none' : 'filter-saturate-0'"
|
:class="colorMode.preference === mode ? 'pointer-events-none' : 'filter-saturate-0'"
|
||||||
@click="setColorMode('dark')"
|
@click="setColorMode(mode)"
|
||||||
>
|
>
|
||||||
<div i-ri:moon-line />
|
<span :class="`${icon}`" />
|
||||||
{{ $t('settings.interface.dark_mode') }}
|
{{ $t(label) }}
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
btn-text flex-1 flex="~ gap-1 center" p4 border="~ base rounded" bg-base ws-nowrap
|
|
||||||
:tabindex="colorMode.preference === 'light' ? 0 : -1"
|
|
||||||
:class="colorMode.preference === 'light' ? 'pointer-events-none' : 'filter-saturate-0'"
|
|
||||||
@click="setColorMode('light')"
|
|
||||||
>
|
|
||||||
<div i-ri:sun-line />
|
|
||||||
{{ $t('settings.interface.light_mode') }}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
btn-text flex-1 flex="~ gap-1 center" p4 border="~ base rounded" bg-base ws-nowrap
|
|
||||||
:tabindex="colorMode.preference === 'system' ? 0 : -1"
|
|
||||||
:class="colorMode.preference === 'system' ? 'pointer-events-none' : 'filter-saturate-0'"
|
|
||||||
@click="setColorMode('system')"
|
|
||||||
>
|
|
||||||
<div i-ri:computer-line />
|
|
||||||
{{ $t('settings.interface.system_mode') }}
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in a new issue