VueTube/NUXT/pages/mods/theme.vue

148 lines
3.9 KiB
Vue
Raw Normal View History

2022-03-14 17:13:24 +00:00
<template>
<div class="mainContainer pt-1">
<v-card class="pb-5">
<v-card-title>Rounded Corners</v-card-title>
<v-row class="ml-3 mr-6">
<section class="row">
<v-switch
v-model="roblox"
label="Roblox"
hint="If you want UI to look like Minecraft"
persistent-hint
inset
@click="saveRadius(roblox)"
/>
</section>
</v-row>
</v-card>
2022-03-14 17:13:24 +00:00
<v-card class="pb-5">
2022-03-14 17:24:47 +00:00
<v-card-title>Global Base Color</v-card-title>
2022-03-14 17:13:24 +00:00
<v-row class="ml-3 mr-6">
<section class="row">
<v-switch
v-model="$vuetify.theme.dark"
label="Dark Theme"
hint="Bravo Six, Going Dark."
persistent-hint
inset
@click="saveTheme($vuetify.theme.dark)"
/>
</section>
<v-btn v-if="$vuetify.theme.dark" text tile class="white--text black" @click="amoled" >
{{
this.$vuetify.theme.themes.dark.background === '#000'
? 'LCD'
: 'OLED'
}}
<v-icon :size="this.$vuetify.theme.themes.dark.background === '#000' ? '.5rem' : '.9rem'" class="ml-2">mdi-brightness-2</v-icon>
</v-btn>
</v-row>
</v-card>
2022-03-15 22:33:16 +00:00
<v-card class="pb-5">
<v-card-title>Accent Color</v-card-title>
<v-card-text>
<v-alert color="primary" dense outlined type="warning">NOTE: This doesn't save after closing the app (yet)</v-alert>
<v-color-picker dot-size="5" hide-mode-switch mode="hexa" v-model="accentColor" />
</v-card-text>
</v-card>
2022-03-14 17:13:24 +00:00
</div>
</template>
<script>
export default {
2022-03-15 22:33:16 +00:00
data() {
return {
accentColor: '#ffffff',
roblox: false,
2022-03-15 22:33:16 +00:00
}
},
mounted() {
2022-03-16 00:13:26 +00:00
this.accentColor = this.$vuetify.theme.themes.dark.primary;
this.roblox = localStorage.getItem('roblox') === 'true';
2022-03-15 22:33:16 +00:00
},
2022-03-14 17:13:24 +00:00
methods: {
amoled() {
this.$vuetify.theme.themes.dark.background === '#000' ? (
this.$vuetify.theme.themes.dark.accent = '#222',
this.$vuetify.theme.themes.dark.accent2 = '#222',
2022-03-16 06:18:01 +00:00
this.$vuetify.theme.themes.dark.background = '#333',
localStorage.setItem("isOled", false)
2022-03-14 17:13:24 +00:00
) : (
this.$vuetify.theme.themes.dark.accent = '#000',
this.$vuetify.theme.themes.dark.accent2 = '#000',
2022-03-16 06:18:01 +00:00
this.$vuetify.theme.themes.dark.background = '#000',
localStorage.setItem("isOled", true)
2022-03-14 17:13:24 +00:00
)
// doesn't work 😭
// console.log(document.getElementsByClassName('v-application--wrap')[0])
// console.log(document.getElementsByClassName('v-application--wrap')[0].style)
// document.getElementsByClassName('v-application--wrap')[0].style.backgroundColor = "#000000 !important"
},
saveTheme(isDark) {
2022-03-15 19:43:30 +00:00
localStorage.setItem("darkTheme", isDark);
2022-03-15 22:33:16 +00:00
},
saveRadius(value) {
localStorage.setItem("roblox", value);
},
2022-03-15 22:33:16 +00:00
},
computed: {
// 😩
// roblox: {
// get () {
// return localStorage.getItem("roblox") === 'true'
// },
// set (value) {
// if(process.client) {
// localStorage.setItem("roblox", value)
// }
// }
// }
},
2022-03-15 22:33:16 +00:00
watch: {
accentColor: function (val, oldVal) {
this.$vuetify.theme.currentTheme.primary = val;
let primaryAlt = this.$libs.hexToRgb(val);
2022-03-16 00:13:26 +00:00
let rgbEdit = 130; //Light Mode
if (localStorage.getItem('darkTheme') === "true") rgbEdit = -80; //Dark Mode
2022-03-15 22:33:16 +00:00
for (const i in primaryAlt) {
2022-03-16 00:13:26 +00:00
primaryAlt[i] = primaryAlt[i] + rgbEdit; //Amount To Lighten By
2022-03-15 22:33:16 +00:00
if (primaryAlt[i] > 255) primaryAlt[i] = 255;
2022-03-16 00:13:26 +00:00
if (primaryAlt[i] < 0) primaryAlt[i] = 0;
2022-03-15 22:33:16 +00:00
}
primaryAlt = this.$libs.rgbToHex(primaryAlt.r, primaryAlt.g, primaryAlt.b);
this.$vuetify.theme.currentTheme.primaryAlt = primaryAlt;
2022-03-14 17:13:24 +00:00
}
}
2022-03-15 22:33:16 +00:00
2022-03-14 17:13:24 +00:00
}
</script>
<style scoped>
.v-card {
margin: 1em;
}
section {
padding: 0 1em 1em 1em;
}
</style>