refactor(theme): remove light theme and enforce dark mode across all apps

This commit is contained in:
oib
2026-02-27 14:00:33 +01:00
parent 521f7ec04a
commit d023654e74
15 changed files with 89 additions and 447 deletions

View File

@@ -21,16 +21,6 @@ body.dark {
--global-header-cta-text: #0f172a;
}
body.light {
--global-header-bg: rgba(255, 255, 255, 0.97);
--global-header-border: rgba(15, 23, 42, 0.08);
--global-header-text: #111827;
--global-header-muted: #6b7280;
--global-header-pill: rgba(37, 99, 235, 0.07);
--global-header-pill-hover: rgba(37, 99, 235, 0.15);
--global-header-accent: #2563eb;
--global-header-cta-text: #fff;
}
.global-header {
height: 90px;
@@ -45,7 +35,7 @@ body.light {
}
.global-header__inner {
max-width: 1200px;
max-width: 1160px;
margin: 0 auto;
padding: 0 1.25rem;
height: 100%;
@@ -137,27 +127,10 @@ body.light {
flex-wrap: wrap;
}
.global-dark-toggle {
border: 1px solid var(--global-header-border);
background: transparent;
color: var(--global-header-text);
padding: 0.35rem 0.9rem;
border-radius: 999px;
font-size: 0.9rem;
display: inline-flex;
align-items: center;
gap: 0.35rem;
cursor: pointer;
transition: all 0.2s ease;
}
.global-dark-toggle:hover {
border-color: var(--global-header-accent);
color: var(--global-header-accent);
}
.global-subnav {
max-width: 1200px;
max-width: 1160px;
margin: 0 auto;
padding: 0 1.25rem 0.75rem;
display: flex;

View File

@@ -1,15 +1,11 @@
(function () {
// Immediately restore theme on script load
const savedTheme = localStorage.getItem('theme') || localStorage.getItem('exchangeTheme');
if (savedTheme) {
if (savedTheme === 'dark') {
document.documentElement.setAttribute('data-theme', 'dark');
document.documentElement.classList.add('dark');
} else {
document.documentElement.removeAttribute('data-theme');
document.documentElement.classList.remove('dark');
}
}
// Always enforce dark theme
document.documentElement.setAttribute('data-theme', 'dark');
document.documentElement.classList.add('dark');
// Clean up any old user preferences
if (localStorage.getItem('theme')) localStorage.removeItem('theme');
if (localStorage.getItem('exchangeTheme')) localStorage.removeItem('exchangeTheme');
const NAV_ITEMS = [
{ key: 'home', label: 'Home', href: '/' },
@@ -19,8 +15,6 @@
{ key: 'docs', label: 'Docs', href: '/docs/index.html' },
];
const CTA = { label: 'Launch Marketplace', href: '/marketplace/' };
function determineActiveKey(pathname) {
if (pathname.startsWith('/explorer')) return 'explorer';
if (pathname.startsWith('/marketplace')) return 'marketplace';
@@ -48,81 +42,11 @@
</div>
</a>
<nav class="global-nav">${navLinks}</nav>
<div class="global-header__actions">
<button type="button" class="global-dark-toggle" data-role="global-theme-toggle">
<span class="global-dark-toggle__emoji">🌙</span>
<span class="global-dark-toggle__text">Dark</span>
</button>
</div>
</div>
</header>
`;
}
function getCurrentTheme() {
if (document.documentElement.hasAttribute('data-theme')) {
return document.documentElement.getAttribute('data-theme');
}
if (document.documentElement.classList.contains('dark')) return 'dark';
if (document.body && document.body.classList.contains('light')) return 'light';
return 'light';
}
function updateToggleLabel(theme) {
const emojiEl = document.querySelector('.global-dark-toggle__emoji');
const textEl = document.querySelector('.global-dark-toggle__text');
if (!emojiEl || !textEl) return;
if (theme === 'dark') {
emojiEl.textContent = '🌙';
textEl.textContent = 'Dark';
} else {
emojiEl.textContent = '☀️';
textEl.textContent = 'Light';
}
}
function setGlobalTheme(theme) {
if (theme === 'dark') {
document.documentElement.setAttribute('data-theme', 'dark');
document.documentElement.classList.add('dark');
document.body.classList.remove('light');
} else {
document.documentElement.removeAttribute('data-theme');
document.documentElement.classList.remove('dark');
document.body.classList.add('light');
}
localStorage.setItem('theme', theme);
localStorage.setItem('exchangeTheme', theme); // for backwards compat
}
function getGlobalTheme() {
return localStorage.getItem('theme') || localStorage.getItem('exchangeTheme') || 'dark';
}
function bindThemeToggle() {
const toggle = document.querySelector('[data-role="global-theme-toggle"]');
if (!toggle) return;
toggle.addEventListener('click', () => {
// Don't call window.toggleDarkMode anymore because it causes state desync.
// We take full control of the global theme here.
const current = getCurrentTheme();
const next = current === 'dark' ? 'light' : 'dark';
setGlobalTheme(next);
// If the page has a specific app-level override, trigger it
if (typeof window.setTheme === 'function' && window.location.pathname === '/') {
window.setTheme(next);
}
setTimeout(() => updateToggleLabel(getCurrentTheme()), 0);
});
updateToggleLabel(getCurrentTheme());
}
function initHeader() {
const activeKey = determineActiveKey(window.location.pathname);
const headerHTML = buildHeader(activeKey);
@@ -135,8 +59,6 @@
} else {
document.body.insertAdjacentHTML('afterbegin', headerHTML);
}
bindThemeToggle();
}
if (document.readyState === 'loading') {

View File

@@ -30,22 +30,6 @@
--code-text: #e6edf3;
}
/* Light mode */
body.light {
--primary-color: #2563eb;
--secondary-color: #7c3aed;
--accent-color: #0ea5e9;
--success-color: #10b981;
--warning-color: #f59e0b;
--danger-color: #ef4444;
--text-dark: #1f2937;
--text-light: #6b7280;
--bg-light: #f9fafb;
--bg-white: #ffffff;
--border-color: #e5e7eb;
--code-bg: #1f2937;
--code-text: #e5e7eb;
}
/* ============================================
Base Styles

View File

@@ -51,12 +51,6 @@
<a href="/Exchange/" class="global-nav__link">Exchange</a>
<a href="/docs/index.html" class="global-nav__link">Docs</a>
</nav>
<div class="global-header__actions">
<button class="global-dark-toggle" data-role="global-theme-toggle" title="Toggle dark mode">
<span class="global-dark-toggle__emoji">🌙</span>
<span class="global-dark-toggle__text">Dark</span>
</button>
</div>
</div>
</header>