Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d27412e
Add simple tiles component for gallery
mkevins Oct 28, 2019
a2bd38f
Refactor tiles to accept props more directly
mkevins Oct 16, 2019
11bd1fd
Add groutSpacing prop to tiles
mkevins Oct 23, 2019
b7175fe
Tiles - WIP - debugging layout issue on orientation change
mkevins Oct 28, 2019
66406bf
Tiles - fix spacing (fence-post issue)
mkevins Oct 28, 2019
28dfef4
Tiles - use width instead of flexBasis to fix rotation glitch
mkevins Oct 28, 2019
ae536e3
Fix lint errors
mkevins Oct 28, 2019
9754371
Add native gallery - gallery image
pinarol Oct 10, 2019
ee3b0eb
WIP - refactor native gallery image
mkevins Oct 25, 2019
018448b
WIP - gallery image - deselect caption when image tapped
mkevins Oct 29, 2019
07ebc54
Add MediaUploadProgress to GalleryImage
mkevins Nov 1, 2019
b24fb08
Extract styles from gallery image
mkevins Nov 4, 2019
843bace
Add failed upload UI to gallery image
mkevins Nov 4, 2019
17499b7
Remove HOC from gallery image
mkevins Nov 4, 2019
b043431
Remove unused props / methods in gallery image
mkevins Nov 4, 2019
5c9c313
Remove gallery image when upload is cancelled
mkevins Nov 4, 2019
f83aa92
Remove unused code from gallery image
mkevins Nov 4, 2019
82ae9d5
Use accessibilityLabel prop on gallery image buttons
mkevins Nov 4, 2019
e779b5b
Remove href code from gallery image
mkevins Nov 4, 2019
1f47a68
Extract remaining styles from gallery image
mkevins Nov 4, 2019
00a195c
Fix lint errors
mkevins Nov 4, 2019
b52d643
Extract gallery.js
pinarol Oct 10, 2019
8aa8a32
Refactor gallery to accept props more directly
mkevins Oct 16, 2019
2190ff6
Use viewport HOC in gallery edit
mkevins Oct 25, 2019
4cb7c7f
Use cross-platform Platform module in gallery edit
mkevins Oct 25, 2019
5cef2f2
WIP - gallery edit - use icon prop with RangeControl
mkevins Oct 29, 2019
4461e72
Fix lint errors
mkevins Oct 29, 2019
b7fe6a7
WIP - add gallery button
mkevins Oct 25, 2019
216c78b
Fix lint errors
mkevins Nov 4, 2019
2907d0a
Add append logic to MediaPlaceholder for gallery
mkevins Oct 25, 2019
d9c9bca
Fix lint errors
mkevins Nov 4, 2019
2a810a5
Rename groutSpacing prop to spacing in gallery tiles
mkevins Nov 5, 2019
f533477
Extract gallery tiles styles to scss
mkevins Nov 5, 2019
b995d5d
Add explanatory comment to gallery tiles for layout logic
mkevins Nov 5, 2019
d44177a
Add native gallery
pinarol Oct 10, 2019
0040899
Add native gallery block behind DEV flag
pinarol Oct 10, 2019
4b756b9
Refactor gallery to accept props more directly
mkevins Oct 16, 2019
a6182f4
Pass isBlockSelected prop to gallery-image
mkevins Oct 25, 2019
a13454a
Pass isCropped prop to gallery-image
mkevins Oct 25, 2019
d4315fd
Limit displayed columns on mobile for gallery
mkevins Oct 25, 2019
f0ca1ce
Fix lint errors
mkevins Oct 29, 2019
cde6846
Use renamed tiles spacing prop in native gallery component
mkevins Nov 5, 2019
8fafcd0
Merge branches 'try/gallery-draft-mediaplaceholder', 'try/gallery-dra…
mkevins Nov 5, 2019
9522e1d
Trigger travis
mkevins Nov 6, 2019
5cdac2b
Remove isString check from gallery button
mkevins Nov 6, 2019
da7e78f
Refactor gallery to accept props more directly
mkevins Nov 6, 2019
1457fa5
Merge branch 'master' into try/gallery-draft-extract-gallery
mkevins Nov 6, 2019
20e7777
Merge branches 'try/gallery-draft-extract-gallery', 'try/gallery-draf…
mkevins Nov 6, 2019
85be21b
[RNMobile] Gallery - Button (#18264)
mkevins Nov 6, 2019
c95d5eb
Merge branch 'master' into try/gallery-draft
mkevins Nov 7, 2019
86b9e55
Fix isCropped style for mobile gallery image
mkevins Nov 7, 2019
14422b6
Merge branch 'try/gallery-draft-gallery-image' into try/gallery-draft
mkevins Nov 7, 2019
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
Prev Previous commit
Next Next commit
Tiles - fix spacing (fence-post issue)
  • Loading branch information
mkevins committed Oct 28, 2019
commit 66406bfdabd90309a29d9ad9a5f89b86b6eb5790
77 changes: 23 additions & 54 deletions packages/block-library/src/gallery/tiles.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,83 +6,52 @@ import { View } from 'react-native';
/**
* WordPress dependencies
*/
import { Children, useEffect, useLayoutEffect, useState } from '@wordpress/element';
import { Children } from '@wordpress/element';

const containerStyle = {
// flex: 1,
flexDirection: 'row',
flexWrap: 'wrap',
};

function Tiles( props ) {
// const [ columns, setColumns ] = useState();
const tileStyle = {
overflow: 'hidden',
flexDirection: 'row',
alignItems: 'center',
borderColor: 'transparent',
};

function Tiles( props ) {
const {
// columns: newColumns,
columns,
children,
groutSpacing = 10,
} = props;

// useEffect(() => {
// // if ( columns !== newColumns ) {
// setTimeout(() => {
// setColumns(newColumns);
// }, 1);
// // }
// });

// useLayoutEffect(() => {
// // setTimeout(() => {
// setColumns(newColumns);
// // }, 1);
// });

const tileBorderWidth = groutSpacing / 2;
const tileCount = Children.count( children );
const lastRow = Math.floor( ( tileCount - 1 ) / columns );
const lastTile = tileCount - 1;
const lastRow = Math.floor( lastTile / columns );

const wrappedChilren = Children.map( children, ( child, index ) => {
const wrappedChildren = Children.map( children, ( child, index ) => {
const row = Math.floor( index / columns );
const isLastItem = ( index + 1 ) === tileCount;

const isInFirstRow = row === 0;
const isInLastRow = row === lastRow;

const isFirstInRow = index % columns === 0;
const isLastInRow = ( index + 1 ) % columns === 0 || isLastItem;

const tileStyle = {
flex: 1,
flexBasis: ( ( 1 / columns ) * 100 ) + '%',
overflow: 'hidden',
flexDirection: 'row',
alignItems: 'center',
borderColor: 'transparent',
borderLeftWidth: isFirstInRow ? 0 : tileBorderWidth,
borderRightWidth: isLastInRow ? 0 : tileBorderWidth,
borderTopWidth: isInFirstRow ? 0 : tileBorderWidth,
borderBottomWidth: isInLastRow ? 0 : tileBorderWidth,
};
const rowLength = row === lastRow ? lastTile % columns + 1: columns;
const indexInRow = index % columns;

return (
<View style={ tileStyle }
onLayout={ (e) => {
console.log(`Tile ${index} width: ${e.nativeEvent.layout.width}`)
} }
>
<View style={ [ tileStyle, {
flexBasis: ( ( 1 / rowLength ) * 100 ) + '%',
borderLeftWidth: groutSpacing * ( indexInRow / rowLength ),
borderRightWidth: groutSpacing * ( 1 - ( indexInRow + 1 ) / rowLength ),
borderTopWidth: row === 0 ? 0 : groutSpacing / 2,
borderBottomWidth: row === lastRow ? 0 : groutSpacing / 2,
} ]}>
{ child }
</View>
);
} )
} );

return (
<View style={ containerStyle }
onLayout={ (e) => {
console.log(`Tiles width: ${e.nativeEvent.layout.width}`)
} }
>
{ wrappedChilren }
<View style={ containerStyle }>
{ wrappedChildren }
</View>
);
}
Expand Down