api-client/components/smart/ColorModePicker.vue

85 lines
1.9 KiB
Vue
Raw Normal View History

2020-09-24 02:52:54 +00:00
<template>
2020-12-12 13:46:37 +00:00
<div class="flex flex-col">
2020-09-24 02:52:54 +00:00
<label>
<ColorScheme placeholder="..." tag="span">
{{ $t("background") }}:
2021-07-06 12:20:37 +00:00
{{ activeColor.charAt(0).toUpperCase() + activeColor.slice(1) }}
<span v-if="activeColor === 'system'">
2020-09-24 02:52:54 +00:00
({{ $colorMode.value }} mode detected)
</span>
</ColorScheme>
</label>
2020-12-12 13:46:37 +00:00
<div>
2020-09-24 02:52:54 +00:00
<span
v-for="(color, index) of colors"
:key="`color-${index}`"
v-tooltip="`${color.charAt(0).toUpperCase()}${color.slice(1)}`"
2021-05-15 12:43:31 +00:00
class="
inline-flex
items-center
justify-center
p-3
m-2
transition
duration-150
ease-in-out
bg-transparent
rounded-full
cursor-pointer
2021-06-12 16:46:17 +00:00
text-secondaryLight
hover:text-secondary
2021-05-15 12:43:31 +00:00
"
2020-09-24 02:52:54 +00:00
:class="[
2021-07-06 12:20:37 +00:00
{ 'bg-primary': color === activeColor },
{ 'text-accent hover:text-accent': color === activeColor },
2020-09-24 02:52:54 +00:00
]"
2021-07-06 12:20:37 +00:00
@click="setBGMode(color)"
2020-09-24 02:52:54 +00:00
>
<i class="material-icons">{{ getIcon(color) }}</i>
</span>
</div>
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>