-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Gallery block refactor: remove the imageCount attribute #33677
Changes from 3 commits
8586af7
f1d7616
427065f
ba7ffcd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,11 +20,6 @@ import { | |
import { __ } from '@wordpress/i18n'; | ||
import { createBlock } from '@wordpress/blocks'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { defaultColumnsNumber } from './shared'; | ||
|
||
const allowedBlocks = [ 'core/image' ]; | ||
|
||
export const Gallery = ( props ) => { | ||
|
@@ -37,13 +32,7 @@ export const Gallery = ( props ) => { | |
blockProps, | ||
} = props; | ||
|
||
const { | ||
imageCount, | ||
align, | ||
columns = defaultColumnsNumber( imageCount ), | ||
caption, | ||
imageCrop, | ||
} = attributes; | ||
const { align, columns = 'default', caption, imageCrop } = attributes; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the idea of setting the default classname, but not sure about defaulting this variable to a string, since it's a numeric type usually, and I think it'd be good to keep the types consistent. An alternative could be to change the classnames call below: {
[ `align${ align }` ]: align,
[ `columns-${ columns }` ]: columns !== undefined,
[ `columns-default` ]: columns === undefined,
'is-cropped': imageCrop,
} The same comment would also apply in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point, confusing the type there isn't great, switched to your suggested approach. |
||
|
||
const { children, ...innerBlocksProps } = useInnerBlocksProps( blockProps, { | ||
allowedBlocks, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ export const settings = { | |
example: { | ||
attributes: { | ||
columns: 2, | ||
imageCount: 2, | ||
}, | ||
innerBlocks: [ | ||
{ | ||
|
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.
Might be safest to make it
!! innerBlockImages?.length
, just in caseinnerBlocks
is everundefined
for some reason.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.
yeh, that makes sense, done.