Skip to content

Latest Posts: add grid option and improve front-end rendering - #1992

Merged
mtias merged 10 commits into
masterfrom
add/latest-posts-grid
Jul 25, 2017
Merged

mtias merged 10 commits into
masterfrom
add/latest-posts-grid

Conversation

@mtias

@mtias mtias commented Jul 24, 2017

Copy link
Copy Markdown
Member

This enhances the latest posts block adding a "grid" layout option.

image

In the future, we'd want to add a columns slider like galleries have.


The front-end rendering seemed quite lackluster and wasn't rendering the date. This also fixes that.

@mtias mtias added [Feature] Blocks Overall functionality of blocks Design labels Jul 24, 2017
Comment thread lib/blocks/latest-posts.php Outdated
$post_date = "<span class='wp-block-latest-posts__post-date'>{$post_the_date}</span>";
}

$posts_content .= "<li><a href='{$post_permalink}'>{$post_title}</a>{$post_date}</li>\n";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The return value of get_permalink() also needs to go through esc_url(), which was missed previously.

The return values of get_the_date() and get_the_title() should probably also go through esc_html().

Comment thread lib/blocks/latest-posts.php Outdated

$posts_content .= "<li><a href='{$post_permalink}'>{$post_title}</a></li>\n";
if ( $attributes['displayPostDate'] ) {
$post_date = "<span class='wp-block-latest-posts__post-date'>{$post_the_date}</span>";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should not a <time datetime='...'> element be used here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, sounds like a good update.

Comment thread lib/blocks/latest-posts.php Outdated
}

$class = 'wp-block-latest-posts ' . esc_attr( 'align' . $align );
if ( $attributes['layout'] === 'grid' ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs condition condition.

@mtias

mtias commented Jul 24, 2017 •

Copy link
Copy Markdown
Member Author

Front-end:

image

@melchoyce

Copy link
Copy Markdown
Contributor

Testing:

image

Changing the number of posts in the Inspector doesn't seem to update the list inside my post content, and the grid is a little wonky.

@mtias

mtias commented Jul 24, 2017

Copy link
Copy Markdown
Member Author

@melchoyce see #1991

@westonruter
westonruter force-pushed the add/latest-posts-grid branch from 534ae27 to 11522a0 Compare July 25, 2017 06:26
@westonruter

Copy link
Copy Markdown
Member

Rebased to include fix from show-count fix from master. Commit 534ae27c rewritten to c76e54d.

@westonruter

Copy link
Copy Markdown
Member

Changing the number of posts in the Inspector doesn't seem to update the list inside my post content, and the grid is a little wonky.

Should we prevent flexbox from wrapping entirely until we add support for column counts? How would we know to have a fixed width for a given post in the grid if we don't know the number of columns we intend to show?

@mtias

mtias commented Jul 25, 2017

Copy link
Copy Markdown
Member Author

I prefer the wrap, even if a bit odd until we add columns, otherwise it can get very squishy:

image

@mtias

mtias commented Jul 25, 2017

Copy link
Copy Markdown
Member Author

We should get the date format to match (doesn't have to be here).

It would be good to use _wpDateSettings.formats.date at some point.
@mtias

mtias commented Jul 25, 2017

Copy link
Copy Markdown
Member Author

Updated date format. It'd be nice to use _wpDateSettings.formats.date but PHP and moment.js tokens don't match.

@mtias
mtias merged commit 8580da5 into master Jul 25, 2017
@mtias
mtias deleted the add/latest-posts-grid branch July 25, 2017 10:00
@westonruter westonruter mentioned this pull request Jul 25, 2017
5 of 6 tasks
@melchoyce

melchoyce commented Jul 25, 2017 •

Copy link
Copy Markdown
Contributor

I prefer the wrap, even if a bit odd until we add columns, otherwise it can get very squishy:

@mtias Could we try limiting the grid to either two or three columns in a future PR?

@mtias

mtias commented Jul 25, 2017

Copy link
Copy Markdown
Member Author

I was thinking of adding the column slider. I can see cases where it makes sense to have many in a line, specially if you use the full-width option.

@melchoyce

Copy link
Copy Markdown
Contributor

Okay, I was thinking just short-term — but it sounds like you're planning on implementing the columns sooner rather than later?

@westonruter

Copy link
Copy Markdown
Member

Added issue for exporting PHP date format to the client for use by Moment.js: #2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Blocks Overall functionality of blocks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants