feat: theme syncing

This commit is contained in:
Andrew Bastin
2021-07-06 08:20:37 -04:00
parent 86bd4aa568
commit 48e562dcee
5 changed files with 122 additions and 49 deletions

View File

@@ -38,40 +38,37 @@
</div>
</template>
<script>
import { getLocalConfig, setLocalConfig } from "~/newstore/localpersistence"
<script lang="ts">
import Vue from "vue"
import {
HoppAccentColors,
HoppAccentColor,
getSettingSubject,
settingsStore,
applySetting,
} from "~/newstore/settings"
export default {
export default Vue.extend({
data() {
return {
active: getLocalConfig("THEME_COLOR") || "green",
accentColors: [
"blue",
"green",
"teal",
"indigo",
"purple",
"orange",
"pink",
"red",
"yellow",
],
accentColors: HoppAccentColors,
active: settingsStore.value.THEME_COLOR,
}
},
watch: {
active(color) {
setLocalConfig("THEME_COLOR", color)
},
subscriptions() {
return {
active: getSettingSubject("THEME_COLOR"),
}
},
methods: {
setActiveColor(color) {
setActiveColor(color: HoppAccentColor) {
document.documentElement.setAttribute("data-accent", color)
this.active = color
applySetting("THEME_COLOR", color)
},
capitalized(color) {
capitalized(color: HoppAccentColor) {
return `${color.charAt(0).toUpperCase()}${color.slice(1)}`
},
},
}
})
</script>