From f0b5ba92d6005c007ce1288c528789ac71120985 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 25 Mar 2025 16:54:54 +0000 Subject: [PATCH] polish badge --- _includes/default_head_tags.html | 5 ++++- assets/js/pre_page_load.js | 17 ++++++++++++++--- badge.html | 19 +++++++++++++++++++ manifest.json | 11 ++++++++--- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/_includes/default_head_tags.html b/_includes/default_head_tags.html index 205dca1..3cabff8 100644 --- a/_includes/default_head_tags.html +++ b/_includes/default_head_tags.html @@ -14,7 +14,10 @@ - + + + + diff --git a/assets/js/pre_page_load.js b/assets/js/pre_page_load.js index 3fbbba4..0b1c4b8 100644 --- a/assets/js/pre_page_load.js +++ b/assets/js/pre_page_load.js @@ -14,6 +14,8 @@ const getCSSCustomProp = (propKey) => { return response; }; +const themeColor = document.querySelectorAll('meta[name="theme-color"]'); + const applySetting = () => { let currentSetting = localStorage.getItem(STORAGE_KEY) || getCSSCustomProp(COLOR_MODE_KEY); @@ -23,10 +25,19 @@ const applySetting = () => { "data-user-color-scheme", currentSetting ); + switch (currentSetting) { + case "light": + console.log("setting theme colour to #fcfcfc"); + themeColor.forEach((n) => n.setAttribute("content", "#fcfcfc")); + break; + case "dark": + themeColor.forEach((n) => n.setAttribute("content", "#222")); + break; + } } - console.log( - `Mode Preference set on document.documentElement.getAttribute("data-user-color-scheme"): ${currentSetting}` - ); + // console.log( + // `Mode Preference set on document.documentElement.getAttribute("data-user-color-scheme"): ${currentSetting}` + // ); }; let localStorageSetting = localStorage.getItem(STORAGE_KEY); diff --git a/badge.html b/badge.html index 1af210a..a46c0af 100644 --- a/badge.html +++ b/badge.html @@ -12,10 +12,20 @@ img: {% include default_head_tags.html %}