figma-transformer: decode stroke weight/align/dashes so borders render at design width#335
Merged
Merged
Conversation
…r at design width The Kiwi decoder's NodeChange field policy never whitelisted the stroke geometry fields, so strokeWeight/strokeAlign/dashPattern were skipped during selective decode. The emitter's strokeStyles() already reads strokeWeight and strokeAlign, but with the fields dropped at decode time every border fell back to the 1px default regardless of the design (coverage issue #328). - Whitelist strokeWeight, strokeAlign, strokeCap, strokeJoin, dashPattern, and the per-side border weights on the NodeChange policy. Per-side names are over-listed across both border*Weight/stroke*Weight shapes; unlisted fields are skipped, not mis-read, so the over-list is safe. - Carry the same stroke fields through component-instance resolution and instance-child override merges so instances render their own strokes. - Extend strokeStyles() to honour the decoded geometry: real weight on the border/box-shadow, per-side border-*-width when independent weights are present, box-sizing:border-box for INSIDE strokes, and border-style:dashed for a non-empty dashPattern (CSS borders can't express exact dash lengths; precise dashes would need an SVG/background stroke, out of scope). - Add contract coverage: a real Kiwi decode fixture proving strokeWeight=3, strokeAlign=INSIDE and dashPattern=[4,2] survive the field policy, plus emitter fixtures asserting an INSIDE stroke emits border:3px (not 1px) and a dashPattern emits border-style:dashed. Refs #328
cd272a7 to
1468889
Compare
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.
Summary
Per coverage issue #328, the Kiwi decoder's
NodeChangefield policy never whitelisted the stroke geometry fields, sostrokeWeight/strokeAlign/dashPatternwere dropped during selective decode. The emitter'sstrokeStyles()already readstrokeWeight/strokeAlign, but with those fields gone every border rendered at the 1px default regardless of the design.Changes
FigKiwiDecoder— whiteliststrokeWeight,strokeAlign,strokeCap,strokeJoin,dashPattern, and the per-side border weights on theNodeChangepolicy. Per-side names are over-listed across bothborder*Weight/stroke*Weightshapes; unlisted fields are skipped (not mis-read), so the over-list is safe.ScenegraphNormalizer— carry the stroke fields through component-instance resolution and instance-child override merges so instances render their own strokes.StaticHtmlEmitter::strokeStyles()— honour the decoded geometry:strokeWeighton theborder/ outsidebox-shadowringborder-*-widthwhen independent weights are presentbox-sizing:border-boxforINSIDEstrokes so the box isn't grownborder-style:dashedfor a non-emptydashPatternCSS borders can't reproduce exact Figma dash lengths (
border-styleonly exposes thedashedkeyword); precise dashes would need an SVG/background stroke, which is out of scope here.Test
php tests/contract/run.php— all pass. New coverage:strokeWeight=3,strokeAlign=INSIDEanddashPattern=[4,2]survive the field policy.INSIDEstroke emits the exactborder:3px solid #000000;box-sizing:border-box(no longer the 1px default).dashPatternemitsborder-style:dashedat the design width.Refs #328
AI assistance