feat: 12 UI improvements batch - 1. Editor surface flush (no margin/border, Google Docs style) - 2. Custom styled summary slider (gradient thumb) - 3. Empty states with icons for suggestions - 4. Enhanced status bar (chars, sentences, reading time) - 5. Mobile scrollable formatting toolbar - 6. Summary word count + compression ratio - 7. Document search bar with filter - 8. Text color + highlight color pickers - 9. Lists (bullet/ordered) + indent/outdent + clear format - 10. Animated sun/moon theme toggle - 11. Summary bullet points mode toggle - 12. Print styles (only editor content)
afdf449 | // Bayan theme system — dark/light with localStorage persistence | |
| const THEME_KEY = 'bayan-theme'; | |
| function getPreferredTheme() { | |
| const stored = localStorage.getItem(THEME_KEY); | |
| if (stored === 'light' || stored === 'dark') return stored; | |
| return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; | |
| } | |
| function updateThemeToggleIcon(theme) { | |
| const btn = document.getElementById('theme-toggle'); | |
| if (!btn) return; | |
| const isDark = theme === 'dark'; | |
| btn.setAttribute('aria-pressed', isDark ? 'true' : 'false'); | |
| btn.setAttribute( | |
| 'aria-label', | |
| isDark ? 'التبديل إلى الوضع الفاتح' : 'التبديل إلى الوضع الداكن' | |
| ); | |
| // CSS handles the sun/moon icon transitions via [data-theme] selectors | |
| } | |
| function clearThemePaletteOverrides() { | |
| const root = document.documentElement; | |
| const themeManaged = [ | |
| '--color-bg', '--color-surface', '--color-surface-elevated', '--color-editor', | |
| '--color-text-primary', '--color-text-secondary', '--color-text-muted', | |
| '--background-color', '--surface-color', '--text-color', '--text-secondary' | |
| ]; | |
| themeManaged.forEach((prop) => root.style.removeProperty(prop)); | |
| } | |
| function setTheme(theme) { | |
| document.documentElement.setAttribute('data-theme', theme); | |
| localStorage.setItem(THEME_KEY, theme); | |
| clearThemePaletteOverrides(); | |
| updateThemeToggleIcon(theme); | |
| // Notify settings-sync so the change can be persisted to cloud | |
| window.dispatchEvent(new CustomEvent('bayan:themechange', { detail: { theme } })); | |
| } | |
| function toggleTheme() { | |
| const current = document.documentElement.getAttribute('data-theme') || 'dark'; | |
| setTheme(current === 'dark' ? 'light' : 'dark'); | |
| } | |
| function initTheme() { | |
| setTheme(getPreferredTheme()); | |
| const btn = document.getElementById('theme-toggle'); | |
| if (btn) { | |
| btn.addEventListener('click', toggleTheme); | |
| } | |
| } | |
| // Apply theme before paint to avoid flash | |
| (function applyThemeEarly() { | |
| try { | |
| const stored = localStorage.getItem(THEME_KEY); | |
| const theme = stored === 'light' || stored === 'dark' | |
| ? stored | |
| : (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); | |
| document.documentElement.setAttribute('data-theme', theme); | |
| } catch (_) { | |
| document.documentElement.setAttribute('data-theme', 'dark'); | |
| } | |
| })(); | |