feat: add CSS @property rule support#284
Conversation
49bbca6 to
aad4e3a
Compare
aad4e3a to
bfebfe5
Compare
bfebfe5 to
d83cc3e
Compare
|
@YevheniiKotyrlo mind rebasing this with |
d83cc3e to
64a2be8
Compare
danstepanov
left a comment
There was a problem hiding this comment.
Nice work on this, the @Property approach is way cleaner than the -moz-orient hack. Two things:
1. Comment on the isStyleFunction passthrough (_handler.ts)
Accepting any style function in any type slot is the right call — but it's non-obvious. A future reader might wonder why var(--x) matches a "number" slot. Can you expand the comment a bit to explain the tradeoff? Something like: "this makes pattern matching less strict when variables are involved, but rejecting them would break variable-based shadows entirely."
2. repeated single-child unwrap (compiler.ts)
return results.length === 1 ? results[0] : results;This changes the return shape depending on child count. Could you either add a test with a single-child repeated to confirm it works downstream, or add a comment noting that no real-world @property declaration hits that path?
|
Can you also resolve the conflicts since I merged #277, ideally via a rebase |
64a2be8 to
b26fed0
Compare
|
Rebased on latest Addressed both review comments:
All quality gates pass (typecheck, lint, build with no unstaged files, test — 990 passed, 3 pre-existing babel failures same on |
Problem
Tailwind CSS v4 uses ~53
@propertydeclarations to register custom property initial values (e.g.,--tw-shadow,--tw-ring-shadow). Previously, react-native-css ignored@propertyrules entirely and faked-moz-orientsupport to trigger Tailwind's@supportsfallback path. This fallback injected universal variable defaults which interfered with class-level overrides, causing utilities likering-2to produceboxShadow: [].The
@propertyapproach is generic and framework-agnostic — this is the direction suggested during the #277 review.Changes
src/compiler/compiler.tsParse
@propertyrules, extractinitial-valueinto root variables viaextractPropertyRule/parsePropertyInitialValue. Handles length, number, percentage, color, angle, token-list, custom-ident, and repeated component types.src/compiler/stylesheet.tsAdd
addRootVariable()public method following the existing variable storage pattern.src/compiler/supports.tsRemove the
-moz-orienthack (no longer needed).src/native/styles/shorthands/_handler.tsAllow
StyleFunctionvalues (calc, var) to pass type checks in the shorthand handler. These are unresolved at pattern-match time but resolve to the correct type at runtime — rejecting them would break variable-based shadows entirely.src/native/styles/shorthands/box-shadow.tsFix color type from
"string"to"color"to accept platform color objects (e.g.,PlatformColorfromcurrentcolorresolution).Tests
@propertyparsing (including single-child and multi-childrepeatedtypes)Verification
yarn typecheck— passyarn lint— passyarn build— pass (no unstaged files)yarn test— 990 passed, 3 failed (pre-existing babel plugin failures, same onmain)Related
@propertyapproach suggested during that review@types/debugdependency fix in the same repo