| @@ -6,7 +6,7 @@ |
| 6 | <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> | 6 | <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
| 7 | <title>Glean</title> | 7 | <title>Glean</title> |
| 8 | <script> | 8 | <script> |
| 9 | - (function(){var p=localStorage.getItem('theme')||'system';var r=p==='system'?(window.matchMedia('(prefers-color-scheme:dark)').matches?'dark':'light'):p;document.documentElement.setAttribute('data-theme',r)})(); | 9 | + (function(){var p=localStorage.getItem('theme')||(window.matchMedia('(prefers-color-scheme:dark)').matches?'dark':'light');document.documentElement.setAttribute('data-theme',p)})(); |
| 10 | </script> | 10 | </script> |
| 11 | <link rel="stylesheet" href="/static/output.css"> | 11 | <link rel="stylesheet" href="/static/output.css"> |
| 12 | <script src="/static/htmx.min.js"></script> | 12 | <script src="/static/htmx.min.js"></script> |
| @@ -195,10 +195,8 @@ |
| 195 | <button onclick="toggleTheme()" class="text-xs text-spot-secondary hover:text-spot-text hover:underline inline-flex gap-1.5 items-center transition text-left"> | 195 | <button onclick="toggleTheme()" class="text-xs text-spot-secondary hover:text-spot-text hover:underline inline-flex gap-1.5 items-center transition text-left"> |
| 196 | <svg class="w-3.5 h-3.5 shrink-0 theme-icon-dark" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"/></svg> | 196 | <svg class="w-3.5 h-3.5 shrink-0 theme-icon-dark" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"/></svg> |
| 197 | <svg class="w-3.5 h-3.5 shrink-0 theme-icon-light hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"/></svg> | 197 | <svg class="w-3.5 h-3.5 shrink-0 theme-icon-light hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"/></svg> |
| 198 | - <svg class="w-3.5 h-3.5 shrink-0 theme-icon-system hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25A2.25 2.25 0 0 1 5.25 3h13.5A2.25 2.25 0 0 1 21 5.25Z"/></svg> | | |
| 199 | <span class="theme-text-dark">Dark</span> | 198 | <span class="theme-text-dark">Dark</span> |
| 200 | <span class="theme-text-light hidden">Light</span> | 199 | <span class="theme-text-light hidden">Light</span> |
| 201 | - <span class="theme-text-system hidden">System</span> | | |
| 202 | </button> | 200 | </button> |
| 203 | <button onclick="document.getElementById('shortcuts-dialog').showModal()" class="text-xs text-spot-secondary hover:text-spot-text hover:underline inline-flex gap-1.5 items-center transition text-left"> | 201 | <button onclick="document.getElementById('shortcuts-dialog').showModal()" class="text-xs text-spot-secondary hover:text-spot-text hover:underline inline-flex gap-1.5 items-center transition text-left"> |
| 204 | <svg class="w-3.5 h-3.5 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m6.75 7.5 3 2.25-3 2.25m4.5 0h3m-9 8.25h13.5A2.25 2.25 0 0 0 21 18V6a2.25 2.25 0 0 0-2.25-2.25H5.25A2.25 2.25 0 0 0 3 6v12a2.25 2.25 0 0 0 2.25 2.25Z"/></svg> | 202 | <svg class="w-3.5 h-3.5 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m6.75 7.5 3 2.25-3 2.25m4.5 0h3m-9 8.25h13.5A2.25 2.25 0 0 0 21 18V6a2.25 2.25 0 0 0-2.25-2.25H5.25A2.25 2.25 0 0 0 3 6v12a2.25 2.25 0 0 0 2.25 2.25Z"/></svg> |
| @@ -231,10 +229,8 @@ |
| 231 | <button onclick="toggleTheme()" class="text-xs text-spot-secondary hover:text-spot-text inline-flex gap-1.5 items-center transition"> | 229 | <button onclick="toggleTheme()" class="text-xs text-spot-secondary hover:text-spot-text inline-flex gap-1.5 items-center transition"> |
| 232 | <svg class="w-3.5 h-3.5 theme-icon-dark" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"/></svg> | 230 | <svg class="w-3.5 h-3.5 theme-icon-dark" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"/></svg> |
| 233 | <svg class="w-3.5 h-3.5 theme-icon-light hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"/></svg> | 231 | <svg class="w-3.5 h-3.5 theme-icon-light hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"/></svg> |
| 234 | - <svg class="w-3.5 h-3.5 theme-icon-system hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25A2.25 2.25 0 0 1 5.25 3h13.5A2.25 2.25 0 0 1 21 5.25Z"/></svg> | | |
| 235 | <span class="theme-text-dark">Dark</span> | 232 | <span class="theme-text-dark">Dark</span> |
| 236 | <span class="theme-text-light hidden">Light</span> | 233 | <span class="theme-text-light hidden">Light</span> |
| 237 | - <span class="theme-text-system hidden">System</span> | | |
| 238 | </button> | 234 | </button> |
| 239 | </div> | 235 | </div> |
| 240 | <div class="border-t border-spot-divider mt-4 pt-3"> | 236 | <div class="border-t border-spot-divider mt-4 pt-3"> |
| @@ -248,17 +244,12 @@ |
| 248 | </main> | 244 | </main> |
| 249 | | 245 | |
| 250 | <script> | 246 | <script> |
| 251 | - var themePref = localStorage.getItem('theme') || 'system'; | 247 | + var themePref = localStorage.getItem('theme') || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); |
| 252 | - var modes = ['dark', 'light', 'system']; | | |
| 253 | - | | |
| 254 | - function resolveTheme(pref) { | | |
| 255 | - return pref === 'system' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : pref; | | |
| 256 | - } | | |
| 257 | | 248 | |
| 258 | function applyTheme() { | 249 | function applyTheme() { |
| 259 | - document.documentElement.setAttribute('data-theme', resolveTheme(themePref)); | 250 | + document.documentElement.setAttribute('data-theme', themePref); |
| 260 | - var next = modes[(modes.indexOf(themePref) + 1) % 3]; | 251 | + var next = themePref === 'dark' ? 'light' : 'dark'; |
| 261 | - modes.forEach(function(m) { | 252 | + ['dark', 'light'].forEach(function(m) { |
| 262 | var show = m === next; | 253 | var show = m === next; |
| 263 | document.querySelectorAll('.theme-icon-' + m + ', .theme-text-' + m).forEach(function(el) { | 254 | document.querySelectorAll('.theme-icon-' + m + ', .theme-text-' + m).forEach(function(el) { |
| 264 | el.classList.toggle('hidden', !show); | 255 | el.classList.toggle('hidden', !show); |
| @@ -267,15 +258,11 @@ |
| 267 | } | 258 | } |
| 268 | | 259 | |
| 269 | function toggleTheme() { | 260 | function toggleTheme() { |
| 270 | - themePref = modes[(modes.indexOf(themePref) + 1) % 3]; | 261 | + themePref = themePref === 'dark' ? 'light' : 'dark'; |
| 271 | localStorage.setItem('theme', themePref); | 262 | localStorage.setItem('theme', themePref); |
| 272 | applyTheme(); | 263 | applyTheme(); |
| 273 | } | 264 | } |
| 274 | | 265 | |
| 275 | - window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function() { | | |
| 276 | - if (themePref === 'system') applyTheme(); | | |
| 277 | - }); | | |
| 278 | - | | |
| 279 | applyTheme(); | 266 | applyTheme(); |
| 280 | | 267 | |
| 281 | window.addEventListener('pageshow', function(e) { | 268 | window.addEventListener('pageshow', function(e) { |