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.
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 toalignment: 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 aVStack
.The
row-between
property has changed tovertical-gap
, while thecol-between
property has changed tohorizontal-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
andvertical-scroll
can be used to offset the children. If supplied these properties override the alignment of the node in the relevant direction.