openpencil/packages/core
Chris Gliddon 0f875eee46
feat(canvas): default canvas bg to dark on prefers-color-scheme: dark (#205)
A user on a dark OS who launches OpenPencil currently gets a pure-white
canvas flash into their dark desktop every time — visually jarring and
eye-straining in low light. Upstream has no theme system at all, so
this change defers to the OS `prefers-color-scheme` for newly-created
pages only.

Changes:

- Add `CANVAS_BG_COLOR_DARK` (#2c2c2c, matching Figma's dark-mode
  canvas) next to the existing light `CANVAS_BG_COLOR`.
- Add `getDefaultCanvasBgColor()` helper that reads
  `matchMedia('(prefers-color-scheme: dark)')` once per call.
- Use the helper in `editor/create.ts` (initial editor state) and
  `editor/pages.ts` (page-switch reset). Both are new-page
  initializers.

Deliberately untouched:

- `io/formats/fig/export.ts` still writes the static light
  `CANVAS_BG_COLOR` as the page `backgroundColor`. If a dark-theme
  user's exports forced darkness on recipients, files wouldn't be
  portable. The serialization path stays neutral.
- `canvas/renderer.ts` default — only a fallback when state is
  missing `pageColor`; effectively dead once `create.ts` runs.
- Per-page ColorInput in `PageSection.vue` remains the manual
  override for any user preference.

Companion colors (rulers, selection, snap) were already dark-
friendly values and need no adjustment — rulers become slightly more
legible on dark canvas than they were on light.

Tested on Arch + KDE Plasma (dark) + WebKit2GTK 2.52 + Mesa 26:
new pages render ~#2c2c2c, switching to light OS theme flips back
to #f5f5f5 on next launch, saved-and-reopened files keep the light
export value (confirming the serialization boundary).
2026-04-20 11:44:50 +03:00
..
assets Refactor font loading: DRY up local font lookup, fix headless fallback 2026-03-16 13:38:16 +03:00
src feat(canvas): default canvas bg to dark on prefers-color-scheme: dark (#205) 2026-04-20 11:44:50 +03:00
package.json fix(layout): bump yoga-layout to 3.3.0-grid.3 with Node.free() support 2026-04-13 12:09:45 +03:00
tsconfig.json Fix core release build config 2026-03-30 18:54:18 +03:00
tsdown.config.ts Release v0.11.6 2026-04-08 22:04:22 +03:00