Compare commits

..
2 Commits
Author SHA1 Message Date
cole-maxwell1 8dc216d4e9 fix(theme): synchronize navbar logo with active color scheme
Replace CSS background-image switching with direct navbar image source updates to avoid Safari and WebKit repaint failures.

Select the appropriate logo during initial DOM construction and update it when the system color scheme changes, Safari restores a cached page, or the document returns to the foreground. Preserve CSP compatibility and Gitea subpath support while retaining the existing logo dimensions.
2026-09-07 21:34:45 -05:00
cole-maxwell1 d8cf7ed29b fix(theme): refresh navbar logo on iOS Safari
Replace CSS content substitution with theme-specific navbar background images to ensure WebKit repaints the logo when the system color scheme changes.

Hide the upstream image while preserving its layout dimensions, and use selectors that prevent Gitea's navbar hover styles from clearing the custom logo.
2026-09-07 19:00:10 -05:00
4 changed files with 36 additions and 18 deletions
+1 -12
View File
@@ -1,21 +1,10 @@
@import "./theme-codecraftsmen-light.css" (prefers-color-scheme: light);
@import "./theme-codecraftsmen-dark.css" (prefers-color-scheme: dark);
@media (prefers-color-scheme: light) {
html[data-theme="codecraftsmen-auto"] #navbar-logo img {
content: url("../img/logo-light-no-slogan.svg");
html[data-theme="codecraftsmen-auto"] #navbar #navbar-logo img {
width: 60px;
height: 30px;
}
}
@media (prefers-color-scheme: dark) {
html[data-theme="codecraftsmen-auto"] #navbar-logo img {
content: url("../img/logo-dark-no-slogan.svg");
width: 60px;
height: 30px;
}
}
gitea-theme-meta-info {
--theme-display-name: "CodeCraftsmen Auto";
@@ -293,8 +293,7 @@ gitea-theme-meta-info {
--cc-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
html[data-theme="codecraftsmen-dark"] #navbar-logo img {
content: url("../img/logo-dark-no-slogan.svg");
html[data-theme="codecraftsmen-dark"] #navbar #navbar-logo img {
width: 60px;
height: 30px;
}
@@ -269,8 +269,7 @@ gitea-theme-meta-info {
--cc-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
html[data-theme="codecraftsmen-light"] #navbar-logo img {
content: url("../img/logo-light-no-slogan.svg");
html[data-theme="codecraftsmen-light"] #navbar #navbar-logo img {
width: 60px;
height: 30px;
}
+31
View File
@@ -4,3 +4,34 @@
window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};
plausible.init()
</script>
<script nonce="{{ctx.CspScriptNonce}}">
(() => {
const darkMode = window.matchMedia("(prefers-color-scheme: dark)");
const updateNavbarLogo = () => {
const logo = document.querySelector("#navbar-logo img");
const theme = document.documentElement.dataset.theme;
if (!logo) return false;
if (!theme?.startsWith("codecraftsmen-")) return true;
const dark = theme === "codecraftsmen-dark" || (theme === "codecraftsmen-auto" && darkMode.matches);
const src = `${window.config.assetUrlPrefix}/img/logo-${dark ? "dark" : "light"}-no-slogan.svg`;
if (logo.getAttribute("src") !== src) logo.setAttribute("src", src);
return true;
};
const navbarObserver = new MutationObserver(() => {
if (updateNavbarLogo()) navbarObserver.disconnect();
});
navbarObserver.observe(document.documentElement, {childList: true, subtree: true});
document.addEventListener("DOMContentLoaded", () => {
updateNavbarLogo();
navbarObserver.disconnect();
}, {once: true});
darkMode.addEventListener("change", updateNavbarLogo);
window.addEventListener("pageshow", updateNavbarLogo);
document.addEventListener("visibilitychange", () => {
if (!document.hidden) updateNavbarLogo();
});
})();
</script>