Skip to content

fix: add a visible theme toggle to the viewer#81

Merged
paolino merged 2 commits intomainfrom
fix/theme-toggle-ui-80
Apr 23, 2026
Merged

fix: add a visible theme toggle to the viewer#81
paolino merged 2 commits intomainfrom
fix/theme-toggle-ui-80

Conversation

@paolino
Copy link
Copy Markdown
Contributor

@paolino paolino commented Apr 23, 2026

Closes #80

What changed

This adds a visible dark/light theme toggle to the shared viewer controls so embedded deployments such as Cardano Knowledge Maps expose an in-page way to switch themes.

The change keeps the project aligned with the constitution:

  • theme selection and persistence now live in PureScript viewer state
  • JavaScript remains thin browser FFI for reading system theme and applying the resolved theme to document.documentElement
  • the static HTML bootstrap only handles first-paint theme resolution from ?theme= or persisted preference so the page does not flash in the wrong theme before Halogen mounts

Implementation notes

  • added theme to viewer state plus a ToggleTheme action
  • render a compact theme button in the controls row
  • initialize theme from URL override, then persisted preference, then system theme
  • persist manual theme changes in localStorage
  • keep the URL param in sync when the user toggles so links remain shareable and explicit overrides still work
  • added thin FFI.Theme and extended FFI.Url with getThemeParam / setThemeParam

Verification

  • nix develop --quiet -c just test
  • nix develop --quiet -c just bundle-lib
  • headless Chromium check against the built viewer loaded with Cardano Knowledge Maps data:
    • default load renders .theme-toggle-btn
    • clicking the button flips data-theme and updates ?theme=
    • loading ?theme=dark shows with title Switch to light theme

Reviewer focus

  • confirm the control placement in the top-left viewer controls is acceptable for both app and lib variants
  • confirm persisting explicit dark/light selection is preferable to cycling through an auto mode in the UI
  • confirm downstream consumers only need a rebuild/redeploy to pick up the new control

paolino added 2 commits April 23, 2026 17:01
Adds spec 012 covering expand/collapse node shaping with anchor
semantics, no global re-layout, affordance indicator, and reset.
Portability of shaped views is deferred to spec 013 (#77).
@paolino paolino added the bug Something isn't working label Apr 23, 2026
@paolino paolino self-assigned this Apr 23, 2026
@paolino paolino merged commit 848e13c into main Apr 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a visible dark/light theme toggle to the viewer UI

1 participant