Skip to content

Respect the system color scheme - #120

Open
diwash007 wants to merge 2 commits into
karakanb:masterfrom
diwash007:feat/system-theme
Open

diwash007 wants to merge 2 commits into
karakanb:masterfrom
diwash007:feat/system-theme

Conversation

@diwash007

Copy link
Copy Markdown

Summary

The theme only had an on/off night mode toggle. The OS preference was read once on first load and then pinned by the persisted state, so devo never followed later system appearance changes.

This replaces the toggle with a Light / System / Dark control (System is the default):

  • System follows prefers-color-scheme and updates live when the OS appearance changes, with no reload.
  • Light / Dark override the OS.
  • Users who explicitly toggled night mode before keep that choice as Light or Dark.

The existing isNightMode state is still derived and used, so cards, selects and styles are unchanged.

Also: feed failures no longer spin forever

While testing, the Product Hunt card loaded forever and the dev server showed a Failed to fetch overlay. devo.ams3.digitaloceanspaces.com/producthunt.json currently returns 404, and designernews.co/api/v2/stories does too. Cards now treat non-OK responses as failures and show "Couldn't load X. Retry" instead of an endless spinner. The feeds themselves still need fixing or replacing.

Testing

  • npm run lint passes.
  • npm test: 16 pass, including 6 new tests in tests/unit/themeMode.spec.js. They cover the System default, live OS changes, explicit overrides, migration of the old toggle, a stale persisted value on reload, and invalid modes.
  • Manual check in Chrome on the dev server, emulating OS light and dark: the theme follows the OS live in System mode, Light and Dark override it, and the choice persists across reloads.

Add a three-way Light / System / Dark theme control in place of the
on/off night mode toggle, with System as the default.

In System mode the app follows prefers-color-scheme and reacts live
when the OS appearance changes. Previously the OS preference was read
only once, and the persisted state then pinned that value forever.

Users who explicitly toggled night mode before keep that choice as
Light or Dark.
A failed or non-2xx feed request used to reject unhandled, leaving the
card loading forever (and triggering the dev-server error overlay).
Treat non-OK responses as failures, and show a retry message on the
card.

Product Hunt and Designer News feed URLs currently return 404.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant