feat: scope_css - extract scoped CSS from Tailwind output for Web Components (#50)#52
Merged
feat: scope_css - extract scoped CSS from Tailwind output for Web Components (#50)#52
Conversation
Add .claude/worktrees/ to .gitignore per legion team finding (#214) where rust sub-agents staging with git add -A pulled worktree gitlinks into main. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ponents (#50) Add scope_css and extract_classes_from_ts to veneer-adapters for per-component Shadow DOM stylesheet scoping. - scope_css: extracts @Utility blocks matching a class list from a Tailwind v4 CSS source file; strips modifier prefixes (hover:, @sm:, focus-visible:, etc.) to resolve base names; includes only the @theme custom property declarations referenced by matched utilities - extract_classes_from_ts: parses .classes.ts source via oxc, walks exported string literals (flat, object, array), returns deduplicated sorted class tokens Regex-based CSS parsing (v1 spec). No new crate deps -- regex was already in the workspace. 13 new tests, 78 total passing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Extract find_matching_brace helper to dedupe brace-depth tracking across extract_utility_blocks and extract_relevant_theme_decls - Replace body_end==0 sentinel with Option<usize> for correctness - Remove dead @ prefix strip from strip_modifiers (rfind handles it) - Collapse double-traversal in collect_classes_from_expr: recurse into object properties directly instead of calling extract_nested_object_classes then also iterating props - Dedupe warning loops in scope_css to single pass - Add chained-modifier test (@sm:hover:flex) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
scope_css(classes, full_css)— extracts matching@utilityblocks from a Tailwind v4 CSS source file; strips all modifier prefixes (hover:,@sm:,focus-visible:, chained@sm:hover:, etc.) viarfind(':')'; includes only the@themecustom property declarations referenced by matched utilities viavar(--...)extract_classes_from_ts(source)— parses a.classes.tsfile via oxc, walks exported string literals recursively (flat strings, object property values, arrays), returns deduplicated sorted class tokensveneer-adapterspublic APIImplementation notes
find_matching_bracehelper for both@utilityand@themeblock extractionregexwas already in the workspaceTest plan
cargo clippy -p veneer-adapters -- -D warningscleancargo fmt -- --checkcleanCloses #50
🤖 Generated with Claude Code