v1.8.11: fix branding colors — inject style overrides for Tailwind classes, sync color picker with hex input

This commit is contained in:
2026-05-28 20:54:56 +00:00
parent 4f8692cc77
commit 9f489fbbcb
15 changed files with 49 additions and 12 deletions
+21 -2
View File
@@ -373,8 +373,27 @@ let currentUser = null;
fetch('/branding').then(r=>r.json()).then(b=>{
if(b.site_name){document.title=b.site_name;const bn=document.getElementById('brand-name');if(bn)bn.textContent=b.site_name;}
if(b.site_subtitle){const bs=document.getElementById('brand-sub');if(bs)bs.textContent=b.site_subtitle;}
if(b.primary_color) document.documentElement.style.setProperty('--primary', b.primary_color);
if(b.secondary_color) document.documentElement.style.setProperty('--secondary', b.secondary_color);
if(b.primary_color || b.secondary_color) {
const p = b.primary_color || '#4edea3';
const s = b.secondary_color || '#95d3ba';
document.documentElement.style.setProperty('--primary', p);
document.documentElement.style.setProperty('--secondary', s);
// Override Tailwind hardcoded colors with dynamic style injection
const style = document.createElement('style');
style.textContent = `
.text-primary { color: ${p} !important; }
.bg-primary { background-color: ${p} !important; }
.border-primary { border-color: ${p} !important; }
.text-secondary { color: ${s} !important; }
.bg-secondary { background-color: ${s} !important; }
.border-secondary { border-color: ${s} !important; }
.hover\\:text-primary:hover { color: ${p} !important; }
.hover\\:bg-primary:hover { background-color: ${p} !important; }
.focus\\:border-primary:focus { border-color: ${p} !important; }
.shadow-primary { --tw-shadow-color: ${p}; }
`;
document.head.appendChild(style);
}
if(b.logo_url){
const logo=document.getElementById('brand-logo');
if(logo){logo.src=b.logo_url;logo.style.height=(b.logo_size||'40')+'px';logo.classList.remove('hidden');}