feat(preset-wind4): support theme parse in all bracket syntax rule#5181
Conversation
✅ Deploy Preview for unocss ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
commit: |
There was a problem hiding this comment.
Pull request overview
This PR updates preset-wind4 so bracket-syntax parsing can evaluate theme expressions/variables (e.g. theme(...), --spacing(8)) by consistently passing the active theme into h.bracket* helpers across variants and rules, addressing cases like calc(...+--spacing(8)) from #5151/#5174.
Changes:
- Pass
ctx.theme/{ theme }intoh.bracket(...)and related chained helpers (.cssvar,.percent, etc.) throughout variants and rules. - Adjust several helper functions/rule handlers to accept
theme/RuleContextso bracket parsing can resolve theme-aware values. - Minor typing updates (e.g.
Variant<Theme>,RuleContext<Theme>) to match updated handler signatures.
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages-presets/preset-wind4/src/variants/supports.ts | Pass theme into bracket parsing for supports- variant values. |
| packages-presets/preset-wind4/src/variants/placeholder.ts | Make placeholder opacity detection theme-aware when parsing bracket values. |
| packages-presets/preset-wind4/src/variants/misc.ts | Pass theme into bracket parsing for selector/layer/scope/variables and fix Variant<Theme> typing. |
| packages-presets/preset-wind4/src/variants/media.ts | Pass theme into bracket parsing for custom media variant values. |
| packages-presets/preset-wind4/src/variants/data.ts | Pass theme into bracket parsing for data- variants. |
| packages-presets/preset-wind4/src/variants/container.ts | Pass theme into bracket parsing for container query sizes. |
| packages-presets/preset-wind4/src/variants/combinators.ts | Pass theme into bracket parsing for combinator scope bodies. |
| packages-presets/preset-wind4/src/variants/aria.ts | Pass theme into bracket parsing for aria- variants. |
| packages-presets/preset-wind4/src/utils/utilities.ts | Ensure bracket parsing in parseColor uses theme for modifiers/alpha. |
| packages-presets/preset-wind4/src/rules/typography.ts | Pass theme into multiple bracket/cssvar helpers for typography-related rules. |
| packages-presets/preset-wind4/src/rules/transition.ts | Pass theme into time/cssvar parsing for transition duration/delay/ease. |
| packages-presets/preset-wind4/src/rules/transform.ts | Thread theme through transform value parsing helpers via RuleContext<Theme>. |
| packages-presets/preset-wind4/src/rules/table.ts | Pass theme into bracket/cssvar parsing for table-related sizing. |
| packages-presets/preset-wind4/src/rules/svg.ts | Pass theme into stroke/fill opacity and width parsing helpers. |
| packages-presets/preset-wind4/src/rules/static.ts | Pass theme into bracket parsing for display/cursor/contain/content/object-position. |
| packages-presets/preset-wind4/src/rules/spacing.ts | Pass theme into bracket/cssvar parsing for spacing rules. |
| packages-presets/preset-wind4/src/rules/size.ts | Pass theme into aspect-ratio parsing for bracket/cssvar values. |
| packages-presets/preset-wind4/src/rules/shadow.ts | Pass theme into shadow parsing helpers (color/opacity/cssvar). |
| packages-presets/preset-wind4/src/rules/ring.ts | Pass theme into ring width/opacity/cssvar parsing. |
| packages-presets/preset-wind4/src/rules/position.ts | Pass theme into inset/z-index parsing helpers for bracket/cssvar values. |
| packages-presets/preset-wind4/src/rules/placeholder.ts | Pass theme into placeholder opacity parsing. |
| packages-presets/preset-wind4/src/rules/mask.ts | Pass theme into mask parsing helpers for bracket/cssvar values. |
| packages-presets/preset-wind4/src/rules/grid.ts | Pass theme into grid parsing helpers (including template areas). |
| packages-presets/preset-wind4/src/rules/flex.ts | Pass theme into flex/basis/shrink/grow bracket/cssvar parsing. |
| packages-presets/preset-wind4/src/rules/filters.ts | Pass theme into filter/drop-shadow parsing helpers for bracket/cssvar/percent values. |
| packages-presets/preset-wind4/src/rules/divide.ts | Pass theme into divide opacity/size parsing helpers. |
| packages-presets/preset-wind4/src/rules/decoration.ts | Pass theme into decoration thickness/offset/opacity parsing helpers. |
| packages-presets/preset-wind4/src/rules/columns.ts | Pass theme into columns value parsing via bracket/cssvar. |
| packages-presets/preset-wind4/src/rules/color.ts | Pass theme into bg/url/position/size bracket parsing and bg opacity handling. |
| packages-presets/preset-wind4/src/rules/border.ts | Pass theme into border size/opacity/radius bracket/cssvar parsing. |
| packages-presets/preset-wind4/src/rules/behaviors.ts | Pass theme into outline/will-change/list-image/accent/caret parsing helpers. |
| packages-presets/preset-wind4/src/rules/background.ts | Pass theme into gradient position/opacity parsing helpers. |
| packages-presets/preset-wind4/src/rules/animation.ts | Pass theme into animation name/timings/iteration parsing via bracket/cssvar. |
| packages-presets/preset-wind4/src/rules/align.ts | Pass theme into vertical-align bracket/cssvar parsing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (s != null) | ||
| return { 'grid-template-areas': h.cssvar(v) ?? v.split('-').map(s => `"${h.bracket(s)}"`).join(' ') } | ||
| return { 'grid-area': h.bracket.cssvar(v) } | ||
| return { 'grid-template-areas': h.cssvar(v) ?? v.split('-').map(s => `"${h.bracket(s, theme)}"`).join(' ') } |
There was a problem hiding this comment.
In grid-template-areas generation, v.split('-').map(s => "${h.bracket(s, theme)}") will stringify undefined when a segment isn’t bracket-syntax (e.g. grid-areas-foo-bar), producing invalid CSS like "undefined". Consider either falling back to the raw segment (h.bracket(s, theme) ?? s) or returning undefined when any segment can’t be parsed, to avoid emitting broken output.
| return { 'grid-template-areas': h.cssvar(v) ?? v.split('-').map(s => `"${h.bracket(s, theme)}"`).join(' ') } | |
| return { 'grid-template-areas': h.cssvar(v) ?? v.split('-').map(s => `"${h.bracket(s, theme) ?? s}"`).join(' ') } |
Related to #5151, #5174