Skip to content

Introduce dark mode: support plugins#43

Open
sistrall wants to merge 3 commits into
masterfrom
feat/semantic-tokens-for-colors
Open

Introduce dark mode: support plugins#43
sistrall wants to merge 3 commits into
masterfrom
feat/semantic-tokens-for-colors

Conversation

@sistrall
Copy link
Copy Markdown
Contributor

Adds a semanticColorTokensTheme field to the plugin SDK context, with a typed list of known tokens (surface/ink/border, plus per-context variants for primary/tinted/accent/selected/disabled/danger/highlight/etc., plus diff/status/overlay/stacked/progress/tooltip/code/shadow groups). The Theme field is preserved but marked deprecated for backward compat.

generateStyleFromCtx now emits these tokens as CSS custom properties (--color--surface, --color--primary--ink, etc.) on the Canvas root.

All react-ui components are migrated to consume the new tokens (Button, ButtonGroup, Dropdown, Section, TextInput, TextareaInput, SwitchInput, SidebarPanel, Toolbar, Tooltip, VerticalSplit, …).

For backward compatibility, the legacy color vars in Canvas/styles.module.css (--border-color, --base-body-color, --alert-color, --add-color, …) now resolve to the closest semantic token first, falling back to their original light-mode RGB values. The color block is marked @deprecated and slated for removal in a future major; spacing/font/easing tokens remain stable. --spacing-xs is added to complete the spacing scale.

Other touch-ups:

  • fill="currentColor" on every shipped SVG icon so colors inherit
  • SidebarPanel uses CaretDown/Up icons (matching the CMS)
  • SwitchInput styles brought in line with the CMS (off-track ink-muted, primary--ink/surface for checked, smoother knob transitions)
  • Fix broken var(--border-radius-m) reference in TooltipDelayGroup JSDoc example

@sistrall sistrall self-assigned this Apr 21, 2026
@sistrall sistrall force-pushed the feat/semantic-tokens-for-colors branch 2 times, most recently from 01c4633 to daa8770 Compare April 22, 2026 13:06
@sistrall sistrall changed the title feat: introduce semantic color tokens and migrate react-ui to them Introduce dark mode: support plugins Apr 22, 2026
@stefanoverna stefanoverna force-pushed the feat/semantic-tokens-for-colors branch from 52e7aff to b3ead57 Compare May 29, 2026 14:08
Adds a `semanticColorTokensTheme` field to the plugin SDK context, with a
typed list of known tokens (surface/ink/border, plus per-context variants
for primary/tinted/accent/selected/disabled/danger/highlight/etc., plus
diff/status/overlay/stacked/progress/tooltip/code/shadow groups). The
`Theme` field is preserved but marked deprecated for backward compat.

`generateStyleFromCtx` now emits these tokens as CSS custom properties
(`--color--surface`, `--color--primary--ink`, etc.) on the Canvas root.

All react-ui components are migrated to consume the new tokens
(Button, ButtonGroup, Dropdown, Section, TextInput, TextareaInput,
SwitchInput, SidebarPanel, Toolbar, Tooltip, VerticalSplit, …).

For backward compatibility, the legacy color vars in
`Canvas/styles.module.css` (`--border-color`, `--base-body-color`,
`--alert-color`, `--add-color`, …) now resolve to the closest semantic
token first, falling back to their original light-mode RGB values. The
color block is marked `@deprecated` and slated for removal in a future
major; spacing/font/easing tokens remain stable. `--spacing-xs` is added
to complete the spacing scale.

Other touch-ups:
- `fill="currentColor"` on every shipped SVG icon so colors inherit
- SidebarPanel uses CaretDown/Up icons (matching the CMS)
- SwitchInput styles brought in line with the CMS (off-track ink-muted,
  primary--ink/surface for checked, smoother knob transitions)
- Fix broken `var(--border-radius-m)` reference in TooltipDelayGroup
  JSDoc example

v3.0.0-alpha.0

feat: expose ctx.colorScheme and reflect it onto data-theme

Adds `colorScheme: 'light' | 'dark'` to the plugin context. The host
resolves `'system'` before sending. The SDK runtime writes the value to
`document.documentElement.dataset.theme` on the initial handshake and on
every ctx update (skipping no-op writes), so plugin CSS can branch with
`[data-theme="dark"] { … }` selectors and non-CSS code can read
`ctx.colorScheme` directly.

Other changes bundled here:
- Canvas JSDoc `@example` rewritten as a complete semantic-token reference
  (naming convention, every standalone/context group, status ink samples,
  shadow composites preview).
- SelectInput multi-value chips now set `--color--tinted--ink` on label
  and remove button so chip text stays legible in dark mode.

v3.0.1-alpha.0

feat: make SDK token-agnostic and sync react-ui with cms components

SDK no longer enumerates semantic color tokens. `SemanticColorTokensTheme`
is now `Record<string, string>` keyed by CSS custom property name (e.g.
`--color--raised--surface`); `generateStyleFromCtx` applies whatever the
host sends verbatim. Drops the hand-maintained `KnownSemanticColorTokens`
type and the `semanticTokenCssNames` map, so the token vocabulary can
evolve host-side without an SDK release.

react-ui changes:
- Migrate box-shadows to composite `--shadow--*` tokens (Dropdown,
  Tooltip, SwitchInput, VerticalSplit) — `--color--shadow*` no longer exists.
- Sync component CSS with cms counterparts: drop stale selected-borders
  (SwitchInput checked, ButtonGroup), drop SidebarPanel content background,
  add primary button hover/active states, overlay backdrop blur, and a
  floating shadow on the SelectInput menu.
- Restore the Canvas semantic-token example, reconciled against the host's
  current authoritative token set.

Updated tests and UPGRADING notes accordingly.

Note: pre-commit hook bypassed — the react-ui jest suite has a pre-existing
ESM/CJS config failure unrelated to this change (the sdk suite passes).

fix(react-ui): drop dead token fallbacks, fix jest ESM config

- Canvas legacy color vars now resolve straight to their semantic token
  (e.g. `--alert-color: var(--color--feedback-fail--ink)`); the hardcoded
  RGB fallback is unnecessary since the host ships the tokens before this
  package is released. The `*-rgb-components` vars stay for backward compat.
- generateStyleFromCtx imports `BaseCtx` as `import type` (it's type-only).
- jest.config.js: make ts-jest emit ESM (`module: esnext`) so test modules
  load under the default-esm preset instead of throwing "exports is not
  defined"; move ts-jest config out of the deprecated `globals` block.
- Refine the v3 host-contract note in sdk UPGRADING.md.
@stefanoverna stefanoverna force-pushed the feat/semantic-tokens-for-colors branch from b3ead57 to 84e07da Compare May 29, 2026 15:20
@stefanoverna stefanoverna force-pushed the feat/semantic-tokens-for-colors branch from 84e07da to 7debc55 Compare May 29, 2026 15:22
@stefanoverna stefanoverna force-pushed the feat/semantic-tokens-for-colors branch from 6b88a99 to 998ccd0 Compare May 29, 2026 15:31
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