mirror of
https://github.com/penpot/penpot.git
synced 2026-10-29 14:00:37 +00:00
The variant switch event picked its target variant, and the component swap event worked out where the new head goes, inside the frontend events. Code that runs without the frontend store, such as the pure composable runner, could not do the same switch or swap. The swap and the switch also checked for nesting loops with two different functions. Move them to app.common.logic.variants: - find-switch-target picks the nearest variant with the requested value. - generate-component-swap-in-place builds the swap changes keeping the old head's index, grid cell and swap-keep-attrs, plus the keep-touched step when asked. - swap-nesting-loop? checks that a swap or switch does not nest a component inside itself. The swap menu, the plugin swapComponent and the variants-switch event all use it. The frontend events behave as before, with two exceptions. Switching to a value no other variant has does nothing, where it threw in min-key. A swap also updates the layout of the shapes the keep-touched step adds.