Skip to content

Commit

Permalink
Latest Posts: Bring back classname on post list (#26477)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryelle authored and tellthemachines committed Oct 30, 2020
1 parent dae7452 commit 1338661
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/block-library/src/latest-posts/block.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"apiVersion": 2,
"name": "core/latest-posts",
"category": "widgets",
"attributes": {
Expand Down
24 changes: 12 additions & 12 deletions packages/block-library/src/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,15 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
</InspectorControls>
);

const blockProps = useBlockProps();
const blockProps = useBlockProps( {
className: classnames( {
'wp-block-latest-posts__list': true,
'is-grid': postLayout === 'grid',
'has-dates': displayPostDate,
'has-author': displayAuthor,
[ `columns-${ columns }` ]: postLayout === 'grid',
} ),
} );

const hasPosts = Array.isArray( latestPosts ) && latestPosts.length;
if ( ! hasPosts ) {
Expand Down Expand Up @@ -442,20 +450,12 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
const dateFormat = __experimentalGetSettings().formats.date;

return (
<div { ...blockProps }>
<>
{ inspectorControls }
<BlockControls>
<ToolbarGroup controls={ layoutControls } />
</BlockControls>
<ul
className={ classnames( {
'wp-block-latest-posts__list': true,
'is-grid': postLayout === 'grid',
'has-dates': displayPostDate,
'has-author': displayAuthor,
[ `columns-${ columns }` ]: postLayout === 'grid',
} ) }
>
<ul { ...blockProps }>
{ displayPosts.map( ( post, i ) => {
const titleTrimmed = invoke( post, [
'title',
Expand Down Expand Up @@ -585,6 +585,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
);
} ) }
</ul>
</div>
</>
);
}

0 comments on commit 1338661

Please sign in to comment.