Skip to content

Commit

Permalink
set browser theme color
Browse files Browse the repository at this point in the history
  • Loading branch information
io53 committed Mar 20, 2024
1 parent fbd7de5 commit f2d988e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
-->
<script>
let bgMode = localStorage.getItem("chakra-ui-color-mode") || "dark"
document.body.style.background = bgMode === "dark" ? "#001b1a" : "#edf2f2"
let bgColor = bgMode === "dark" ? "#001b1a" : "#edf2f2"
document.body.style.background = bgColor
document.querySelector('meta[name="theme-color"]').setAttribute('content', bgColor);

try {
let cookie = document.cookie;
Expand Down Expand Up @@ -112,7 +114,7 @@
return window.location.href.indexOf("/staging") !== -1
}
function getUserKey() {
return isStaging() ? "staging_user" : "user"
return isStaging() ? "staging_user" : "user"
}
if (!isStaging() && !getUser()) {
localStorage.removeItem(getUserKey())
Expand Down
3 changes: 2 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ function ColorModeSwitch() {
if (currColorMode !== colorMode) {
currColorMode = colorMode;
try {
document.querySelector('meta[name="theme-color"]').setAttribute("content", ruuviTheme.newColors.bodyBg[currColorMode]);
console.log("ruuviTheme.newColors.bodyBg[currColorMode]", ruuviTheme.newColors.bodyBg[currColorMode])
document.querySelector('meta[name="theme-color"]').setAttribute("content", ruuviTheme.newColors.bodyBg[currColorMode].replace(" !important", ""));
} catch (error) {
}
}
Expand Down

0 comments on commit f2d988e

Please sign in to comment.