Skip to content

feat: @property typed tokens, surface consolidation, macro/CQ tests, drift-check - #386

Merged
jackgranatowski merged 2 commits into
mainfrom
claude/open-issues-review-n064yh
Jun 23, 2026
Merged

feat: @property typed tokens, surface consolidation, macro/CQ tests, drift-check#386
jackgranatowski merged 2 commits into
mainfrom
claude/open-issues-review-n064yh

Conversation

@jackgranatowski

@jackgranatowski jackgranatowski commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Issue #359@Property registrations for output tokens
Register radius (13 tokens, ), space (22 tokens, ), and
shadow (16 tokens, *) tokens via @Property in core/tokens.css. Radius and
space gain CSS transitions (border-radius, gap, padding can now interpolate
on hover/theme switch). Shadow tokens gain cascade isolation and typed
DevTools inspection. initial-value uses bare 0 (unitless zero valid for ).

Surface consolidation (roadmap)
Convert .sf-surface--* named variants from standalone precomputed rules into
thin aliases that set --sf-surface-color. The generic .sf-surface @supports
block (extended with :is() to cover all 12 variants) handles auto-contrast
derivation uniformly. Removes ~220 lines of duplicated contextual cascade.
Element-scoped brand overrides now also re-derive contrast (improved behavior).
Old engines (Chrome <119 / Safari <16.4) get background only; accepted trade-off.

Issue #246 — macro catalog drift-check + comprehensive behavioral tests
Add scripts/check-macro-catalog.js: parses core/macros.css + core/motion.css,
compares against docs/macros.md, exits 1 on drift. Wired as npm run check:macros.

Add 11 missing behavioral tests to tests/macros.spec.js covering every
previously untested macro: .sf-prose, .sf-not-prose, .sf-scrim, .sf-text-protect,
.sf-text-gradient, .sf-link-external, .sf-link--subtle (hover), .sf-link--reverse
(hover), .sf-content-auto, .sf-tabular-nums, .sf-entrance--fade (including
prefers-reduced-motion gating).

Issue #205 — additional auto-color/link test cases
Add 4 tests to tests/auto-color.spec.js: .sf-link--subtle hover reveals
underline, .sf-link--reverse underline at rest, dark theme link underline
token non-transparent, --sf-color-link--visited differs from --sf-color-link.
Update element-scoped override test to reflect improved behavior.

Container query coverage
Add .sf-cq unnamed container test to tests/container-queries.spec.js,
proving children resolve @container queries against the .sf-cq width
(not the viewport).

Token snapshot update
Remove viewport-dependent clamp() space tokens from raw snapshot list;
regenerate snapshot with updated --sf-radius-m value (8px via @Property).

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

Summary by CodeRabbit

  • Bug Fixes

    • Improved automatic text color/contrast for surface styles across all themes, including named variants.
    • Refined underline behavior for subtle and reverse link styles.
  • New Features

    • Registered design tokens with CSS @property for better typing/animation support (radii, spacing/gap, and shadow/shadow-glow/text-shadow).
  • Tests

    • Added/extended Playwright coverage for macros, token semantics, and container query behavior.
    • Updated color/underline regression assertions.
  • Chores

    • Added a macro catalog consistency check and aligned generated documentation tokens.

…drift-check

Issue #359@Property registrations for output tokens
Register radius (13 tokens, <length>), space (22 tokens, <length>), and
shadow (16 tokens, *) tokens via @Property in core/tokens.css. Radius and
space gain CSS transitions (border-radius, gap, padding can now interpolate
on hover/theme switch). Shadow tokens gain cascade isolation and typed
DevTools inspection. initial-value uses bare 0 (unitless zero valid for <length>).

Surface consolidation (roadmap)
Convert .sf-surface--* named variants from standalone precomputed rules into
thin aliases that set --sf-surface-color. The generic .sf-surface @supports
block (extended with :is() to cover all 12 variants) handles auto-contrast
derivation uniformly. Removes ~220 lines of duplicated contextual cascade.
Element-scoped brand overrides now also re-derive contrast (improved behavior).
Old engines (Chrome <119 / Safari <16.4) get background only; accepted trade-off.

Issue #246 — macro catalog drift-check + comprehensive behavioral tests
Add scripts/check-macro-catalog.js: parses core/macros.css + core/motion.css,
compares against docs/macros.md, exits 1 on drift. Wired as npm run check:macros.

Add 11 missing behavioral tests to tests/macros.spec.js covering every
previously untested macro: .sf-prose, .sf-not-prose, .sf-scrim, .sf-text-protect,
.sf-text-gradient, .sf-link-external, .sf-link--subtle (hover), .sf-link--reverse
(hover), .sf-content-auto, .sf-tabular-nums, .sf-entrance--fade (including
prefers-reduced-motion gating).

Issue #205 — additional auto-color/link test cases
Add 4 tests to tests/auto-color.spec.js: .sf-link--subtle hover reveals
underline, .sf-link--reverse underline at rest, dark theme link underline
token non-transparent, --sf-color-link--visited differs from --sf-color-link.
Update element-scoped override test to reflect improved behavior.

Container query coverage
Add .sf-cq unnamed container test to tests/container-queries.spec.js,
proving children resolve @container queries against the .sf-cq width
(not the viewport).

Token snapshot update
Remove viewport-dependent clamp() space tokens from raw snapshot list;
regenerate snapshot with updated --sf-radius-m value (8px via @Property).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a5ce39da-db63-4c19-98ab-af777bcede65

📥 Commits

Reviewing files that changed from the base of the PR and between 7b8e1f1 and 02bda16.

⛔ Files ignored due to path filters (1)
  • dist/badge-optimal.json is excluded by !**/dist/**
📒 Files selected for processing (3)
  • core/macros.css
  • scripts/check-macro-catalog.js
  • tests/auto-color.spec.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • scripts/check-macro-catalog.js
  • tests/auto-color.spec.js
  • core/macros.css

📝 Walkthrough

Walkthrough

Adds CSS @property registrations for radius, spacing, and shadow output tokens in core/tokens.css, propagating registration metadata to both API index files. Refactors .sf-surface--* named variant rules in core/macros.css to participate in a unified auto-contrast :is() selector. Introduces a new check-macro-catalog.js drift-check script. Extends Playwright tests across macros, container queries, and auto-color behaviors.

Changes

Token @property Registrations, Surface Macro Refactor, and Tooling

Layer / File(s) Summary
@property declarations in tokens.css and snapshot alignment
core/tokens.css, tests/token-semantic.spec.js, tests/token-semantic.snapshot.json
Inserts @property registration blocks for radius, spacing/gap, and shadow tokens using <length> or "*" syntax. The token-semantic spec removes viewport-dependent spacing entries from RAW_TOKENS; the snapshot updates --sf-radius-m to its resolved 8px value and drops spacing entries that now compute as pixel lengths.
Generated API index metadata propagation
docs/api-index.json, configurator/src/data/api-index.generated.json
Updates registered, animatable, syntax, inherits, and group fields for all affected padding/gap, radius, section-padding, shadow, drop-shadow, and text-shadow tokens. Also bumps the sync hash in the configurator mirror.
Surface macro auto-contrast unification
core/macros.css, tests/auto-color.spec.js
Rewrites .sf-surface--* variant rules from per-variant color: var(--sf-color-text--on-*) to thin aliases setting only --sf-surface-color and background. Extends the @supports auto-contrast block to cover all named variants via a single :is() selector, removing the previous per-variant token blocks inside that gate. Auto-color tests updated to assert element-scoped brand overrides re-derive on-colour, and link/underline tests updated for .sf-link--subtle/.sf-link--reverse behaviors.
Macro catalog drift-check script
scripts/check-macro-catalog.js, package.json
New Node.js script reads macro CSS source files and docs/macros.md, extracts .sf-* class tokens (with wildcard expansion), computes set differences, logs mismatches, and exits 1 on drift. Registered as check:macros in package.json.
Extended macro and container-query tests
tests/macros.spec.js, tests/container-queries.spec.js
Adds Playwright test blocks for .sf-prose/.sf-not-prose, .sf-scrim, .sf-text-protect, .sf-text-gradient, .sf-link-external, .sf-link--subtle/.sf-link--reverse, .sf-content-auto, .sf-tabular-nums, .sf-entrance--fade, and an anonymous inline-size container test for .sf-cq.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • codeslash-dev/SLASHED#284: Both PRs modify the .sf-surface--* contextual surface cascade in core/macros.css, changing how derived contrast tokens are produced for named variants.
  • codeslash-dev/SLASHED#329: Both PRs touch the same @supports (color: oklch(from red l c h)) and (width: calc(1px * sign(1))) auto-contrast gate logic in core/macros.css.
  • codeslash-dev/SLASHED#254: Both PRs directly operate on the same --sf-shadow-*, --sf-text-shadow-*, and --sf-drop-shadow-* token declarations in core/tokens.css.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the four main changes: @property token registrations, surface consolidation, macro/CQ tests, and a drift-check script.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/open-issues-review-n064yh

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

SLASHED/core/macros.css

Lines 287 to 290 in 7b8e1f1

--sf-surface-contrast: oklch(from var(--sf-surface-color) clamp(0.1, sign(var(--sf-contrast-threshold) - l) * 999, 0.95) 0 0 / 1);
background: var(--sf-surface-color);
color: var(--sf-surface-contrast);
--sf-color-text: var(--sf-surface-contrast);

P2 Badge Use on-color tokens for named surface foregrounds

In current browsers with sign() support, named variants now derive --sf-surface-contrast directly from --sf-surface-color, so an override like .sf-surface--primary { --sf-color-text--on-primary: oklch(0.12 0 0); } no longer changes color, --sf-color-text, borders, links, focus rings, etc. This breaks the documented per-surface override contract in docs/theming.md:200-226; only generic .sf-surface should need direct public-token pinning, while named variants should continue to seed their foreground from the matching --sf-color-text--on-* token.

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread core/macros.css Outdated
Comment on lines +258 to +262
.sf-surface--primary { --sf-surface-color: var(--sf-color-primary); background: var(--sf-color-primary); }
.sf-surface--secondary { --sf-surface-color: var(--sf-color-secondary); background: var(--sf-color-secondary); }
.sf-surface--tertiary { --sf-surface-color: var(--sf-color-tertiary); background: var(--sf-color-tertiary); }
.sf-surface--action { --sf-surface-color: var(--sf-color-action); background: var(--sf-color-action); }
.sf-surface--neutral { --sf-surface-color: var(--sf-color-neutral); background: var(--sf-color-neutral); }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore fallback foregrounds for named surfaces

For the supported floor browsers that have oklch(from …) but not sign() (the core/tokens.css comments call out Chrome 125–137 and Firefox 128–130), the contextual block below is skipped, so these named surface rules are the only ones that apply. Dropping color: var(--sf-color-text--on-*) means .sf-surface--primary/status surfaces render with inherited page text on colored backgrounds, regressing the previous accessible foreground fallback for those browsers.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/check-macro-catalog.js`:
- Around line 80-87: In the wildcard matching block where glob is true, after
the inner for loop that iterates through cssClasses and adds matches to
docsClasses, add validation to check if the wildcard pattern matched any CSS
classes. If no matches were found for the wildcard prefix (meaning no classes
were added for that specific pattern), report an error or warning to flag the
unmatched wildcard instead of silently ignoring it.

In `@tests/auto-color.spec.js`:
- Around line 293-308: The test in the dark theme link underline token check
only validates that textDecorationColor is not transparent, but does not verify
that an underline is actually rendered on the link element. Before asserting the
color value in the page.evaluate function, add the appropriate CSS class (such
as `.sf-link--reverse`) to the anchor element created in the test, and also
verify that the underline is actually present (by checking the textDecoration
property or similar) before asserting that the decoration color is
non-transparent. This ensures the test fails if no underline is rendered
regardless of the computed color value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5cba6e71-4d59-45f2-bab9-d970306461be

📥 Commits

Reviewing files that changed from the base of the PR and between 76414b6 and 7b8e1f1.

⛔ Files ignored due to path filters (2)
  • dist/badge-essential.json is excluded by !**/dist/**
  • dist/badge-optimal.json is excluded by !**/dist/**
📒 Files selected for processing (11)
  • configurator/src/data/api-index.generated.json
  • core/macros.css
  • core/tokens.css
  • docs/api-index.json
  • package.json
  • scripts/check-macro-catalog.js
  • tests/auto-color.spec.js
  • tests/container-queries.spec.js
  • tests/macros.spec.js
  • tests/token-semantic.snapshot.json
  • tests/token-semantic.spec.js

Comment thread scripts/check-macro-catalog.js
Comment thread tests/auto-color.spec.js
…hecks

Address three issues flagged in the PR #386 automated review:

- core/macros.css: add `color: var(--sf-color-text--on-*)` back to each named
  surface variant. Chrome 125–137 / Firefox 128–130 support oklch(from) but not
  sign(), so the @supports cascade block is skipped; without an explicit color
  declaration those browsers inherit page-body text onto coloured backgrounds.
  Restores accessible foreground for the intermediate browser tier while the
  auto-contrast cascade still takes over in fully modern engines.

- scripts/check-macro-catalog.js: track wildcard patterns that expand to zero
  CSS classes and report them as errors. Previously a stale wildcard (e.g.
  .sf-entrance--* after a rename) would pass the drift-check silently.

- tests/auto-color.spec.js: add .sf-link--reverse to the dark-theme underline
  test anchor and assert textDecorationLine === 'underline' before checking the
  decoration colour. Prevents the assertion from passing vacuously when no
  underline is rendered.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TJ5PentbTtNx4serLVMZcb
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