Repository navigation
fix(preset): resolve leftover alpha placeholders under presetWind4 - #5
Merged
Merged
Conversation
presetWind4 inlines theme colors that contain `var(` into utilities as `color-mix(..., <color> <opacity>, transparent)` without replacing their `%alpha` placeholder. Every shade of the runtime palette contains `var(--chromatic-hue)`, so `text-primary-600`, `bg-primary-500/50` and the other color utilities produced invalid declarations that browsers drop. Replace leftover placeholders with `1` in a postprocess hook, the value wind4 itself uses for theme variables. The surrounding `color-mix` still applies the utility opacity, and the runtime hue stays dynamic. wind3 resolves placeholders before postprocessing, so its output is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ Deploy Preview for proj-airi-chromatic ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
4 of 5 tasks
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.
Problem
With
presetWind4+presetChromatic, color utilities generate invalid CSS, so browsers drop them:presetWind4 inlines a theme color that contains
var(into the utility ascolor-mix(<method>, <color> <opacity>, transparent)and does not replace its%alphaplaceholder (colorCSSGenerator,@unocss/preset-wind4/dist/utils-*.mjs, 66.7.5 lines 569–586). It only replaces placeholders with1when it emits theme variables (getThemeVarsMap,dist/index.mjsline 456), which it skips for these colors. Every shade of the runtime palette containsvar(--chromatic-hue), so every shade is affected. presetWind3 is fine.Fix
A
postprocesshook replaces leftover%alpha/<alpha-value>placeholders with1, the value wind4 itself uses for theme variables. The surroundingcolor-mix(…, transparent)still applies the utility's opacity (/50→… / 1) 50%, transparent)), and--chromatic-huestays dynamic at runtime.The hook runs on every utility, not only chromatic ones. A leftover placeholder is always invalid CSS, so the hook cannot change any output that was valid before.
wind3 output is unchanged
presetWind3 resolves every placeholder before postprocessing. I generated CSS for 16 utility prefixes × 11 shades × opacity / saturation / brightness modifiers and
hover:, in both runtime andbakeColorsmodes, before and after the change: the results are byte-identical (cmp).Tests
New
packages/preset/src/shared.wind4.test.tscoverstext-primary-600,bg-primary-500/50,border-primary-400,ring-primary-500,bg-primary-50, and the modifier syntaxbg-primary-500/50~10*115. All 4 cases failed before the fix and pass after it.pnpm test:run(14 tests),pnpm typecheck,pnpm lintandpnpm build:packagespass.Found while adopting chromatic in the vieval web viewer, which uses presetWind4.
🤖 Generated with Claude Code