A light / dark / system switch in the header, instead of a trip to Your details #9
Labels
No labels
accessibility
authentication
breaking change
bug
documentation
enhancement
interface
internationalisation
observability
security
tier
1
tier
2
tier
3
tier/4
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
Depends on
Reference
Postulo/postulo#9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Observation
What exists today: more than it looks
The preference exists, and everything beneath the switch is built:
Profile.themewith three values — system, light, dark — default system (accounts/models.py:Themeat line 76, the field at line 125).core/context_processors.py) resolves it toui_theme, andbase.htmlstamps it asdata-themeon<html>(line 2); "system" stamps nothing.darkvariant (assets/css/app.css) honours an explicitdata-themefirst andprefers-color-schemeotherwise, so all three states already behave correctly.What is missing is the control. Today the only way to change theme is Your details, the Theme select, Save (
accounts/forms.py, line 53) — a trip nobody makes to flip a switch. The header's right cluster (base.html, line 57) holds Capture, Record, the display name and Sign out, nothing else.So this issue is: a switch in that cluster, drawn with #8's icons, writing to the field that already exists.
Shape
sun,moonandmonitorin turn, with the current state and the next one in atitleand a visually hidden label ("Theme: dark. Switch to match the operating system"). A three-segment control is the alternative — clearer, and wider than a phone header can spare.Profile.theme, called from the button through htmx, with a plain form as the no-script fallback. The choice then follows the account to every device, and the server renders the rightdata-themeon the next load — no flash of the wrong theme, which is the classic failure of client-only toggles.static/js/app.js, the same pattern asdata-autosubmit, flipsdata-themeon<html>the moment the button is pressed, before the request returns. No inline script: the CSP isscript-src 'self'and the existing file is already the place for this.app.cssnever setscolor-scheme. Worth checking on the ragnar instance: withoutcolor-scheme: darkon the root when the dark theme is active, scrollbars,<select>popups and the date picker most likely keep their light chrome. A one-line rule keyed on the samedata-themeand media query as the variant fixes it, and is wanted with or without the switch.Classification
Enhancement. Not breaking: the field exists, the default is unchanged, and the select on Your details stays for anyone who prefers it.
Depends on
#8 for the sun, moon and monitor icons. It could ship first with three pasted SVGs, but that is precisely the ad-hoc icon use #8 exists to prevent.
Open questions