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

Carousel: handle posts without featured images #731

Merged
merged 5 commits into from
Apr 6, 2021

Conversation

adekbadek
Copy link
Member

All Submissions:

Changes proposed in this Pull Request:

Closes #443

How to test the changes in this Pull Request:

  1. Insert three Carousel blocks on a page: one that renders posts with featured images, one that renders posts without any, and one which would render no posts
  2. In the editor, observe the first is behaving as expected, the second is displaying grey surface in place of the featured image, and the last is displaying a center-aligned error message (and no carousel arrows)
  3. On frontend, first two should behave as in the editor, while the last should not render any visible content

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

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

Looking good overall, just a couple of minor UI requests below.

@@ -66,28 +63,30 @@ function newspack_blocks_render_block_carousel( $attributes ) {
while ( $article_query->have_posts() ) :
Copy link
Contributor

Choose a reason for hiding this comment

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

If the carousel has no posts, I still see empty carousel UI on the front-end. At this point, if ! $article_query->have_posts(), we should just return early before the UI below line 220 gets rendered.

Screen Shot 2021-04-05 at 8 50 12 PM

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 9660922

className="swiper-pagination-bullets amp-pagination"
ref={ this.paginationRef }
/>
{ ! hasNoPosts && (
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also not render the next/previous UI (buttons and bullets) if there's only one post, both here and on the front-end.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in c439d60

# Conflicts:
#	includes/class-newspack-blocks-api.php
#	src/blocks/carousel/edit.js
#	src/blocks/carousel/view.php
@adekbadek adekbadek requested a review from dkoo April 6, 2021 10:06
Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

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

This looks good now, thanks for the updates!

@adekbadek adekbadek merged commit 0db34be into master Apr 6, 2021
@adekbadek adekbadek deleted the fix/carousel-no-featured-imgs branch April 6, 2021 17:26
matticbot pushed a commit that referenced this pull request Apr 6, 2021
# [1.23.0-alpha.2](v1.23.0-alpha.1...v1.23.0-alpha.2) (2021-04-06)

### Features

* handle posts with no featured image ([#731](#731)) ([0db34be](0db34be)), closes [#443](#443)
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.23.0-alpha.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Apr 6, 2021
# [1.23.0](v1.22.1...v1.23.0) (2021-04-06)

### Features

* add new patterns for donation and subscribe ([#730](#730)) ([a00cfd6](a00cfd6))
* deduplication across homepage posts & carousel ([#725](#725)) ([427c4e0](427c4e0)), closes [#664](#664)
* handle posts with no featured image ([#731](#731)) ([0db34be](0db34be)), closes [#443](#443)
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.23.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Articles Carousel: missing placeholder for empty state
3 participants