UI: light/dark switch in the header (operator request)
The design system already renders light when the browser prefers it; this adds the same ☀ button Gandalf has (lt.theme.toggle). The choice is remembered per browser (localStorage) and synced across tabs; until it is used, the browser's preference still decides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
51afe4b69f
commit
c04227a763
2 files changed
+9
-1
No files matched your search
@@ -145,6 +145,7 @@ def test_needs_attention_page(store):
|
||||
assert 'Loki: <strong>blind</strong>' in html and 'HTTP 500' in html
|
||||
assert 'On the timeline only' in html and 'monitor-01 slow' in html # unexplained symptom
|
||||
assert 'Last 7 days' in html and 'storage-01 oom' in html
|
||||
assert 'id="lt-theme-btn"' in html and 'lt.theme.toggle()' in html # light/dark switch
|
||||
|
||||
|
||||
def test_incident_and_known_pages(store):
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
</nav>
|
||||
</div>
|
||||
<div class="lt-header-right">
|
||||
<button type="button" class="lt-theme-btn" id="lt-theme-btn"
|
||||
aria-label="Switch between light and dark mode" title="Light or dark mode">☀</button>
|
||||
{% if user.name %}<span class="lt-header-user">{{ user.name }}</span>{% endif %}
|
||||
{% if 'admin' in user.groups %}<span class="lt-badge-admin">admin</span>{% endif %}
|
||||
</div>
|
||||
@@ -64,7 +66,12 @@
|
||||
</footer>
|
||||
|
||||
<script nonce="{{ nonce }}">
|
||||
document.addEventListener('DOMContentLoaded', function () { lt.init({ skipBoot: true }); });
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
lt.init({ skipBoot: true });
|
||||
// Light or dark: follows the browser until chosen here, then remembered (same as Gandalf).
|
||||
var themeBtn = document.getElementById('lt-theme-btn');
|
||||
if (themeBtn) themeBtn.addEventListener('click', function () { lt.theme.toggle(); });
|
||||
});
|
||||
</script>
|
||||
{% block scripts %}{% endblock %}
|
||||
</body>
|
||||
|
||||
Reference in new issue
Block a user