fix(preset-wind4): support nested spacing theme functions#5161
Closed
Jack-lea wants to merge 1 commit intounocss:mainfrom
Closed
fix(preset-wind4): support nested spacing theme functions#5161Jack-lea wants to merge 1 commit intounocss:mainfrom
Jack-lea wants to merge 1 commit intounocss:mainfrom
Conversation
✅ Deploy Preview for unocss ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
zyyv
reviewed
Mar 23, 2026
Comment on lines
+211
to
+212
| if (theme) | ||
| base = replaceThemeFunctions(base, theme) |
Member
There was a problem hiding this comment.
Sorry, I don't think this is a very good solution.
Comment on lines
214
to
242
| if (base.startsWith('--')) { | ||
| const calcMatch = base.match(/^--([\w.-]+)\(([^)]+)\)$/) | ||
| if (calcMatch != null && theme) { | ||
| // Handle theme function with calculation: --theme.key(factor) | ||
| const [, name, factor] = calcMatch | ||
| const [key, ...paths] = name.split('.') as [keyof Theme, ...string[]] | ||
| const { val, varKey } = processThemeVariable(name, key, paths, theme) | ||
|
|
||
| if (val != null) | ||
| base = `calc(var(--${escapeSelector(varKey.replaceAll('.', '-'))}) * ${factor})` | ||
| } | ||
| else { | ||
| // Handle regular CSS variable: --name or --theme.key with optional default | ||
| const [name, defaultValue] = base.slice(2).split(',') | ||
| const suffix = defaultValue ? `, ${defaultValue}` : '' | ||
| const escapedName = escapeSelector(name) | ||
|
|
||
| if (theme) { | ||
| const [key, ...paths] = name.split('.') as [keyof Theme, ...string[]] | ||
| const { val, varKey } = processThemeVariable(name, key, paths, theme) | ||
| base = val != null | ||
| ? `var(--${escapeSelector(varKey.replaceAll('.', '-'))}${suffix})` | ||
| : `var(--${escapedName}${suffix})` | ||
| } | ||
| else { | ||
| base = `var(--${escapedName}${suffix})` | ||
| } | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
My previous assessment was too narrow; I shouldn't have relied on a simple startsWith check. I think we should rewrite this logic to replace all theme variables enclosed within [].
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.
No description provided.