8000 Dark scheme and the Light | Dark | System choice by kiran-brahma · Pull Request #81 · kiran-brahma/writing-tool · GitHub
[go: up one dir, main page]

Skip to content

Dark scheme and the Light | Dark | System choice - #81

Merged
kiran-brahma merged 1 commit into
v1.3from
v1.3-62
Sep 26, 2026
Merged

kiran-brahma merged 1 commit into
v1.3from
v1.3-62

Conversation

@kiran-brahma
Copy link
Copy Markdown
Owner

Part of #57. Closes #62.

What changed

  • Dark values for every colour name (src/index.css). The page is a warm dark paper (#1f1d1a) a step above the ground (#191816), not black (story 206). Ink is light and never pure white. An ink fill becomes a light fill, with on-ink dark on it. Marks are still amber, now a deep amber wash with a bright underline so ink stays readable on them. Blue pencil comes in The mark: blue pencil, underlined at rest #64. The dark block is written once through a dark custom variant that expands to @media (prefers-color-scheme: dark) :root:not([data-theme=light]) and :root[data-theme=dark]. color-scheme follows, so native controls and scrollbars match too.
  • Light | Dark | System in AI Settings, in a new "Colour scheme" panel. System is the default. With System, no attribute is set and the stylesheet follows the OS by itself. Light or Dark sets data-theme on <html> (src/settings/useColorScheme.ts). Nothing is mirrored into localStorage.
  • resolveColorScheme(setting, systemPrefersDark) and isColorSchemeSetting in src/core/colorScheme.ts.
  • colorScheme key in the existing settings store. It is normalised on load, so an unknown value becomes System, and it travels in a Backup. No Dexie migration.
  • theme-color: index.html now has two metas, one per prefers-color-scheme, set to the ground colour of each scheme. The hook gives each meta the resolved colour, so with System the browser switches between them with no script. public/manifest.webmanifest's static theme_color is left as it was.
  • Root background and ring offset: html is painted with ground, and --tw-ring-offset-color defaults to paper. In dark, an ink-filled control's ring-offset-2 is no longer a white band. Light looks the same, because paper is white there.
  • New agent gate scripts/gates/palette.mjs, listed as "no palette colour class in the UI source". It reads string and template literals in src/**/*.{ts,tsx} (tests excluded). It flags any palette class, whatever its variant or opacity (hover:bg-stone-100/60, text-white, ring-offset-white …), and any palette variable (--color-stone-100).

Acceptance criteria

  • resolveColorScheme(setting, systemPrefersDark) is tested over the full table. Verified: src/core/colorScheme.test.ts covers all 6 rows and asserts the table covers every setting.
  • The colorScheme key saves, loads, and normalises an unknown value to System. Verified: src/storage/settings.test.ts, same style as the existing keys. A Backup → Restore round-trip test is also in src/storage/durability.test.ts.
  • With System, changing the OS scheme changes the app live, and reload shows no flash. Verified in headless Chromium with emulateMedia. Switching light → dark with no reload changed --color-ground and color-scheme at once, and data-theme stayed absent. On a reload with a dark OS, the root was already dark (#191816, color-scheme: dark) at DOMContentLoaded, before settings were read. Only checked against the dev server, where Vite injects the CSS through JS. In a production build the stylesheet is a blocking <link>, so it should hold there too, but that was not measured separately.
  • Light and Dark override the OS, and the choice survives reload and Backup → Restore. Verified: Light on a dark OS and Dark on a light OS each held after a reload. I backed up with Dark, switched to Light and restored the file, and Dark came back (data-theme="dark"). Setting System again removed the attribute.
  • theme-color matches the scheme. Verified: both metas read #fafaf9 under Light and #191816 under Dark. Under System each keeps its own colour.
  • Story 187's contrast minimums hold in dark. Verified: computed from rendered colours composited over their real backgrounds. The Rail's muted text has a minimum of 6.58:1, on the sunk group headers, and 6.6–9.1:1 elsewhere. A disabled Pass name ("George Orwell's rules" toggled off, muted-ink, 14px) on paper is 7.48:1. faint-ink on paper is 6.12:1.
  • The agent gate rejects a raw palette class added to UI source, and passes on the tree. Verified: pnpm run gates is clean on the tree. Adding a probe file with hover:bg-stone-100 failed the gate (exit 1, file and line reported), and the probe was then removed. Unit tests are in scripts/gates/palette.test.mjs.
  • Every screen checked by eye in both schemes at 1440px. Verified in headless Chromium: Editor with Highlights and an open Callout, the Rail's Structure / Paragraph / Word / All tabs with Judge, Milestones and Revisions, Library, Pass workbench, AI Settings (including the new panel), How this works and Privacy. I also looked at the focus ring on an ink button in dark.

pnpm test (1069 passed), pnpm typecheck, pnpm run gates and pnpm build all pass.

Notes

  • A disabled ink button (disabled:bg-rule text-on-ink, e.g. the Judge button with nothing selected) is low-contrast in dark, as it already is in light. It is disabled, so it was left alone.
  • There are no new domain terms. "Colour scheme" is a UI label, not a glossary concept.

🤖 Generated with Claude Code


Generated by Claude Code

Every colour name gains a dark value: a warm dark paper, not black, with
light ink that is never pure white. The Writer chooses Light, Dark or
System in AI Settings. System is the default: no attribute is set and the
stylesheet follows prefers-color-scheme itself, live and with no flash.
Light or Dark sets data-theme on the root element.

The choice is the colorScheme key in the existing settings store,
normalised on load (unknown -> System), carried in a Backup. No Dexie
migration. resolveColorScheme names the resolved scheme for the two
theme-color metas, which now follow the scheme. The root is the ground
colour, and a focus ring's offset follows paper, so an ink-filled
control's ring in dark has no white band.

A new agent gate fails the build on a raw palette colour class or
palette variable in UI source.

Part of #57. Closes #62.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FjB3Gu8vhg5enkAneTdqga
@chatgpt-codex-connector
chatgpt-codex-connector Bot commented Sep 26, 2026 •
Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-09-26T10:13:23.161138Z 2fda7d2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

2 participants

0