Browser tab color matches selected theme

This commit is contained in:
Liyas Thomas
2019-10-29 12:17:57 +05:30
parent 27d3e9e6b7
commit be00a6fd60
2 changed files with 10 additions and 2 deletions

View File

@@ -5,7 +5,7 @@
<li> <li>
<h3 class="title">Background</h3> <h3 class="title">Background</h3>
<div class="backgrounds"> <div class="backgrounds">
<span :key="theme.class" @click="applyTheme(theme.class)" v-for="theme in themes"> <span :key="theme.class" @click="applyTheme(theme.class, theme.color)" v-for="theme in themes">
<swatch <swatch
:active="settings.THEME_CLASS === theme.class" :active="settings.THEME_CLASS === theme.class"
:class="{ vibrant: theme.vibrant }" :class="{ vibrant: theme.vibrant }"
@@ -164,6 +164,7 @@
settings: { settings: {
THEME_CLASS: this.$store.state.postwoman.settings.THEME_CLASS || "", THEME_CLASS: this.$store.state.postwoman.settings.THEME_CLASS || "",
THEME_COLOR: "", THEME_COLOR: "",
THEME_TAB_COLOR: "",
THEME_COLOR_VIBRANT: true, THEME_COLOR_VIBRANT: true,
DISABLE_FRAME_COLORS: DISABLE_FRAME_COLORS:
@@ -187,8 +188,10 @@
}, },
methods: { methods: {
applyTheme(name) { applyTheme(name, color) {
this.applySetting("THEME_CLASS", name); this.applySetting("THEME_CLASS", name);
document.querySelector('meta[name=theme-color]').setAttribute('content', color)
this.applySetting("THEME_TAB_COLOR", color);
document.documentElement.className = name; document.documentElement.className = name;
let imgGitHub = document.getElementById("imgGitHub"); let imgGitHub = document.getElementById("imgGitHub");
imgGitHub.style["filter"] = ""; imgGitHub.style["filter"] = "";

View File

@@ -12,6 +12,11 @@ export const SETTINGS_KEYS = [
*/ */
"THEME_COLOR", "THEME_COLOR",
/**
* The hex color code for browser tab color.
*/
"THEME_TAB_COLOR",
/** /**
* Whether or not THEME_COLOR is considered 'vibrant'. * Whether or not THEME_COLOR is considered 'vibrant'.
* *