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 d023c50
Show file tree
Hide file tree
Showing 2 changed files with 5 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
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function ColorModeSwitch() {
if (currColorMode !== colorMode) {
currColorMode = colorMode;
try {
document.querySelector('meta[name="theme-color"]').setAttribute("content", 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 d023c50

Please sign in to comment.