Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental auto-layout system #519

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Experimental auto-layout system #519

wants to merge 1 commit into from

Conversation

geom3trik
Copy link
Collaborator

This PR changes the layout system to behave similarly to Figma auto-layout.

Below I've outlined the main differences between the current and new systems.

Padding & Alignment

In the current system, both padding and alignment are achieved through the child-space properties. So in the current system, to align the children to the center the child-space would be set to stretch. This makes it very difficult to have a fixed amount of padding while also controlling the alignment of the children. Each child would need to have its spacing set independently, which in the current system overrides the child-spacing (padding) of the parent.

In the new system, padding and alignment are separate properties. There is no longer any stretch padding, only a fixed size in pixels or percentage. Alignment is achieved through a new Alignment property.

Practically speaking this means that child-space: 1s can be changed to alignment: center.

Gap

The new system has properties for horizontal and vertical gaps which work similarly to the current system. The main difference is that these gaps cannot be overridden by individual child spacing as they can currently. This means that in the new system the gaps between children are always the same, fixed-size or stretch. To have uneven gaps the children would need to be grouped together in a container like a HStack or a VStack.

The row-between property has changed to vertical-gap, while the col-between property has changed to horizontal-gap.

Spacing

In the new system, spacing no longer applies to children which are within an auto-layout, only to children which are absolutely positioned. Therefore, unlike the current system, , spacing cannot be used to override the parent's padding.

Constraints

The new system no longer has spacing constraints. i.e. no min-left, max-left etc.

Scrolling

In the new system scrolling is part of layout. If the children of a node extend beyond its bounds, Then optional properties for horizontal-scroll and vertical-scroll can be used to offset the children. If supplied these properties override the alignment of the node in the relevant direction.

@geom3trik geom3trik force-pushed the auto-layout branch 2 times, most recently from 8b1d701 to ed46ea0 Compare December 6, 2024 15:09
@geom3trik geom3trik force-pushed the auto-layout branch 2 times, most recently from e1498fb to 891ed64 Compare December 19, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant