feat: replace dark mode button with Material Design toggle switch#893
feat: replace dark mode button with Material Design toggle switch#893emuehlstein wants to merge 1 commit intoKpa-clawbot:masterfrom
Conversation
Replaces the single-icon <button> with a <label>-wrapped checkbox toggle switch (pill design with sun/moon icons). The slider position visually communicates current state, eliminating the ambiguity of a single emoji button. Changes: - public/index.html: <button#darkModeToggle> → <label#darkModeToggle> with hidden checkbox, track, thumb, and sun/moon icon spans - public/style.css: add .theme-toggle component (all CSS variables, no hardcoded hex), 44px touch target, smooth 200ms transitions - public/app.js: listen on checkbox 'change' event; fallback to button click handler if checkbox element is absent (backward compat) - test-e2e-playwright.js: update dark mode test to click #darkModeToggle directly (works for both label and button); legacy button emoji scan kept as fallback for upstream compatibility All colors via CSS variables (--border, --accent, --nav-text). npm test: 596 passed, 1 pre-existing failure unrelated to this change.
75be7f9 to
06d089b
Compare
|
currently live at https://dev-scope.chicagooffline.com/ |
PR #893 Expert Review — Dark Mode Toggle SwitchPR: #893 Verdict: ✅ APPROVEClean, well-scoped UI change. No security concerns. Minor accessibility nit below. Security Review (External Fork — Extra Paranoia)
Verdict: Zero security findings. This PR touches only presentation layer (CSS, HTML structure, one JS event listener swap). No attack surface introduced. Code QualityMust-fix: NoneNon-blocking observations (not blocking merge):
Summary
Recommendation: Merge as-is. Accessibility improvement can be a follow-up. |
Summary
Replaces the single-icon dark mode button (☀️) with a Material Design-style toggle switch using sun/moon icons.
Motivation
The current dark mode button uses a single emoji (☀️/🌙) that swaps on click. This has a UX ambiguity problem: does ☀️ mean "click for light mode" or "you're currently in light mode"? Users must click to find out.
Per Material Design 3 Switch guidelines, switches are the recommended component for binary settings because the toggle position visually communicates the current state. A pill-style toggle with sun/moon icons eliminates the ambiguity — the slider position shows which mode is active.
Changes
public/index.html— Replace<button>with<label>containing a hidden checkbox, track, thumb, and sun/moon icon spans. Theid="darkModeToggle"is preserved on the outer label for backward compatibility with any external references.public/style.css— Add.theme-togglecomponent styles: track, thumb, icons with CSS transitions. All colors use CSS variables (--border,--accent,--nav-text) per project theming conventions. No hardcoded hex values.public/app.js— Listen onchangeevent of the checkbox instead ofclickon the button. Includes fallback: ifdarkModeCheckboxelement is missing (e.g., older cached HTML), the original button click handler still works.Design Details
--bordercolor (unchecked) /--accent(checked)--nav-textfor contrastaria-label="Toggle dark mode"on the label, checkbox isaria-hidden="true"(decorative, the label is the accessible element)Testing
npm testpasses (596/596 on frontend helpers, 62/62 on packet-filter, 29/29 on aging). One pre-existing failure on bug: Packet Byte Breakdown — hop offsets and values don't match raw_hex (uses aggregated pathHops instead of per-observer path) #844 (byte breakdown hop count) — unrelated.Browser Validation
Tested on dev-scope.chicagooffline.com (Chromium). Toggle appears in nav bar, slides between sun/moon, persists theme to localStorage, respects existing
meshcore-themesaved preference on page load.No New Dependencies
Pure CSS + vanilla JS. No build step changes. No new npm packages.