Repository navigation
fix: map every logical border property onto a prop React Native reads - #393
Conversation
d5cc8ca to
e36c560
Compare
e36c560 to
85c6387
Compare
sammoore
left a comment
There was a problem hiding this comment.
Thanks for this! The core fix has landed in #581: your commit with follow-ups on top, squashed into 0ef4ec8 with you as co-author. border-x-*/border-y-* colours now compile to one declaration per edge (borderStartColor/borderEndColor, borderTopColor/borderBottomColor), so they're drawn on both platforms and a later edge colour wins in cascade order. That fixes the Nativewind v4 regression without #474.
#581 set aside the parts of this PR that doesn't affect Tailwind users, leaving four fixes for this PR. Could you rebase onto main and narrow it to them?
Two are independent of #474 and apply directly to main:
- Quieting the warning for
border-inline-style: var(--tw-border-style), which everyborder-x-2/border-y-2triggers. Ideally just a ~3-line warning change. light-dark()in the edge shorthands (border-inline,border-inline-start,border-block-startand so on). It can reuse thedescriptorPropertiesthat #581 added.
Two resolve at runtime, so as written they need #474:
- A
var()axis colour holding two colours (--c: red blueinborder-x-(--c)). This could work without #474 by keeping #581's one declaration per edge and having each edge pick its colour from the resolved value. var()inborder-inline/border-blockand their-start/-endforms.
Up to you how you want to group these changes (all in this PR based on #474, or what have you); I'll review them after the next release. The runtime pair can wait for #474 and/or use the per-edge approach above.
b19d450 to
168b6ff
Compare
|
Rebased onto
|
168b6ff to
683eb44
Compare
… React Native reads - A var() per-edge style, which every Tailwind border-x-* / border-y-* width utility writes through --tw-border-style, drops without a warning, as a solid one does: its value is unknown, not a known non-solid style. - light-dark() in border-inline, border-inline-start/-end and border-block-start/-end sends its dark half to the edge keys its light half lands on, through descriptorProperties, and so does a colour longhand, renamed or not. - A var() axis colour holding two colours keeps nativewind#581's one declaration per edge, and each edge picks its own colour from the resolved value. - var() in border-inline, border-block and their -start/-end forms resolves at runtime onto the same edge keys as the literal forms, the style component dropped; with nativewind#474's cascade order a later edge declaration replaces its edge.
683eb44 to
16ba73c
Compare


The four logical border cases #581 set aside, on top of #474.
Problem
On
main:border-inline-style: var(--tw-border-style)warns. Every Tailwindborder-x-*/border-y-*width utility writes a per-edge style through--tw-border-style, so each one logs a warning, although avar()style drops exactly as asolidone does.light-dark()in an edge shorthand sends its dark half to a key React Native lacks.border-inline,border-inline-start/-endandborder-block-start/-endaddress it to the property's own name (borderInline,borderInlineStart, …), so the dark scheme paints nothing new. The renamed longhands (border-inline-start-color,border-inline-end-color) do the same.var()axis colour holding two colours sets neither edge.border-x-(--c)with--c: red blueputs the whole pair on each edge.var()inborder-inline,border-blockand their-start/-endforms puts the variable's text onborderInline,borderBlockor their start/end key, none of which React Native reads, so no edge is set.Solution
var()value without a warning, since an unknown value is not a known non-solid one.parseColorForwith the edge keys they write, asborder-blockand the axis colours do after fix(compiler): land border-x/border-y colours on border keys React Native draws #581, and the colour longhands do the same with the key they write, so the renamedborder-inline-start-color/-end-colorsend it toborderStartColor/borderEndColor.var()axis colour keeps fix(compiler): land border-x/border-y colours on border keys React Native draws #581's one declaration per edge; each edge resolves throughaxisColorStart/axisColorEnd, which take one or two colours and pick their own (css-logical-1 §4.5.3).borderInline,borderBlockand their start/end resolvers inshorthands/border.tsland width and colour on the keys the literal forms use, dropping the style. They shareborder's runtime grammar, so a variable matches in the ordersborder: var()matches today: width style colour, style colour, or width style. They resolve where their declaration stands, so a later edge declaration replaces its edge with fix(native): resolve declarations in cascade order once an element's variables are set #474's cascade order.Tests
src/__tests__/compiler/logical-borders.test.ts: each per-edge style with avar()drops without a warning.src/__tests__/native/logical-borders.test.tsx: a two-colour variable in each axis colour; eachvar()shorthand reaching the edges it names; a later edge colour over avar()shorthand; the real-key guard over every member with avar()and every colour-bearing member withlight-dark(), in both schemes.Verification
Every CI job passes locally on the head: lint, typecheck,
yarn test, the library and web builds, commitlint, and the iOS dev build.Merge order
Builds on #474, which lands first.