-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Components: Update Flex #28609
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
Merged
Merged
Components: Update Flex #28609
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
654f135
Components: Add G2 Flex
sarayourfriend 854f787
Add types to current Flex
sarayourfriend bb45238
Adapter G2 flex components
sarayourfriend 6b730f2
Fix tests
sarayourfriend dd9e4a5
Components: Move G2 Flex into UI
sarayourfriend bd20f81
Update with latest from g2
sarayourfriend 52a2e12
Fix integration of `ui/flex` with `InputControl`
ba79199
Merge branch 'add/g2-flex' of github.com:WordPress/gutenberg into add…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { withNext } from '../ui/context'; | ||
| import { | ||
| Flex as NextFlex, | ||
| FlexItem as NextFlexItem, | ||
| FlexBlock as NextFlexBlock, | ||
| } from '../ui/flex'; | ||
|
|
||
| const Flex = process.env.COMPONENT_SYSTEM_PHASE === 1 ? NextFlex : undefined; | ||
| const FlexBlock = | ||
| process.env.COMPONENT_SYSTEM_PHASE === 1 ? NextFlexBlock : undefined; | ||
| const FlexItem = | ||
| process.env.COMPONENT_SYSTEM_PHASE === 1 ? NextFlexItem : undefined; | ||
|
|
||
| /** | ||
| * @param {import('./index').Props} props Current props. | ||
| * @return {import('../ui/flex/types').FlexProps} Next props. | ||
| */ | ||
| const flexAdapter = ( { isReversed, ...restProps } ) => ( { | ||
| // There's no equivalent for `direction` on the original component so we can just translate `isReversed` to it | ||
| direction: isReversed ? 'row-reverse' : 'row', | ||
| ...restProps, | ||
| // There's an HTML attribute named `wrap` that will exist in `restProps` so we need to set it to undefined so the default behavior of the next component takes over | ||
| wrap: undefined, | ||
| } ); | ||
|
|
||
| /** | ||
| * @param {import('./item').Props} props Current props. | ||
| * @return {import('../ui/flex/types').FlexItemProps} Next props. | ||
| */ | ||
| const flexItemAdapter = ( props ) => ( { | ||
| ...props, | ||
| // ensure these are undefined so the default takes over | ||
| isBlock: undefined, | ||
| display: undefined, | ||
| } ); | ||
|
|
||
| /** | ||
| * @param {import('./block').Props} props Current props. | ||
| * @return {import('../ui/flex/types').FlexBlockProps} Next props. | ||
| */ | ||
| const flexBlockAdapter = ( props ) => ( { | ||
| ...props, | ||
| // ensure this is undefined so the default takes over | ||
| display: undefined, | ||
| } ); | ||
|
|
||
| /* eslint-disable jsdoc/valid-types */ | ||
| /** | ||
| * @param {import('react').ForwardRefExoticComponent<import('./index').Props>} Current | ||
| */ | ||
| /* eslint-enable jsdoc/valid-types */ | ||
| export function withNextFlex( Current ) { | ||
| return withNext( Current, Flex, 'WPComponentsFlex', flexAdapter ); | ||
| } | ||
|
|
||
| /* eslint-disable jsdoc/valid-types */ | ||
| /** | ||
| * @param {import('react').ForwardRefExoticComponent<import('./item').Props>} Current | ||
| */ | ||
| /* eslint-enable jsdoc/valid-types */ | ||
| export function withNextFlexItem( Current ) { | ||
| return withNext( Current, FlexItem, 'WPComponentsFlex', flexItemAdapter ); | ||
| } | ||
|
|
||
| /* eslint-disable jsdoc/valid-types */ | ||
| /** | ||
| * @param {import('react').ForwardRefExoticComponent<import('./block').Props>} Current | ||
| */ | ||
| /* eslint-enable jsdoc/valid-types */ | ||
| export function withNextFlexBlock( Current ) { | ||
| return withNext( Current, FlexBlock, 'WPComponentsFlex', flexBlockAdapter ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.