openpencil/tests/engine
Danila Poyarkov 45df90c5c7
CSS Grid layout mode (#73)
* Switch to @open-pencil/yoga-layout with CSS Grid support

Use our fork (open-pencil/yoga, grid branch) which cherry-picks the
upstream CSS Grid PRs (#1893–#1898) onto current main. The JS bindings
are ported from the old embind approach to the new wasm_bridge.c API.

npm:@open-pencil/yoga-layout alias keeps all imports as 'yoga-layout'.

Also handle FinalizationRegistry change (upstream #1908) — node.free()
no longer exists, nodes are garbage collected automatically.

* Add CSS Grid layout mode

Scene graph:
- LayoutMode gains 'GRID' option alongside HORIZONTAL/VERTICAL
- GridTrack type (sizing: FIXED/FR/AUTO, value) for track definitions
- GridPosition type (column, row, columnSpan, rowSpan) for children
- New node props: gridTemplateColumns/Rows, gridColumnGap, gridRowGap,
  gridPosition

Layout engine:
- buildGridTree() sets Display.Grid and maps GridTrack[] to Yoga's
  setGridTemplateColumns/Rows API with FR/Points/Auto track types
- Grid children use gridPosition for column/row placement with span
- Flex layout path unchanged

Store:
- setLayoutMode('GRID') auto-creates NxM track grid based on child
  count (sqrt heuristic), defaults to 1fr tracks

UI (LayoutSection.vue):
- Grid button (grid-2x2 icon) added to flow direction row
- Columns/Rows track editors: ScrubInput for value + AppSelect for
  sizing mode (Fill fr / Fixed px / Auto), add/remove buttons
- Separate column gap and row gap ScrubInputs
- Wrap button hidden when grid is active
- Flex alignment grid hidden when grid is active

Kiwi serialization skips GRID mode for now (no .fig codec support).

* Add grid layout integration tests

12 new test scenarios covering:
- Basic 2x2 grid, fixed columns, mixed fr/fixed, unequal fr weights
- Column gap, row gap, both gaps combined
- Padding offsets
- Explicit gridPosition placement, column span, row span
- Absolute children skipped
- Hidden children collapsed
- Nested grid inside flex parent (computeAllLayouts)

Also fix: grid frames as children of flex parents now correctly use
Display.Grid via configureChildAsGrid() instead of falling through
to configureChildAsAutoLayout() which set FlexDirection.

* Deduplicate grid yoga configuration

Extract configureAsGrid() and createGridChildNode() shared by
buildGridTree (root-level grid) and configureChildAsGrid (grid
nested inside flex parent).

* Add grid layout to changelog

* Add grid support to JSX and Tailwind CSS export

OpenPencil format: grid → columns/rows/columnGap/rowGap props,
child colStart/rowStart/colSpan/rowSpan.

Tailwind format: grid grid-cols-N grid-rows-N gap-x-* gap-y-*,
mixed tracks use arbitrary values (grid-cols-[200px_1fr_auto]),
child col-start-*/row-start-*/col-span-*/row-span-*.

Both formats: padding emitted for grid frames (shared with flex),
flex-only props (justify/items/wrap/gap) scoped to isFlex.

* Remove duplicate gridTrackToTw, use shared formatTrack

Also drop unused GridTrackSizing import from LayoutSection.vue.

* Fix grid icon: use layout-grid instead of grid-2x2

unplugin-icons can't resolve icon names with digits after hyphens
(grid-2x2 → grid2x2 which doesn't exist).

* Polish layout UI and fix auto-layout behavior

- Replace text labels with compact icons: ↔/↕ for gap, ☐ for uniform padding, T/R/B/L for per-side padding
- Direction-aware gap icon: ↕ for vertical, ↔ for horizontal
- Pin +/− padding toggle button right of gap input
- Fix alignment grid axes for vertical layout (transpose primary/counter)
- Fix grid switch: set FIXED sizing, compute frame size from children
- Remove hardcoded white fill from Shift+A wrap
- Auto-detect horizontal vs vertical from selection bounds

* Add flex-to-grid switch integration test

Verify HUG frame expands and children are placed in 2x2 grid
when switching from vertical flex to grid layout.

* Update changelog for grid layout
2026-03-08 18:23:53 +03:00
..
abspos-cache.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
acp-agent.test.ts Add ACP agent package with tests 2026-03-05 09:14:54 +03:00
clipboard.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
color.test.ts Centralize all color utilities in color.ts 2026-03-07 10:02:11 +03:00
effects-and-resize.test.ts Fix effects rendering: shadows, blur, spread (#24) 2026-03-03 09:53:39 +03:00
eval-cli.test.ts Fix hit-testing: scope hover to current page, click-through empty containers 2026-03-05 08:56:35 +03:00
export-jsx.test.ts CSS Grid layout mode (#73) 2026-03-08 18:23:53 +03:00
fig-import.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
fig-roundtrip.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
figma-api.test.ts Fill Figma Plugin API gaps: 29 new tests, 30+ new properties and methods 2026-03-01 13:35:02 +03:00
fonts.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
individual-strokes.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
layout.test.ts CSS Grid layout mode (#73) 2026-03-08 18:23:53 +03:00
mcp-server.test.ts Fix hit-testing: scope hover to current page, click-through empty containers 2026-03-05 08:56:35 +03:00
mcp.test.ts Fix hit-testing: scope hover to current page, click-through empty containers 2026-03-05 08:56:35 +03:00
multi-selection.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
mutation.test.ts Add mutation unit tests: toggleBoldInRange, vectorNetworkBlob precision, SceneGraph+UndoManager integration 2026-03-07 23:11:03 +03:00
profiler.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
render.test.ts Tailwind CSS v4 JSX export (#54) 2026-03-06 18:04:11 +03:00
renderer-effects.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
scene-graph.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
snap.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
style-runs.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
svg-export.test.ts SVG export (#52) 2026-03-05 10:31:02 +03:00
tailwind-jsx.test.ts CSS Grid layout mode (#73) 2026-03-08 18:23:53 +03:00
text-editor.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
tools-ai-adapter.test.ts Unify tool definitions: define once, adapt for AI/CLI/MCP 2026-03-01 15:02:05 +03:00
tools-cli.test.ts Fix hit-testing: scope hover to current page, click-through empty containers 2026-03-05 08:56:35 +03:00
tools.test.ts Unify tool definitions: define once, adapt for AI/CLI/MCP 2026-03-01 15:02:05 +03:00
undo.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00
vector.test.ts Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests 2026-03-06 22:33:10 +03:00