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

Components: HStack, VStack, ZStack #22

Closed
ItsJonQ opened this issue Aug 11, 2020 · 3 comments
Closed

Components: HStack, VStack, ZStack #22

ItsJonQ opened this issue Aug 11, 2020 · 3 comments
Assignees

Comments

@ItsJonQ
Copy link
Owner

ItsJonQ commented Aug 11, 2020

1 1
(Source: Design+Code)

Recently, I started poking around with Swift UI. My, what a wonderful language + workflow it has!

One of the main primitives is their HStack, VStack, and ZStack Views (aka. Components).

After playing around with it, I thought they would be a welcomed edition to this library as well.

It looks like I'm not the only one who would like this for React:

https://twitter.com/dan_abramov/status/1286433774641852417

Flex

We currently have something similar! The Flex component.

The H/V/Z Stack components could use Flex as a their base, and sprinkle some adjustments to achieve the desired effects.

API/Workflow

One of the key things is injecting Spacer() (Swift UI) within one of the stacks to help with layout.

We can achieve something similar:

<HStack>
  <Text>Hello</Text>
  <Spacer />
  <Button>Next</Button>
</HStack>
<VStack>
  <View>Top</View>
  <Spacer />
  <View>Bottom</View>
</VStack>
<ZStack>
  <View>Layer 0</View>
  <View>Layer 1</View>
</ZStack>

We'll need to adjust the <Spacer /> component to perform double duty to work intelligently within one of these Stack components.

ZStack will be a very interesting one! :)

@simison
Copy link

simison commented Aug 12, 2020

This would make an interesting technical basis for a block: WordPress/gutenberg#24473

@ItsJonQ
Copy link
Owner Author

ItsJonQ commented Aug 12, 2020

Added with this update!
2ffa46c

@ItsJonQ ItsJonQ closed this as completed Aug 12, 2020
@ItsJonQ ItsJonQ self-assigned this Aug 12, 2020
@ItsJonQ
Copy link
Owner Author

ItsJonQ commented Aug 12, 2020

Update! Wrote a blog post about it here:
https://g2components.wordpress.com/2020/08/12/creating-smart-layout-components-hstack-vstack-and-zstack/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants