api-client/components/smart/ColorModePicker.vue

55 lines
1.2 KiB
Vue
Raw Normal View History

2020-09-24 02:52:54 +00:00
<template>
<div class="flex">
<ButtonSecondary
v-for="(color, index) of colors"
:key="`color-${index}`"
v-tippy="{ theme: 'tooltip' }"
:title="`${color.charAt(0).toUpperCase()}${color.slice(1)}`"
:class="{
'bg-primaryLight !text-accent hover:text-accent': color === active,
}"
class="rounded"
:icon="getIcon(color)"
2021-07-13 23:49:08 +00:00
@click.native="setBGMode(color)"
/>
2020-12-11 16:54:34 +00:00
</div>
2020-09-24 02:52:54 +00:00
</template>
2021-07-06 12:20:37 +00:00
<script lang="ts">
2021-08-12 08:14:10 +00:00
import { defineComponent } from "@nuxtjs/composition-api"
2021-07-06 12:20:37 +00:00
import {
applySetting,
HoppBgColor,
HoppBgColors,
2021-08-12 08:14:10 +00:00
useSetting,
2021-07-06 12:20:37 +00:00
} from "~/newstore/settings"
2021-08-12 08:14:10 +00:00
export default defineComponent({
setup() {
2020-09-24 02:52:54 +00:00
return {
2021-07-06 12:20:37 +00:00
colors: HoppBgColors,
2021-08-12 08:14:10 +00:00
active: useSetting("BG_COLOR"),
2020-09-24 02:52:54 +00:00
}
},
methods: {
2021-07-06 12:20:37 +00:00
setBGMode(color: HoppBgColor) {
applySetting("BG_COLOR", color)
},
getIcon(color: HoppBgColor) {
2020-09-24 02:52:54 +00:00
switch (color) {
case "system":
return "desktop_windows"
case "light":
return "wb_sunny"
case "dark":
return "nights_stay"
case "black":
return "bedtime"
default:
return "desktop_windows"
}
},
},
2021-07-06 12:20:37 +00:00
})
2020-09-24 02:52:54 +00:00
</script>