Repository navigation
feat(theme): design tokens for every color, type and shape; theme objects - #4
Merged
Merged
Conversation
…ects
Every color in the stylesheet is now a --de-* token on .de-root, with the
dark values on .de-root.de-dark: find highlights, collaboration status,
avatars, slideshow, tooltips, file badges, paper and placeholders, and the
source editor's syntax colors (moved to the root so a theme reaches them).
Fonts, radii and shadows are tokens too. Rendering is unchanged: a
computed-style comparison against the previous stylesheet over DOCX, XLSX,
PPTX and Markdown, light and dark, differs only in equivalent font stacks
and the color-button swatch edge, which now follows swatch-border (visible
in dark).
- theme accepts { mode, tokens, light, dark } with typed camelCase token
names (ThemeTokens); THEME_TOKENS, createTheme, themeStyle, useThemeRoot
- injectStyles={false} and @p10node/office-engine/styles.css for hosts that
load the stylesheet themselves (CSP, extracted CSS, cascade layers)
- docs/theming.md; unit tests keep THEME_TOKENS and the stylesheet in step
and reject literal colors outside token definitions; e2e for theme
objects in both modes and for injectStyles=false
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 14, 2026
pierreneter
approved these changes
Nov 17, 2026
pierreneter
left a comment
Member
There was a problem hiding this comment.
Thanks a lot for this, and for splitting the work into reviewable steps.
Approved. Merges cleanly; typecheck and unit tests pass on the tip, and I compared the resolved styles with main in light and dark.
Notes for the release, nothing to change before merging:
- The exported
Themetype is nowThemeMode | ThemeOptions, so a host that used it as the mode union stops compiling. I'll call it out in the notes. color-mix()is new instyles.css. Chrome < 111, Safari < 16.2 and Firefox < 113 drop those declarations, so the XLSX range selection loses its fill there. A plain fallback declaration before each one would cover it, in a follow-up if you like.- Theme token values are written as given. That is fine in the browser; under SSR they land in the
styleattribute, sodocs/theming.mdcould say they must not come from untrusted input.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This lets a host give the viewer its own look without overriding the stylesheet's selectors.
Every color in
styles.cssis now a--de-*custom property on.de-root, with the dark values on.de-root.de-dark. That includes the find highlights, collaboration status and avatars, the slideshow, tooltips, file badges, paper and placeholders, and the source editor's syntax colors, which moved to the root so a theme reaches them. Fonts, radii and shadows are tokens too.themestill takes'light' | 'dark' | 'auto', and now also an object:Token names are typed and camelCase (
accentHoversets--de-accent-hover, list inTHEME_TOKENS).createTheme,themeStyleanduseThemeRootare exported for hosts that mountDocxView,XlsxVieworPptxViewin a root of their own. A host that cannot inject a style tag (CSP, extracted CSS, cascade layers) passesinjectStyles={false}and imports@p10node/office-engine/styles.css.docs/theming.mddescribes it all.Rendering is unchanged. I compared computed styles against the current stylesheet over DOCX, XLSX, PPTX and Markdown files, light and dark. The only differences are equivalent font stacks and the color button's swatch edge, which now follows
swatch-borderand so is visible in dark mode.test/theme.test.tskeepsTHEME_TOKENSand the stylesheet in step and fails on a literal color outside a token definition.e2e/viewer.spec.tscovers theme objects in both modes andinjectStyles={false}. On currentmain(v0.13.2),bun run typecheck,bun testand the e2e suite pass in CI.This is the first of a few small PRs I'd like to propose, each building on the one before: host icons, translatable UI texts (English and German), replaceable toolbar components, and a headless mode where the host draws its own controls from a controller. Happy to rename things or split this further if you prefer.
🤖 Generated with Claude Code