api-client/components/smart/ColorModePicker.vue

58 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 === activeColor,
}"
: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">
import Vue from "vue"
import {
applySetting,
getSettingSubject,
HoppBgColor,
HoppBgColors,
} from "~/newstore/settings"
export default Vue.extend({
2020-09-24 02:52:54 +00:00
data() {
return {
2021-07-06 12:20:37 +00:00
colors: HoppBgColors,
}
},
subscriptions() {
return {
activeColor: getSettingSubject("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>