Skip to content

fix: add theme color fallbacks and compatibility notes - #23

Open
mkroemer wants to merge 1 commit into
p10node:mainfrom
mkroemer:fix/theme-icon-compatibility
Open

mkroemer wants to merge 1 commit into
p10node:mainfrom
mkroemer:fix/theme-icon-compatibility

Conversation

@mkroemer

Copy link
Copy Markdown
Contributor

Add token-based fallbacks before color-mix() declarations so selection, hover, and connection states remain visible when that function is unsupported. Mixed source-selection custom properties are gated with @supports, preserving light/dark accent mixing and host srcSel overrides.

Also hoist the typed icon-map example, document trusted theme configuration including SSR, and add pending migration notes for ThemeMode, FileMenuItem.icon, and stable ICON_NAMES keys. Existing versioned release notes are unchanged.

Follows up on the non-blocking review comments in #4 and #5. Fallback colors approximate the mixed states; this does not establish general support for older browsers.

Validation with Bun 1.4.4: frozen install, 15 theme/icon unit tests, typecheck, CSS build/output comparison, and diff whitespace check passed. No browser tests were added or run.

@pierreneter pierreneter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the notes and the test. The main part does not work yet, though. Line numbers are at 02037fc.

  1. src/react/styles.css:399 and the eight other duplicate declarations (400, 484, 932-935, 957, 996, 1044, 1205, 1268): each color-mix() wraps a var(). A declaration that contains var() is always valid at parse time, so it wins over the fallback before it. In a browser without color-mix() it then becomes invalid at computed-value time, and the property goes to its initial value, not back to the earlier declaration. The result is the same as before the PR: no range background, no cell selection, no hover. Checked in Chromium with an unknown function standing in for color-mix(): transparent / none. Only --de-src-sel, which is inside @supports, works. That is the shape to use everywhere: the plain fallback outside, the mixed declaration inside @supports (color: color-mix(in srgb, red, blue)).
  2. test/theme.test.ts:52 asserts the textual pattern that does not work, and it fails on the structure that does (a mixed rule inside @supports with its fallback outside). Also, line 47 only matches a token whose value starts with color-mix(, so a shadow token such as 0 2px 8px color-mix(...) passes, and line 57 skips declarations that follow a comment or span two lines.
  3. docs/development.md:83 says the color-mix() declarations have fallbacks for selection, hover and connection states. Today that holds for --de-src-sel only.
  4. docs/development.md:73: the "pending compatibility notes" are no longer pending. Theme = ThemeMode | ThemeOptions, FileMenuItem.icon: IconName and ICON_NAMES shipped in v0.14.0 (the tag contains 8ba9fa0 and 1a670f2), so "carry these into the next release" would put them under the wrong version.

Non-blocking:

  • Once the fallbacks do apply, some values are far from the mixed ones: .de-collab-live .de-collab-dot gets a solid 3px ring where the mix is an 18% halo, .de-hf-zone:hover gets 12% / 18% where the mix is 5%, and the --de-accent-soft fallbacks are the default blue even when a host sets accent.
  • docs/theming.md:28: the trust note covers token values, but names are passed through as well ('--de-' + kebab(k)). A key from untrusted JSON such as x:1;position:fixed;inset:0;--y ends up as extra declarations in the server-rendered style attribute. Filtering keys by THEME_TOKENS in themeStyle() closes that, which is better than documenting it.
  • A test that pins the whole ICON_NAMES list would enforce the stability promise; test/icons.test.tsx checks seven names.
  • docs/theming.md:93 still says the built-in values are the .de-root and .de-root.de-dark blocks, while the effective srcSel now lives in the @supports block.

This branch has not been deployed

No deployments
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