Add light theme. (#219)

* Add light theme.

* Reload on theme change.
This commit is contained in:
FireMasterK 2021-06-29 01:15:03 +05:30 committed by GitHub
parent 7c66035f41
commit 18752c7de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 54 additions and 22 deletions

View File

@ -1,5 +1,9 @@
<template> <template>
<div class="uk-container uk-container-expand uk-light uk-height-viewport" style="background: #0b0e0f"> <div
class="uk-container uk-container-expand uk-height-viewport"
:style="[{ background: backgroundColor, colour: foregroundColor }]"
:class="{ 'uk-light': darkMode }"
>
<Navigation /> <Navigation />
<router-view /> <router-view />
@ -34,10 +38,6 @@ b {
text-align: start; text-align: start;
} }
#app {
background: #0b0e0f;
}
::-webkit-scrollbar { ::-webkit-scrollbar {
background-color: #15191a; background-color: #15191a;
color: #c5bcae; color: #c5bcae;

View File

@ -1,11 +1,11 @@
<template> <template>
<nav <nav
class="uk-navbar-container uk-container-expand uk-position-relative uk-light" class="uk-navbar-container uk-container-expand uk-position-relative"
style="background: #0b0e0f" :style="[{ background: backgroundColor, colour: foregroundColor }]"
uk-navbar uk-navbar
> >
<div class="uk-navbar-left"> <div class="uk-navbar-left">
<router-link class="uk-navbar-item uk-logo uk-text-bold" to="/" <router-link class="uk-navbar-item uk-logo uk-text-bold" :style="[{ colour: foregroundColor }]" to="/"
><img alt="logo" src="/img/icons/logo.svg" height="32" width="32" />iped</router-link ><img alt="logo" src="/img/icons/logo.svg" height="32" width="32" />iped</router-link
> >
</div> </div>

View File

@ -31,6 +31,13 @@
<br /> <br />
<input class="uk-checkbox" v-model="skipMusicOffTopic" @change="onChange($event)" type="checkbox" /> <input class="uk-checkbox" v-model="skipMusicOffTopic" @change="onChange($event)" type="checkbox" />
<br /> <br />
<b>Theme</b>
<br />
<select class="uk-select uk-width-auto" v-model="selectedTheme" @change="onChange($event)">
<option value="dark">Dark</option>
<option value="light">Light</option>
</select>
<br />
<b>Autoplay Video</b> <b>Autoplay Video</b>
<br /> <br />
<input class="uk-checkbox" v-model="autoPlayVideo" @change="onChange($event)" type="checkbox" /> <input class="uk-checkbox" v-model="autoPlayVideo" @change="onChange($event)" type="checkbox" />
@ -95,6 +102,7 @@ export default {
skipInteraction: true, skipInteraction: true,
skipSelfPromo: true, skipSelfPromo: true,
skipMusicOffTopic: true, skipMusicOffTopic: true,
selectedTheme: "dark",
autoPlayVideo: true, autoPlayVideo: true,
audioOnly: false, audioOnly: false,
resolutions: [144, 240, 360, 480, 720, 1080, 1440, 2160, 4320], resolutions: [144, 240, 360, 480, 720, 1080, 1440, 2160, 4320],
@ -159,6 +167,7 @@ export default {
}); });
} }
this.selectedTheme = localStorage.getItem("theme") || "dark";
this.autoPlayVideo = this.autoPlayVideo =
localStorage.getItem("playerAutoPlay") === null || localStorage.getItem("playerAutoPlay") === "true"; localStorage.getItem("playerAutoPlay") === null || localStorage.getItem("playerAutoPlay") === "true";
this.audioOnly = localStorage.getItem("audioOnly") === "true"; this.audioOnly = localStorage.getItem("audioOnly") === "true";
@ -169,6 +178,10 @@ export default {
methods: { methods: {
onChange() { onChange() {
if (localStorage) { if (localStorage) {
var shouldReload = false;
if (localStorage.getItem("playerAutoPlay") !== this.autoPlayVideo) shouldReload = true;
localStorage.setItem("instance", this.selectedInstance); localStorage.setItem("instance", this.selectedInstance);
localStorage.setItem("sponsorblock", this.sponsorBlock); localStorage.setItem("sponsorblock", this.sponsorBlock);
@ -181,10 +194,13 @@ export default {
if (this.skipMusicOffTopic) sponsorSelected.push("music_offtopic"); if (this.skipMusicOffTopic) sponsorSelected.push("music_offtopic");
localStorage.setItem("selectedSkip", sponsorSelected); localStorage.setItem("selectedSkip", sponsorSelected);
localStorage.setItem("theme", this.selectedTheme);
localStorage.setItem("playerAutoPlay", this.autoPlayVideo); localStorage.setItem("playerAutoPlay", this.autoPlayVideo);
localStorage.setItem("audioOnly", this.audioOnly); localStorage.setItem("audioOnly", this.audioOnly);
localStorage.setItem("quality", this.defaultQuality); localStorage.setItem("quality", this.defaultQuality);
localStorage.setItem("bufferGoal", this.bufferingGoal); localStorage.setItem("bufferGoal", this.bufferingGoal);
if (shouldReload) window.location.reload();
} }
}, },
sslScore(url) { sslScore(url) {

View File

@ -20,12 +20,12 @@
<div v-if="results" class="uk-grid-xl" uk-grid="parallax: 0"> <div v-if="results" class="uk-grid-xl" uk-grid="parallax: 0">
<div <div
style="background: #0b0e0f" :style="[{ background: backgroundColor }]"
class="uk-width-1-2 uk-width-1-3@s uk-width-1-4@m uk-width-1-5@l uk-width-1-6@xl" class="uk-width-1-2 uk-width-1-3@s uk-width-1-4@m uk-width-1-5@l uk-width-1-6@xl"
v-bind:key="result.url" v-bind:key="result.url"
v-for="result in results.items" v-for="result in results.items"
> >
<div class="uk-text-secondary" style="background: #0b0e0f"> <div class="uk-text-secondary">
<router-link class="uk-text-emphasis" v-bind:to="result.url"> <router-link class="uk-text-emphasis" v-bind:to="result.url">
<img style="width: 100%" v-bind:src="result.thumbnail" loading="lazy" /> <img style="width: 100%" v-bind:src="result.thumbnail" loading="lazy" />
<p> <p>

View File

@ -1,10 +1,13 @@
<template> <template>
<div class="uk-position-absolute uk-panel uk-box-shadow-large suggestions-container"> <div
class="uk-position-absolute uk-panel uk-box-shadow-large suggestions-container"
:style="[{ background: secondaryBackgroundColor }]"
>
<ul class="uk-list uk-margin-remove uk-text-secondary"> <ul class="uk-list uk-margin-remove uk-text-secondary">
<li <li
v-for="(suggestion, i) in searchSuggestions" v-for="(suggestion, i) in searchSuggestions"
:key="i" :key="i"
:class="{ selected: selected === i }" :style="[selected === i ? { background: secondaryForegroundColor } : {}]"
@mouseover="onMouseOver(i)" @mouseover="onMouseOver(i)"
@mousedown.stop="onClick(i)" @mousedown.stop="onClick(i)"
class="uk-margin-remove suggestion" class="uk-margin-remove suggestion"
@ -77,7 +80,6 @@ export default {
<style> <style>
.suggestions-container { .suggestions-container {
background-color: #242727;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
max-width: 640px; max-width: 640px;
@ -88,9 +90,6 @@ export default {
.suggestion { .suggestion {
padding: 4px 15px; padding: 4px 15px;
} }
.suggestion.selected {
background-color: #393d3d;
}
@media screen and (max-width: 959px) { @media screen and (max-width: 959px) {
.suggestions-container { .suggestions-container {
max-width: calc(100% - 60px); max-width: calc(100% - 60px);

View File

@ -5,7 +5,7 @@
<div class="uk-grid-xl" uk-grid="parallax: 0"> <div class="uk-grid-xl" uk-grid="parallax: 0">
<div <div
style="background: #0b0e0f" :style="[{ background: backgroundColor }]"
class="uk-width-1-2 uk-width-1-3@s uk-width-1-4@m uk-width-1-5@l uk-width-1-6@xl" class="uk-width-1-2 uk-width-1-3@s uk-width-1-4@m uk-width-1-5@l uk-width-1-6@xl"
v-bind:key="video.url" v-bind:key="video.url"
v-for="video in videos" v-for="video in videos"

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="uk-text-secondary" style="background: #0b0e0f"> <div class="uk-text-secondary" :style="[{ background: backgroundColor }]">
<router-link class="uk-text-emphasis" v-bind:to="video.url"> <router-link class="uk-text-emphasis" v-bind:to="video.url">
<img <img
:height="height" :height="height"

View File

@ -11,7 +11,7 @@
<a>{{ video.uploader }}</a> <a>{{ video.uploader }}</a>
</router-link> </router-link>
<p class="uk-dark"> <p :style="[{ colour: foregroundColor }]">
<font-awesome-icon icon="thumbs-up"></font-awesome-icon> <font-awesome-icon icon="thumbs-up"></font-awesome-icon>
<b>{{ addCommas(video.likes) }}</b> <b>{{ addCommas(video.likes) }}</b>
&nbsp; &nbsp;
@ -28,7 +28,7 @@
<a class="uk-button uk-button-small" style="background: #222" @click="showDesc = !showDesc"> <a class="uk-button uk-button-small" style="background: #222" @click="showDesc = !showDesc">
{{ showDesc ? "+" : "-" }} {{ showDesc ? "+" : "-" }}
</a> </a>
<p v-show="showDesc" class="uk-light" v-html="video.description"></p> <p v-show="showDesc" :style="[{ colour: foregroundColor }]" v-html="video.description"></p>
</div> </div>
<a v-if="sponsors && sponsors.segments">Sponsors Segments: {{ sponsors.segments.length }}</a> <a v-if="sponsors && sponsors.segments">Sponsors Segments: {{ sponsors.segments.length }}</a>
@ -44,7 +44,7 @@
<div class="uk-width-4-5@xl uk-width-3-4@l uk-width-2-3" v-if="comments" ref="comments"> <div class="uk-width-4-5@xl uk-width-3-4@l uk-width-2-3" v-if="comments" ref="comments">
<div <div
class="uk-tile-default uk-align-left uk-width-expand" class="uk-tile-default uk-align-left uk-width-expand"
style="background: #0b0e0f" :style="[{ background: backgroundColor }]"
v-bind:key="comment.commentId" v-bind:key="comment.commentId"
v-for="comment in comments.comments" v-for="comment in comments.comments"
> >
@ -81,7 +81,7 @@
<div class="uk-width-1-5@xl uk-width-1-4@l uk-width-1-3" v-if="video"> <div class="uk-width-1-5@xl uk-width-1-4@l uk-width-1-3" v-if="video">
<div <div
class="uk-tile-default uk-width-auto" class="uk-tile-default uk-width-auto"
style="background: #0b0e0f" :style="[{ background: backgroundColor }]"
v-bind:key="related.url" v-bind:key="related.url"
v-for="related in video.relatedStreams" v-for="related in video.relatedStreams"
> >

View File

@ -69,6 +69,23 @@ const mixin = {
return DOMPurify.sanitize(original); return DOMPurify.sanitize(original);
} }
}, },
computed: {
backgroundColor() {
return localStorage.getItem("theme") === "light" ? "#fff" : "#0b0e0f"
},
secondaryBackgroundColor() {
return localStorage.getItem("theme") === "light" ? "#e5e5e5" : "#242727"
},
foregroundColor() {
return localStorage.getItem("theme") === "light" ? "#15191a" : "#0b0e0f"
},
secondaryForegroundColor() {
return localStorage.getItem("theme") === "light" ? "#666" : "#393d3d"
},
darkMode() {
return localStorage.getItem('theme') !== 'light'
}
}
}; };
const app = createApp(App); const app = createApp(App);