-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[Mobile] Refactor gallery as nested image blocks #31306
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
glendaviesnz
merged 48 commits into
refactor/gallery-to-nested-image-blocks
from
rnmobile/refactor/gallery-as-nested-image-blocks
Aug 3, 2021
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
1521f52
Move native v1 Gallery components to v1 directory
mkevins 8639891
Use v1 defaultColumnsNumber in native v1 gallery
mkevins 91c09b8
Make onFocus optional in MediaPlaceholder
mkevins ffc22e7
Add useInnerBlocksProps hook
mkevins e688131
Enable __experimentalGalleryRefactor flag under __DEV__
mkevins c8fbc35
Add WIP v2 gallery
mkevins 2f44f58
Add numColumns to block-list flat list
mkevins 9fd5897
Temporarily comment out spinner for pending imagesize option
mkevins d646d59
Fix spacing
mkevins 59ea082
Adjust styles to avoid appender overlap
mkevins 683af04
Add gallery caption
mkevins a520018
Fix lint
mkevins 1f0073d
Fix sass lint
mkevins 4e3d981
Merge branch 'refactor/gallery-to-nested-image-blocks' into rnmobile/…
mkevins 77091e2
Merge branch 'refactor/gallery-to-nested-image-blocks' into rnmobile/…
mkevins 2c6e317
[Mobile] - Refactor gallery - cherry pick image edit native (#31826)
mkevins 3221e23
Cherry-pick BlockListItem changes
mkevins 7616231
Return early from render instead of renderContent
mkevins 4d235fd
Cherry-pick plumb blockProps through BlockListBlock
mkevins df286d8
Cherry-pick add GridItem
mkevins f5ff38d
Cherry-pick BlockList
mkevins 0e777c6
Cherry-pick StylePreview key change
mkevins acfcb7f
Cherry-pick blockProps and gridProperties in InnerBlocks
mkevins 30d20b1
Use sass var for galleryAppender padding
mkevins 8e89a84
Cherry-pick remaining gallery changes
mkevins 2de17c3
Remove numColumns
mkevins 931184a
Remove blockProps
mkevins e96cd3e
Fix gallery block.json (delete extra comma)
mkevins 5c78270
Remove unused imageCrop
mkevins 3c2f144
Merge branch 'refactor/gallery-to-nested-image-blocks' into rnmobile/…
mkevins 46c8da7
Merge branch 'refactor/gallery-to-nested-image-blocks-upstream' into …
mkevins 946aeab
Merge branch 'refactor/gallery-to-nested-image-blocks' into rnmobile/…
mkevins fb34126
Merge branch 'refactor/gallery-to-nested-image-blocks-upstream' into …
mkevins 0527d39
Add back blockWidth contentContainerStyles in block list
mkevins a8c1f0e
Use boolean flags for variants in Platform module
mkevins 1c1dc9d
Use boolean Platform flags
mkevins 5f35c4c
Only render imageSizeOptions loading spinner on web
mkevins 57a01f7
Add default for destructured context in image edit
mkevins 0052b11
Temporarily hard-code experimenal gallery refactor flag to true
mkevins 0d5fb18
Revert "Temporarily hard-code experimenal gallery refactor flag to true"
mkevins 03d730b
Update experiments page with warning about the mobile app version
mkevins 93fd471
Merge branch 'refactor/gallery-to-nested-image-blocks-upstream' into …
mkevins 9ca69ea
Merge branch 'refactor/gallery-to-nested-image-blocks' into rnmobile/…
antonis 475f976
Changes new gallery flag name
antonis 5387ca0
Updates mobile warning
antonis ec158f7
Removes the imageCount attribute
antonis 53ba376
Remove the isGrouped context
antonis fe40795
Fixes lint issue
antonis 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,7 @@ | |
| .fullAlignmentPadding { | ||
| padding: $block-edge-to-content; | ||
| } | ||
|
|
||
| .gridItem { | ||
| overflow: visible; | ||
| } | ||
58 changes: 58 additions & 0 deletions
58
packages/block-editor/src/components/block-list/grid-item.native.js
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,58 @@ | ||
| /** | ||
| * External dependencies | ||
| */ | ||
| import { View } from 'react-native'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import styles from './block-list-item.scss'; | ||
|
|
||
| function Grid( props ) { | ||
| /** | ||
| * Since we don't have `calc()`, we must calculate our spacings here in | ||
| * order to preserve even spacing between tiles and equal width for tiles | ||
| * in a given row. | ||
| * | ||
| * In order to ensure equal sizing of tile contents, we distribute the | ||
| * spacing such that each tile has an equal "share" of the fixed spacing. To | ||
| * keep the tiles properly aligned within their rows, we calculate the left | ||
| * and right paddings based on the tile's relative position within the row. | ||
| * | ||
| * Note: we use padding instead of margins so that the fixed spacing is | ||
| * included within the relative spacing (i.e. width percentage), and | ||
| * wrapping behavior is preserved. | ||
| * | ||
| * - The left most tile in a row must have left padding of zero. | ||
| * - The right most tile in a row must have a right padding of zero. | ||
| * | ||
| * The values of these left and right paddings are interpolated for tiles in | ||
| * between. The right padding is complementary with the left padding of the | ||
| * next tile (i.e. the right padding of [tile n] + the left padding of | ||
| * [tile n + 1] will be equal for all tiles except the last one in a given | ||
| * row). | ||
| * | ||
| */ | ||
| const { numOfColumns, children, tileCount, index, maxWidth } = props; | ||
| const lastTile = tileCount - 1; | ||
| const lastRow = Math.floor( lastTile / numOfColumns ); | ||
|
|
||
| const row = Math.floor( index / numOfColumns ); | ||
| const rowLength = | ||
| row === lastRow ? ( lastTile % numOfColumns ) + 1 : numOfColumns; | ||
|
|
||
| return ( | ||
| <View | ||
| style={ [ | ||
| { | ||
| width: maxWidth / rowLength, | ||
| }, | ||
| styles.gridItem, | ||
| ] } | ||
| > | ||
| { children } | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export default Grid; |
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
6 changes: 4 additions & 2 deletions
6
packages/block-library/src/gallery/gallery-styles.native.scss
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming that the web new gallery pr will not be merged by the end of the week that
1.59.0 (18.0)will code freeze.If this merges earlier or after 18.1 the notice should be updated.