mirror of
https://codeberg.org/SafeTwitch/safetwitch.git
synced 2025-01-03 11:20:07 -05:00
Finish theme selector
This commit is contained in:
parent
5725e84fc7
commit
782a8141ba
4 changed files with 36 additions and 14 deletions
|
@ -4,11 +4,13 @@ import NavbarItem from './components/NavbarView.vue'
|
||||||
import FooterItem from './components/FooterView.vue'
|
import FooterItem from './components/FooterView.vue'
|
||||||
import DevWarning from './components/DevWarning.vue'
|
import DevWarning from './components/DevWarning.vue'
|
||||||
|
|
||||||
|
import { getTheme } from '@/settingsManager'
|
||||||
|
|
||||||
const dev = import.meta.env.DEV
|
const dev = import.meta.env.DEV
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template class="h-full flex flex-row">
|
<template class="h-full flex flex-row">
|
||||||
<div class="light bg-primary">
|
<div :class="getTheme()" class="bg-primary">
|
||||||
<dev-warning v-if="dev"></dev-warning>
|
<dev-warning v-if="dev"></dev-warning>
|
||||||
<navbar-item></navbar-item>
|
<navbar-item></navbar-item>
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit b0f6c8230dceb847d2df2eb79cdd272aa2cd85f4
|
Subproject commit ab47fd80cc24baa7df8a53a9f481ff367ca74e6d
|
|
@ -83,6 +83,10 @@ export function getSetting(key: string): boolean | string {
|
||||||
return parsed[key].selected
|
return parsed[key].selected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getTheme() {
|
||||||
|
return localStorage.getItem('theme') || "light"
|
||||||
|
}
|
||||||
|
|
||||||
export function chatVisible() {
|
export function chatVisible() {
|
||||||
const p = getSetting('chatVisible')
|
const p = getSetting('chatVisible')
|
||||||
// Flip becuase on the setting page it's
|
// Flip becuase on the setting page it's
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { ref } from 'vue'
|
||||||
import { getDefaultSettings, syncUserSettings, setLanguage, themeList } from '@/settingsManager'
|
import { getDefaultSettings, syncUserSettings, setLanguage, themeList } from '@/settingsManager'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -13,9 +14,12 @@ export default {
|
||||||
settings = JSON.parse(storedSettings)
|
settings = JSON.parse(storedSettings)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let selectedTheme = localStorage.getItem('theme') || "light"
|
||||||
|
|
||||||
return {
|
return {
|
||||||
settings,
|
settings,
|
||||||
themeList
|
themeList,
|
||||||
|
selectedTheme: ref(selectedTheme)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -24,8 +28,18 @@ export default {
|
||||||
localStorage.setItem('settings', settings)
|
localStorage.setItem('settings', settings)
|
||||||
setLanguage(this.settings.language.selected, this.$i18n)
|
setLanguage(this.settings.language.selected, this.$i18n)
|
||||||
|
|
||||||
|
this.setTheme()
|
||||||
// Reload needed
|
// Reload needed
|
||||||
location.href = "/"
|
location.href = "/"
|
||||||
|
},
|
||||||
|
setTheme() {
|
||||||
|
localStorage.setItem('theme', this.selectedTheme)
|
||||||
|
},
|
||||||
|
highlight(theme: string) {
|
||||||
|
if (this.selectedTheme == theme) {
|
||||||
|
return 'border-purple'
|
||||||
|
}
|
||||||
|
return "border-none"
|
||||||
}
|
}
|
||||||
// download() {
|
// download() {
|
||||||
// var hiddenElement = document.createElement('a');
|
// var hiddenElement = document.createElement('a');
|
||||||
|
@ -63,12 +77,8 @@ export default {
|
||||||
|
|
||||||
<div v-else-if="setting.type == 'option'" class="justify-between items-center flex">
|
<div v-else-if="setting.type == 'option'" class="justify-between items-center flex">
|
||||||
<label :for="setting.name">{{ $t(`settings.${setting.name}`) }}</label>
|
<label :for="setting.name">{{ $t(`settings.${setting.name}`) }}</label>
|
||||||
<select
|
<select :name="setting.name" type="checkbox" v-model="setting.selected"
|
||||||
:name="setting.name"
|
class="text-black rounded-md h-8 p-0 pr-8 pl-2">
|
||||||
type="checkbox"
|
|
||||||
v-model="setting.selected"
|
|
||||||
class="text-black rounded-md h-8 p-0 pr-8 pl-2"
|
|
||||||
>
|
|
||||||
<option v-for="option of setting.options" :key="option" :value="option">
|
<option v-for="option of setting.options" :key="option" :value="option">
|
||||||
{{ option }}
|
{{ option }}
|
||||||
</option>
|
</option>
|
||||||
|
@ -77,11 +87,17 @@ export default {
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h1 class="font-bold text-3xl mt-2">{{ $t("nav.theme") }}</h1>
|
<h1 class="font-bold text-3xl mt-2">{{ $t("main.themes") }}</h1>
|
||||||
<hr class="my-2" />
|
<hr class="my-2" />
|
||||||
<ul>
|
<ul class="flex space-x-2 ">
|
||||||
<li v-for="theme in themeList" :key="theme.name">
|
<!--
|
||||||
{{ theme.name }}</li>
|
Use theme colors for preview
|
||||||
|
-->
|
||||||
|
<li v-for="theme in themeList" :key="theme.name" class="hover:scale-110 border-2 rounded-md transition-transform" :class="highlight(theme.name)">
|
||||||
|
<button @click="selectedTheme = theme.name" class="p-5 py-1.5 border-4 rounded-md" :style="`border-color: ${theme.extend.colors.primary}; background:${theme.extend.colors.crust}; color:${theme.extend.colors.contrast};`">
|
||||||
|
<p>{{ theme.name }}</p>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="space-x-2 mt-3">
|
<div class="space-x-2 mt-3">
|
||||||
|
|
Loading…
Reference in a new issue