Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/components/src/ui/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export * from './flex';
export * from './grid';
export * from './h-stack';
export * from './text';
export * from './truncate';
export * from './v-stack';
export * from './view';
123 changes: 123 additions & 0 deletions packages/components/src/ui/v-stack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# VStack

`VStack` (or Vertical Stack) is a layout component that arranges child elements in a vertical line.

## Usage

`VStack` can render anything inside.

```jsx live
import { VStack, Text, View } from '@wp-g2/components';
import { ui } from '@wp-g2/styles';

function Example() {
return (
<VStack css={[ui.frame.height(200)]}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we discussed avoiding these css props in public components right? what's the status of that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good point, we should avoid it in the examples as well. I'll make a note to clean these up as we go along

cc/ @ItsJonQ

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sarayourfriend Good call. We'll remove it from the examples

<View css={[ui.background.blue]}>
<Text>Ana</Text>
</View>
<View css={[ui.background.blue]}>
<Text>Elsa</Text>
</View>
<View css={[ui.background.blue]}>
<Text>Olaf</Text>
</View>
</VStack>
);
}
```

## Props

##### alignment

**Type**: `HStackAlignment`,`CSS['alignItems']`

Determines how the child elements are aligned.

- `top`: Aligns content to the top.
- `topLeft`: Aligns content to the top/left.
- `topRight`: Aligns content to the top/right.
- `left`: Aligns content to the left.
- `center`: Aligns content to the center.
- `right`: Aligns content to the right.
- `bottom`: Aligns content to the bottom.
- `bottomLeft`: Aligns content to the bottom/left.
- `bottomRight`: Aligns content to the bottom/right.
- `edge`: Aligns content to the edges of the container.
- `stretch`: Stretches content to the edges of the container.

##### direction

**Type**: `FlexDirection`

The direction flow of the children content can be adjusted with `direction`. `column` will align children vertically and `row` will align children horizontally.

##### expanded

**Type**: `boolean`

Expands to the maximum available width (if horizontal) or height (if vertical).

##### justify

**Type**: `CSS['justifyContent']`

Horizontally aligns content if the `direction` is `row`, or vertically aligns content if the `direction` is `column`.
In the example below, `flex-start` will align the children content to the left.

##### spacing

**Type**: `CSS['width']`

The amount of space between each child element. Spacing in between each child can be adjusted by using `spacing`.
The value of `spacing` works as a multiplier to the library's grid system (base of `4px`).

##### wrap

**Type**: `boolean`

Determines if children should wrap.

## Spacer

When a `Spacer` is used within an `VStack`, the `Spacer` adaptively expands to take up the remaining space.

```jsx
function Example() {
return (
<VStack css={[ui.frame.height(200)]}>
<View css={[ui.background.blue]}>
<Text>Ana</Text>
</View>
<Spacer css={[ui.background.blue]}>
<Text>Elsa</Text>
</Spacer>
<View css={[ui.background.blue]}>
<Text>Olaf</Text>
</View>
</VStack>
);
}
```

`Spacer` can also be used in-between items to push them apart.

```jsx live
function Example() {
return (
<VStack css={[ui.frame.height(200)]}>
<View css={[ui.background.blue]}>
<Text>Ana</Text>
</View>
<Spacer />
<View css={[ui.background.blue]}>
<Text>Elsa</Text>
</View>
<View css={[ui.background.blue]}>
<Text>Olaf</Text>
</View>
</VStack>
);
}
```
3 changes: 3 additions & 0 deletions packages/components/src/ui/v-stack/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as VStack } from './v-stack';

export * from './use-v-stack';
Loading