From 981578e9f2d42dd7721c7326fa74347f754fcf3a Mon Sep 17 00:00:00 2001 From: Sara Marcondes Date: Fri, 5 Feb 2021 11:43:13 -0800 Subject: [PATCH 1/5] Rename hstack stories file to match Gutenberg --- .../src/ui/h-stack/stories/{HStack.stories.js => index.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/components/src/ui/h-stack/stories/{HStack.stories.js => index.js} (100%) diff --git a/packages/components/src/ui/h-stack/stories/HStack.stories.js b/packages/components/src/ui/h-stack/stories/index.js similarity index 100% rename from packages/components/src/ui/h-stack/stories/HStack.stories.js rename to packages/components/src/ui/h-stack/stories/index.js From 0cecc59d2691a67ac52e36522f9c75ebe09c2bb3 Mon Sep 17 00:00:00 2001 From: Sara Marcondes Date: Fri, 5 Feb 2021 11:49:43 -0800 Subject: [PATCH 2/5] Components: Add G2 VStack --- packages/components/src/ui/v-stack/README.md | 165 +++++++ packages/components/src/ui/v-stack/index.js | 3 + .../v-stack/test/__snapshots__/index.js.snap | 432 ++++++++++++++++++ .../components/src/ui/v-stack/test/index.js | 42 ++ packages/components/src/ui/v-stack/types.ts | 47 ++ .../components/src/ui/v-stack/use-v-stack.js | 28 ++ packages/components/src/ui/v-stack/v-stack.js | 37 ++ 7 files changed, 754 insertions(+) create mode 100644 packages/components/src/ui/v-stack/README.md create mode 100644 packages/components/src/ui/v-stack/index.js create mode 100644 packages/components/src/ui/v-stack/test/__snapshots__/index.js.snap create mode 100644 packages/components/src/ui/v-stack/test/index.js create mode 100644 packages/components/src/ui/v-stack/types.ts create mode 100644 packages/components/src/ui/v-stack/use-v-stack.js create mode 100644 packages/components/src/ui/v-stack/v-stack.js diff --git a/packages/components/src/ui/v-stack/README.md b/packages/components/src/ui/v-stack/README.md new file mode 100644 index 00000000000000..432713d234a915 --- /dev/null +++ b/packages/components/src/ui/v-stack/README.md @@ -0,0 +1,165 @@ +--- +title: VStack +description: 'VStack (or Vertical Stack) is a layout component that arranges child elements in a vertical line.' +type: layout +slug: /components/vstack/ +keywords: ['vstack', 'layout', 'vertical', 'align'] +--- + +# VStack + +`VStack` (or Vertical Stack) is a layout component that arranges child elements in a vertical line. + +## Table of contents + + + + +- [Usage](#usage) +- [Props](#props) +- [Spacer](#spacer) +- [See Also](#see-also) + + + + + + + + + + +## 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 ( + + + Ana + + + Elsa + + + Olaf + + + ); +} +``` + +## 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 live +import { VStack, Spacer, Text, View } from '@wp-g2/components'; +import { ui } from '@wp-g2/styles'; + +function Example() { + return ( + + + Ana + + + Elsa + + + Olaf + + + ); +} +``` + +`Spacer` can also be used in-between items to push them apart. + +```jsx live +import { VStack, Spacer, Text, View } from '@wp-g2/components'; +import { ui } from '@wp-g2/styles'; + +function Example() { + return ( + + + Ana + + + + Elsa + + + Olaf + + + ); +} +``` + +## See Also + +- [`HStack`](../hstack/) +- [`Flex`](../flex/) +- [`Spacer`](../spacer/) diff --git a/packages/components/src/ui/v-stack/index.js b/packages/components/src/ui/v-stack/index.js new file mode 100644 index 00000000000000..780ac6bd4811e2 --- /dev/null +++ b/packages/components/src/ui/v-stack/index.js @@ -0,0 +1,3 @@ +export { default as VStack } from './v-stack'; + +export * from './use-v-stack'; diff --git a/packages/components/src/ui/v-stack/test/__snapshots__/index.js.snap b/packages/components/src/ui/v-stack/test/__snapshots__/index.js.snap new file mode 100644 index 00000000000000..fcffa8f4477808 --- /dev/null +++ b/packages/components/src/ui/v-stack/test/__snapshots__/index.js.snap @@ -0,0 +1,432 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`props should render Spacer 1`] = ` +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + --wp-g2-flex-gap: calc(4px * 5); + --wp-g2-flex-gap: calc(var(--wp-g2-grid-base) * 5); + --wp-g2-flex-item-display: block; + --wp-g2-flex-item-margin-bottom: calc(4px * 2); + --wp-g2-flex-item-margin-bottom: var(--wp-g2-flex-gap); + --wp-g2-flex-item-margin-right: 0; + --wp-g2-flex-item-margin-left: 0; + -webkit-align-items: normal; + -webkit-box-align: normal; + -ms-flex-align: normal; + align-items: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + -webkit-box-pack: justify; + -webkit-justify-content: space-between; + -ms-flex-pack: justify; + justify-content: space-between; + --wp-g2-h-stack-spacing: calc(4px * 5); + --wp-g2-h-stack-spacing: calc(var(--wp-g2-grid-base) * 5); +} + +@media (prefers-reduced-motion) { + .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none!important; + transition: none!important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none!important; + transition: none!important; +} + +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>*+*:not(marquee) { + margin-top: calc(4px * 5); + margin-top: calc(var(--wp-g2-grid-base) * 5); +} + +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>* { + min-height: 0; +} + +.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; +} + +@media (prefers-reduced-motion) { + .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { + -webkit-transition: none!important; + transition: none!important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { + -webkit-transition: none!important; + transition: none!important; +} + +.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; + display: block; + max-height: 100%; + max-width: 100%; + min-height: 0; + min-width: 0; + display: var(--wp-g2-flex-item-display); + -webkit-flex: 1; + -ms-flex: 1; + flex: 1; +} + +@media (prefers-reduced-motion) { + .emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { + -webkit-transition: none!important; + transition: none!important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { + -webkit-transition: none!important; + transition: none!important; +} + +
+
+
+
+
+`; + +exports[`props should render alignment 1`] = ` +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + --wp-g2-flex-gap: calc(4px * 2); + --wp-g2-flex-gap: calc(var(--wp-g2-grid-base) * 2); + --wp-g2-flex-item-display: block; + --wp-g2-flex-item-margin-bottom: calc(4px * 2); + --wp-g2-flex-item-margin-bottom: var(--wp-g2-flex-gap); + --wp-g2-flex-item-margin-right: 0; + --wp-g2-flex-item-margin-left: 0; + -webkit-align-items: normal; + -webkit-box-align: normal; + -ms-flex-align: normal; + align-items: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + --wp-g2-h-stack-spacing: calc(4px * 2); + --wp-g2-h-stack-spacing: calc(var(--wp-g2-grid-base) * 2); +} + +@media (prefers-reduced-motion) { + .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none!important; + transition: none!important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none!important; + transition: none!important; +} + +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>*+*:not(marquee) { + margin-top: calc(4px * 2); + margin-top: calc(var(--wp-g2-grid-base) * 2); +} + +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>* { + min-height: 0; +} + +.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; +} + +@media (prefers-reduced-motion) { + .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { + -webkit-transition: none!important; + transition: none!important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { + -webkit-transition: none!important; + transition: none!important; +} + +
+
+
+
+`; + +exports[`props should render correctly 1`] = ` +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + --wp-g2-flex-gap: calc(4px * 2); + --wp-g2-flex-gap: calc(var(--wp-g2-grid-base) * 2); + --wp-g2-flex-item-display: block; + --wp-g2-flex-item-margin-bottom: calc(4px * 2); + --wp-g2-flex-item-margin-bottom: var(--wp-g2-flex-gap); + --wp-g2-flex-item-margin-right: 0; + --wp-g2-flex-item-margin-left: 0; + -webkit-align-items: normal; + -webkit-box-align: normal; + -ms-flex-align: normal; + align-items: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + -webkit-box-pack: justify; + -webkit-justify-content: space-between; + -ms-flex-pack: justify; + justify-content: space-between; + --wp-g2-h-stack-spacing: calc(4px * 2); + --wp-g2-h-stack-spacing: calc(var(--wp-g2-grid-base) * 2); +} + +@media (prefers-reduced-motion) { + .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none!important; + transition: none!important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none!important; + transition: none!important; +} + +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>*+*:not(marquee) { + margin-top: calc(4px * 2); + margin-top: calc(var(--wp-g2-grid-base) * 2); +} + +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>* { + min-height: 0; +} + +.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; +} + +@media (prefers-reduced-motion) { + .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { + -webkit-transition: none!important; + transition: none!important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { + -webkit-transition: none!important; + transition: none!important; +} + +
+
+
+
+`; + +exports[`props should render spacing 1`] = ` +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + --wp-g2-flex-gap: calc(4px * 5); + --wp-g2-flex-gap: calc(var(--wp-g2-grid-base) * 5); + --wp-g2-flex-item-display: block; + --wp-g2-flex-item-margin-bottom: calc(4px * 2); + --wp-g2-flex-item-margin-bottom: var(--wp-g2-flex-gap); + --wp-g2-flex-item-margin-right: 0; + --wp-g2-flex-item-margin-left: 0; + -webkit-align-items: normal; + -webkit-box-align: normal; + -ms-flex-align: normal; + align-items: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + -webkit-box-pack: justify; + -webkit-justify-content: space-between; + -ms-flex-pack: justify; + justify-content: space-between; + --wp-g2-h-stack-spacing: calc(4px * 5); + --wp-g2-h-stack-spacing: calc(var(--wp-g2-grid-base) * 5); +} + +@media (prefers-reduced-motion) { + .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none!important; + transition: none!important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none!important; + transition: none!important; +} + +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>*+*:not(marquee) { + margin-top: calc(4px * 5); + margin-top: calc(var(--wp-g2-grid-base) * 5); +} + +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>* { + min-height: 0; +} + +.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; +} + +@media (prefers-reduced-motion) { + .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { + -webkit-transition: none!important; + transition: none!important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { + -webkit-transition: none!important; + transition: none!important; +} + +
+
+
+
+`; diff --git a/packages/components/src/ui/v-stack/test/index.js b/packages/components/src/ui/v-stack/test/index.js new file mode 100644 index 00000000000000..cfb2df75e0f469 --- /dev/null +++ b/packages/components/src/ui/v-stack/test/index.js @@ -0,0 +1,42 @@ +/** + * External dependencies + */ +import { render } from '@testing-library/react'; + +/** + * Internal dependencies + */ +import { View } from '../../view'; +import { VStack } from '../index'; + +describe( 'props', () => { + test( 'should render correctly', () => { + const { container } = render( + + + + + ); + expect( container.firstChild ).toMatchSnapshot(); + } ); + + test( 'should render alignment', () => { + const { container } = render( + + + + + ); + expect( container.firstChild ).toMatchSnapshot(); + } ); + + test( 'should render spacing', () => { + const { container } = render( + + + + + ); + expect( container.firstChild ).toMatchSnapshot(); + } ); +} ); diff --git a/packages/components/src/ui/v-stack/types.ts b/packages/components/src/ui/v-stack/types.ts new file mode 100644 index 00000000000000..36153e0a1ff2f7 --- /dev/null +++ b/packages/components/src/ui/v-stack/types.ts @@ -0,0 +1,47 @@ +import { CSSProperties } from 'react'; +import { HStackAlignment, Props as HStackProps } from '../h-stack/types'; + +export type Props = HStackProps & { + /** + * @example + *```jsx + * function Example() { + * return ( + * + * + * Ana + * + * + * Elsa + * + * + * Olaf + * + * + * ); + * } + *``` + */ + alignment?: HStackAlignment | CSSProperties[ 'alignItems' ]; + /** + * @example + * ```jsx + * function Example() { + * return ( + * + * + * Ana + * + * + * Elsa + * + * + * Olaf + * + * + * ); + * } + *``` + */ + spacing?: CSSProperties[ 'width' ]; +}; diff --git a/packages/components/src/ui/v-stack/use-v-stack.js b/packages/components/src/ui/v-stack/use-v-stack.js new file mode 100644 index 00000000000000..54b27f4ec76fd9 --- /dev/null +++ b/packages/components/src/ui/v-stack/use-v-stack.js @@ -0,0 +1,28 @@ +/** + * External dependencies + */ +import { useContextSystem } from '@wp-g2/context'; + +/** + * Internal dependencies + */ +import { useHStack } from '../h-stack'; + +/** + * + * @param {import('@wp-g2/create-styles').ViewOwnProps} props + */ +export function useVStack( props ) { + const { expanded = false, ...otherProps } = useContextSystem( + props, + 'VStack' + ); + + const hStackProps = useHStack( { + direction: 'column', + expanded, + ...otherProps, + } ); + + return hStackProps; +} diff --git a/packages/components/src/ui/v-stack/v-stack.js b/packages/components/src/ui/v-stack/v-stack.js new file mode 100644 index 00000000000000..0f1e4a2c778860 --- /dev/null +++ b/packages/components/src/ui/v-stack/v-stack.js @@ -0,0 +1,37 @@ +/** + * Internal dependencies + */ +import { createComponent } from '../utils'; +import { useVStack } from './use-v-stack'; + +/** + * `VStack` (or Vertical Stack) is a layout component that arranges child elements in a vertical line. + * + * `VStack` can render anything inside. + * + * @example + * ```jsx + * function Example() { + * return ( + * + * + * Ana + * + * + * Elsa + * + * + * Olaf + * + * + * ); + * } + * ``` + */ +const VStack = createComponent( { + as: 'div', + useHook: useVStack, + name: 'VStack', +} ); + +export default VStack; From a087692345d3a7a67c864f5bf65e68350463cc5d Mon Sep 17 00:00:00 2001 From: Sara Marcondes Date: Fri, 5 Feb 2021 11:54:29 -0800 Subject: [PATCH 3/5] Clean up README --- packages/components/src/ui/v-stack/README.md | 44 +------------------- 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/packages/components/src/ui/v-stack/README.md b/packages/components/src/ui/v-stack/README.md index 432713d234a915..882465501ad9ef 100644 --- a/packages/components/src/ui/v-stack/README.md +++ b/packages/components/src/ui/v-stack/README.md @@ -1,34 +1,7 @@ ---- -title: VStack -description: 'VStack (or Vertical Stack) is a layout component that arranges child elements in a vertical line.' -type: layout -slug: /components/vstack/ -keywords: ['vstack', 'layout', 'vertical', 'align'] ---- - # VStack `VStack` (or Vertical Stack) is a layout component that arranges child elements in a vertical line. -## Table of contents - - - - -- [Usage](#usage) -- [Props](#props) -- [Spacer](#spacer) -- [See Also](#see-also) - - - - - - - - - - ## Usage `VStack` can render anything inside. @@ -106,17 +79,11 @@ The value of `spacing` works as a multiplier to the library's grid system (base 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 live -import { VStack, Spacer, Text, View } from '@wp-g2/components'; -import { ui } from '@wp-g2/styles'; - +```jsx function Example() { return ( @@ -137,9 +104,6 @@ function Example() { `Spacer` can also be used in-between items to push them apart. ```jsx live -import { VStack, Spacer, Text, View } from '@wp-g2/components'; -import { ui } from '@wp-g2/styles'; - function Example() { return ( @@ -157,9 +121,3 @@ function Example() { ); } ``` - -## See Also - -- [`HStack`](../hstack/) -- [`Flex`](../flex/) -- [`Spacer`](../spacer/) From b5994e441fa81faa452e2921b3729e9703271264 Mon Sep 17 00:00:00 2001 From: Sara Marcondes Date: Fri, 5 Feb 2021 11:55:40 -0800 Subject: [PATCH 4/5] Add v stack and h stack to the ui/index --- packages/components/src/ui/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/components/src/ui/index.js b/packages/components/src/ui/index.js index bd1d80d9b124a8..ba099d22a5dfa5 100644 --- a/packages/components/src/ui/index.js +++ b/packages/components/src/ui/index.js @@ -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'; From 0dd5cf2b81d69ca5653d9021b08c105251970b98 Mon Sep 17 00:00:00 2001 From: Jon Q Date: Mon, 8 Feb 2021 15:30:31 -0500 Subject: [PATCH 5/5] Update VStack snapshots --- .../v-stack/test/__snapshots__/index.js.snap | 279 +++++------------- 1 file changed, 71 insertions(+), 208 deletions(-) diff --git a/packages/components/src/ui/v-stack/test/__snapshots__/index.js.snap b/packages/components/src/ui/v-stack/test/__snapshots__/index.js.snap index fcffa8f4477808..ffa9e3846728df 100644 --- a/packages/components/src/ui/v-stack/test/__snapshots__/index.js.snap +++ b/packages/components/src/ui/v-stack/test/__snapshots__/index.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`props should render Spacer 1`] = ` +exports[`props should render alignment 1`] = ` .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { box-sizing: border-box; -moz-osx-font-smoothing: grayscale; @@ -12,133 +12,21 @@ exports[`props should render Spacer 1`] = ` font-weight: normal; font-weight: var(--wp-g2-font-weight); margin: 0; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - --wp-g2-flex-gap: calc(4px * 5); - --wp-g2-flex-gap: calc(var(--wp-g2-grid-base) * 5); - --wp-g2-flex-item-display: block; - --wp-g2-flex-item-margin-bottom: calc(4px * 2); - --wp-g2-flex-item-margin-bottom: var(--wp-g2-flex-gap); - --wp-g2-flex-item-margin-right: 0; - --wp-g2-flex-item-margin-left: 0; - -webkit-align-items: normal; - -webkit-box-align: normal; - -ms-flex-align: normal; - align-items: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; - -webkit-box-pack: justify; - -webkit-justify-content: space-between; - -ms-flex-pack: justify; - justify-content: space-between; - --wp-g2-h-stack-spacing: calc(4px * 5); - --wp-g2-h-stack-spacing: calc(var(--wp-g2-grid-base) * 5); } @media (prefers-reduced-motion) { .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { - -webkit-transition: none!important; - transition: none!important; + -webkit-transition: none !important; + transition: none !important; } } [data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { - -webkit-transition: none!important; - transition: none!important; -} - -.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>*+*:not(marquee) { - margin-top: calc(4px * 5); - margin-top: calc(var(--wp-g2-grid-base) * 5); -} - -.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>* { - min-height: 0; -} - -.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { - box-sizing: border-box; - -moz-osx-font-smoothing: grayscale; - -webkit-font-smoothing: antialiased; - font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; - font-family: var(--wp-g2-font-family); - font-size: 13px; - font-size: var(--wp-g2-font-size); - font-weight: normal; - font-weight: var(--wp-g2-font-weight); - margin: 0; -} - -@media (prefers-reduced-motion) { - .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { - -webkit-transition: none!important; - transition: none!important; - } -} - -[data-system-ui-reduced-motion-mode="true"] .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { - -webkit-transition: none!important; - transition: none!important; + -webkit-transition: none !important; + transition: none !important; } .emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { - box-sizing: border-box; - -moz-osx-font-smoothing: grayscale; - -webkit-font-smoothing: antialiased; - font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; - font-family: var(--wp-g2-font-family); - font-size: 13px; - font-size: var(--wp-g2-font-size); - font-weight: normal; - font-weight: var(--wp-g2-font-weight); - margin: 0; - display: block; - max-height: 100%; - max-width: 100%; - min-height: 0; - min-width: 0; - display: var(--wp-g2-flex-item-display); - -webkit-flex: 1; - -ms-flex: 1; - flex: 1; -} - -@media (prefers-reduced-motion) { - .emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { - -webkit-transition: none!important; - transition: none!important; - } -} - -[data-system-ui-reduced-motion-mode="true"] .emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { - -webkit-transition: none!important; - transition: none!important; -} - -
-
-
-
-
-`; - -exports[`props should render alignment 1`] = ` -.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { box-sizing: border-box; -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; @@ -176,67 +64,42 @@ exports[`props should render alignment 1`] = ` } @media (prefers-reduced-motion) { - .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { - -webkit-transition: none!important; - transition: none!important; + .emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { + -webkit-transition: none !important; + transition: none !important; } } -[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { - -webkit-transition: none!important; - transition: none!important; +[data-system-ui-reduced-motion-mode="true"] .emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { + -webkit-transition: none !important; + transition: none !important; } -.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>*+*:not(marquee) { +.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 > * + *:not(marquee) { margin-top: calc(4px * 2); margin-top: calc(var(--wp-g2-grid-base) * 2); } -.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>* { +.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 > * { min-height: 0; } -.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { - box-sizing: border-box; - -moz-osx-font-smoothing: grayscale; - -webkit-font-smoothing: antialiased; - font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; - font-family: var(--wp-g2-font-family); - font-size: 13px; - font-size: var(--wp-g2-font-size); - font-weight: normal; - font-weight: var(--wp-g2-font-weight); - margin: 0; -} - -@media (prefers-reduced-motion) { - .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { - -webkit-transition: none!important; - transition: none!important; - } -} - -[data-system-ui-reduced-motion-mode="true"] .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { - -webkit-transition: none!important; - transition: none!important; -} -
`; exports[`props should render correctly 1`] = ` -.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { +.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { box-sizing: border-box; -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; @@ -274,27 +137,27 @@ exports[`props should render correctly 1`] = ` } @media (prefers-reduced-motion) { - .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { - -webkit-transition: none!important; - transition: none!important; + .emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { + -webkit-transition: none !important; + transition: none !important; } } -[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { - -webkit-transition: none!important; - transition: none!important; +[data-system-ui-reduced-motion-mode="true"] .emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { + -webkit-transition: none !important; + transition: none !important; } -.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>*+*:not(marquee) { +.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 > * + *:not(marquee) { margin-top: calc(4px * 2); margin-top: calc(var(--wp-g2-grid-base) * 2); } -.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>* { +.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 > * { min-height: 0; } -.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { +.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { box-sizing: border-box; -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; @@ -308,27 +171,27 @@ exports[`props should render correctly 1`] = ` } @media (prefers-reduced-motion) { - .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { - -webkit-transition: none!important; - transition: none!important; + .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; } } -[data-system-ui-reduced-motion-mode="true"] .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { - -webkit-transition: none!important; - transition: none!important; +[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; }
`; @@ -345,6 +208,31 @@ exports[`props should render spacing 1`] = ` font-weight: normal; font-weight: var(--wp-g2-font-weight); margin: 0; +} + +@media (prefers-reduced-motion) { + .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; + } +} + +[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { + -webkit-transition: none !important; + transition: none !important; +} + +.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; + font-family: var(--wp-g2-font-family); + font-size: 13px; + font-size: var(--wp-g2-font-size); + font-weight: normal; + font-weight: var(--wp-g2-font-weight); + margin: 0; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -372,61 +260,36 @@ exports[`props should render spacing 1`] = ` } @media (prefers-reduced-motion) { - .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { - -webkit-transition: none!important; - transition: none!important; + .emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { + -webkit-transition: none !important; + transition: none !important; } } -[data-system-ui-reduced-motion-mode="true"] .emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0 { - -webkit-transition: none!important; - transition: none!important; +[data-system-ui-reduced-motion-mode="true"] .emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 { + -webkit-transition: none !important; + transition: none !important; } -.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>*+*:not(marquee) { +.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 > * + *:not(marquee) { margin-top: calc(4px * 5); margin-top: calc(var(--wp-g2-grid-base) * 5); } -.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0.emotion-0>* { +.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2.emotion-2 > * { min-height: 0; } -.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { - box-sizing: border-box; - -moz-osx-font-smoothing: grayscale; - -webkit-font-smoothing: antialiased; - font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif; - font-family: var(--wp-g2-font-family); - font-size: 13px; - font-size: var(--wp-g2-font-size); - font-weight: normal; - font-weight: var(--wp-g2-font-weight); - margin: 0; -} - -@media (prefers-reduced-motion) { - .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { - -webkit-transition: none!important; - transition: none!important; - } -} - -[data-system-ui-reduced-motion-mode="true"] .emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1.emotion-1 { - -webkit-transition: none!important; - transition: none!important; -} -
`;