Skip to content
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

Tiled galleries: Consistent layouts #29559

Merged
merged 96 commits into from
Dec 27, 2018
Merged

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented Dec 18, 2018

Changes proposed in this Pull Request

Pulls in changes from Gutenberg gallery components.
Rethink how layouts should be approached.

Resolves #28962

Closes #29614 (supersedes)
Closes #29598 (supersedes)
Fixes #29544 "don't show full size image, use large image instead"
Resolves #29495 "photonize image URLs"
Resolves #28943 "clarify disabled columns control"
Fixes #28904 "captions visible right after adding images"

Currently:

  • Implements a html+css only responsive square + circle layout. It's imperfect (images are not same w/h)

To do:

  1. Save is currently empty
  2. Rework mosaic layout using introduced components
  3. Get square-ish layouts using same w/h dimensions
  4. Get square-ish layouts working on upload
  5. Verify @wordpress deps are present Jetpack-side
  6. clean up dead code/files

Testing instructions

tbd…

cc: @simison

@matticbot
Copy link
Contributor

@sirreal sirreal self-assigned this Dec 18, 2018
@simison simison added the [Goal] Gutenberg Working towards full integration with Gutenberg label Dec 19, 2018
} = this.props;

/* translators: %1$d is the order number of the image, %2$d is the total number of images. */
const ariaLabel = __( sprintf( 'image %1$d of %2$d in gallery', i + 1, images.length ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__ and sprintf need to be another way around here so that we don't attempt to translate already sprintf'ied result.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

align={ align }
className={ `wp-block-jetpack-tiled-gallery ${ className }` }
<Layout
className={ className }
Copy link
Member

@simison simison Dec 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be safe, we probably should set default rectangular layout class is-style-rectangular here somehow on first render when className is undefined. (https://github.com/Automattic/wp-calypso/pull/29559/files#r242806286)

This won't affect functionality anyhow at editor side because is-style-rectangular doesn't have any affect on styling, but on view side we pick the layout from that classname.

const size = Math.min( width, height );
return photon( url, { resize: `${ size },${ size }` } );
}
return photon( url );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check for window.location.hostname === 'localhost' and return the original URL in that case?

import GalleryImage from '../gallery-image';

export default class Layout extends Component {
photonize( { height, width, url } ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never get width and height here: adding them to pickRelevantMediaFiles fixes it:

imageProps.width = get( image, [ 'sizes', 'large', 'width' ] );
imageProps.height = get( image, [ 'sizes', 'large', 'height' ] );

in

https://github.com/Automattic/wp-calypso/blob/0850165273bd7ee74a19f676a0333a70a9b48415/client/gutenberg/extensions/tiled-gallery/edit.jsx#L43-L50

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do get them on already uploaded images. I suspect your suggestion will fix this todo, nice spot!

Get square-ish layouts working on upload

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more tricky things going on here, I'm going to hold off on any changes for now.

onSelect={ onSelectImage( i ) }
setAttributes={ setImageAttributes( i ) }
url={ this.photonize( img ) }
width={ img.width }
Copy link
Member

@simison simison Dec 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This width (and height above) ends up always being undefined, see https://github.com/Automattic/wp-calypso/pull/29559/files#r242816530

columns: {
type: 'number',
},
ids: {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 @jeherve You'll be interested in the image ID array in attributes for Automattic/jetpack#11000

import { IconButton, Spinner } from '@wordpress/components';
import { isBlobURL } from '@wordpress/blob'; // @TODO Add dep Jetpack-side
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@simison simison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mighty good! 💪

@sirreal sirreal force-pushed the update/g7g-tg-consistent-layout branch from 4a07e8c to d17b7b2 Compare December 27, 2018 15:25
@sirreal sirreal added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] Ready to Merge and removed [Status] In Progress labels Dec 27, 2018
@sirreal sirreal merged commit 38897e7 into master Dec 27, 2018
@sirreal sirreal deleted the update/g7g-tg-consistent-layout branch December 27, 2018 15:51
@matticbot matticbot removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] Ready to Merge labels Dec 27, 2018
jeherve pushed a commit to Automattic/jetpack that referenced this pull request Jan 3, 2019
Adds `@wordpress/blob` dependency for Tiled gallery since the block depends to it as of Automattic/wp-calypso#29559

## Testing

- Switch to `update/g7g-tg-consistent-layout` branch in Calypso
- Build blocks: `npm run sdk -- gutenberg ./client/gutenberg/extensions/presets/jetpack/ /PATH_TO_JETPACK/_inc/blocks/`
- Insert tiled gallery block
- **Upload** images to gallery. Blob URLs are URLs for images that are still uploading.
- The block can feel little broken due other issues but it shouldn't complain about missing dependency. ✨ (both editor and when publishing and looking at the page/post)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Tiled Gallery [Goal] Gutenberg Working towards full integration with Gutenberg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants