Skip to content

Commit d1dd7bd

Browse files
components: Promote ui/Flex and deprecate isReversed prop (#31297)
* components: Promote ui/Flex and deprecate `isReversed` prop * Fix various imports * Update packages/components/CHANGELOG.md Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl> * Update packages/components/src/flex/README.md Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl> * Reorganize files and add more READMEs * Use absolute paths to other READMEs * Update README.md * Apply suggestions from code review Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
1 parent 76450e6 commit d1dd7bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+156
-723
lines changed

docs/manifest.json

+13-1
Original file line numberDiff line numberDiff line change
@@ -779,10 +779,22 @@
779779
"markdown_source": "../packages/components/src/external-link/README.md",
780780
"parent": "components"
781781
},
782+
{
783+
"title": "FlexBlock",
784+
"slug": "flex-block",
785+
"markdown_source": "../packages/components/src/flex/flex-block/README.md",
786+
"parent": "components"
787+
},
788+
{
789+
"title": "FlexItem",
790+
"slug": "flex-item",
791+
"markdown_source": "../packages/components/src/flex/flex-item/README.md",
792+
"parent": "components"
793+
},
782794
{
783795
"title": "Flex",
784796
"slug": "flex",
785-
"markdown_source": "../packages/components/src/flex/README.md",
797+
"markdown_source": "../packages/components/src/flex/flex/README.md",
786798
"parent": "components"
787799
},
788800
{

packages/components/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
- Drop support for Internet Explorer 11 ([#31110](https://github.com/WordPress/gutenberg/pull/31110)). Learn more at https://make.wordpress.org/core/2021/04/22/ie-11-support-phase-out-plan/.
88
- Increase the minimum Node.js version to v12 matching Long Term Support releases ([#31270](https://github.com/WordPress/gutenberg/pull/31270)). Learn more at https://nodejs.org/en/about/releases/.
99

10+
### Deprecation
11+
12+
- `isReversed` prop in `Flex` component has been deprecated. Use `direction` instead ([#31297](https://github.com/WordPress/gutenberg/pull/31297)).
13+
14+
### Internal
15+
16+
- `Flex`, `FlexBlock`, and `FlexItem` components have been re-written from the ground up ([#31297](https://github.com/WordPress/gutenberg/pull/31297)).
17+
1018
## 13.0.0 (2021-03-17)
1119

1220
### Breaking Change

packages/components/src/card/styles/card-styles.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { HorizontalRule } from '@wordpress/primitives';
1111
/**
1212
* Internal dependencies
1313
*/
14-
import Flex from '../../flex';
14+
import { Flex } from '../../flex';
1515
import { color, space } from '../../utils/style-mixins';
1616

1717
export const styleProps = {

packages/components/src/flex/README.md

-98
This file was deleted.

packages/components/src/flex/block.js

-30
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# FlexBlock (Experimental)
2+
3+
A layout component to contain items of a fixed width within `Flex`.
4+
5+
## Usage
6+
7+
See [`flex/README.md#usage`](/packages/components/src/flex/README.md#usage) for how to use `FlexBlock`.
8+
9+
## Props
10+
11+
### display
12+
13+
**Type**: `[CSSProperties['display']]`
14+
15+
The CSS display property of `FlexBlock`.

packages/components/src/ui/flex/flex-block.js packages/components/src/flex/flex-block/component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Internal dependencies
33
*/
4-
import { createComponent } from '../utils';
5-
import { useFlexBlock } from './use-flex-block';
4+
import { createComponent } from '../../ui/utils';
5+
import { useFlexBlock } from './hook';
66

77
/**
88
* `FlexBlock` is a primitive layout component that adaptively resizes content within layout containers like `Flex`.

packages/components/src/ui/flex/use-flex-block.js packages/components/src/flex/flex-block/hook.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
22
* Internal dependencies
33
*/
4-
import { useContextSystem } from '../context';
5-
import { useFlexItem } from './use-flex-item';
4+
import { useContextSystem } from '../../ui/context';
5+
import { useFlexItem } from '../flex-item';
66

77
/**
8-
* @param {import('../context').ViewOwnProps<import('./types').FlexBlockProps, 'div'>} props
8+
* @param {import('../../ui/context').ViewOwnProps<import('../types').FlexBlockProps, 'div'>} props
99
*/
1010
export function useFlexBlock( props ) {
1111
const otherProps = useContextSystem( props, 'FlexBlock' );
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default } from './component';
2+
export { useFlexBlock } from './hook';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# FlexItem (Experimental)
2+
3+
A layout component to contain items of a fixed width within `Flex`.
4+
5+
## Usage
6+
7+
See [`flex/README.md#usage`](/packages/components/src/flex/README.md#usage) for how to use `FlexItem`.
8+
9+
## Props
10+
11+
### display
12+
13+
**Type**: `[CSSProperties['display']]`
14+
15+
The CSS display property of `FlexItem`.
16+
17+
### isBlock
18+
19+
**Type**: `[boolean]`
20+
21+
Determins if `FlexItem` should render as an adaptive full-width block.

packages/components/src/ui/flex/flex-item.js packages/components/src/flex/flex-item/component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Internal dependencies
33
*/
4-
import { createComponent } from '../utils';
5-
import { useFlexItem } from './use-flex-item';
4+
import { createComponent } from '../../ui/utils';
5+
import { useFlexItem } from './hook';
66

77
/**
88
* `FlexItem` is a primitive layout component that aligns content within layout containers like `Flex`.

packages/components/src/ui/flex/use-flex-item.js packages/components/src/flex/flex-item/hook.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { css, cx } from 'emotion';
66
/**
77
* Internal dependencies
88
*/
9-
import { useContextSystem } from '../context';
10-
import { useFlexContext } from './context';
11-
import * as styles from './styles';
9+
import { useContextSystem } from '../../ui/context';
10+
import { useFlexContext } from '../context';
11+
import * as styles from '../styles';
1212

1313
/**
14-
* @param {import('../context').ViewOwnProps<import('./types').FlexItemProps, 'div'>} props
14+
* @param {import('../../ui/context').ViewOwnProps<import('../types').FlexItemProps, 'div'>} props
1515
*/
1616
export function useFlexItem( props ) {
1717
const {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default } from './component';
2+
export { useFlexItem } from './hook';

packages/components/src/ui/flex/README.md packages/components/src/flex/flex/README.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Flex
1+
# Flex (Experimental)
22

33
`Flex` is a primitive layout component that adaptively aligns child content horizontally or vertically. `Flex` powers components like `HStack` and `VStack`.
44

@@ -7,7 +7,12 @@
77
`Flex` is used with any of it's two sub-components, `FlexItem` and `FlexBlock`.
88

99
```jsx
10-
import { Flex, FlexItem, FlexBlock, Text } from '@wordpress/components/ui';
10+
import {
11+
__experimentalFlex as Flex,
12+
__experimentalFlexBlock as FlexBlock,
13+
__experimentalFlexItem as FlexItem,
14+
__experimentalText as Text
15+
} from '@wordpress/components';
1116

1217
function Example() {
1318
return (
@@ -27,39 +32,39 @@ function Example() {
2732

2833
##### align
2934

30-
**Type**: `CSS['alignItems']`
35+
**Type**: `CSSProperties['alignItems']`
3136

3237
Aligns children using CSS Flexbox `align-items`. Vertically aligns content if the `direction` is `row`, or horizontally aligns content if the `direction` is `column`.
3338

3439
In the example below, `flex-start` will align the children content to the top.
3540

3641
##### direction
3742

38-
**Type**: `FlexDirection`
43+
**Type**: `[ResponsiveCSSValue<CSSProperties['flexDirection']>]`
3944

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

4247
##### expanded
4348

44-
**Type**: `boolean`
49+
**Type**: `[boolean]`
4550

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

4853
##### gap
4954

50-
**Type**: `number`
55+
**Type**: `[number | string]`
5156

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

5459
##### justify
5560

56-
**Type**: `CSS['justifyContent']`
61+
**Type**: `[CSSProperties['justifyContent']]`
5762

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

6166
##### wrap
6267

63-
**Type**: `boolean`
68+
**Type**: `[boolean]`
6469

6570
Determines if children should wrap.

packages/components/src/ui/flex/flex.js packages/components/src/flex/flex/component.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/**
22
* Internal dependencies
33
*/
4-
import { contextConnect } from '../context';
5-
import { useFlex } from './use-flex';
6-
import { FlexContext } from './context';
7-
import { View } from '../view';
4+
import { contextConnect } from '../../ui/context';
5+
import { useFlex } from './hook';
6+
import { FlexContext } from './../context';
7+
import { View } from '../../ui/view';
88

99
/**
10-
* @param {import('../context').ViewOwnProps<import('./types').FlexProps, 'div'>} props
10+
* @param {import('../../ui/context').ViewOwnProps<import('../types').FlexProps, 'div'>} props
1111
* @param {import('react').Ref<any>} forwardedRef
1212
*/
1313
function Flex( props, forwardedRef ) {

0 commit comments

Comments
 (0)