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

feat: Correction box & Loop item blocks #312

Closed
wants to merge 17 commits into from

Conversation

Takshil-Kunadia
Copy link
Collaborator

All Submissions:

Changes proposed in this Pull Request:

Addresses https://app.asana.com/0/1209292256643614/1209292256643625

How to test the changes in this Pull Request:

Testing Corrections Box Block:-

  1. Create a post add corrections/clarifications.
  2. Add Corrections box block to see the corrections.
  3. Save the post and view the corrections on the front-end.
  4. Modify the corrections on the editor/Add new corrections and click on refresh button to view updated corrections.

Testing Corrections Loop template:-

  1. Create a new Page and select Archive Newspack Corrections template.
  2. Edit the template to change the title/description.
  3. View the page on front-end.

For individual testing of the Corrections Loop item block

  1. Add a Query Loop block and add Post Template and Pagination blocks inside it.
  2. In Post Template block, Add correction Item block.
  3. Set Post type as Corrections in Query Loop block settings. Per page count can also be set here.
  4. View the corrections archive.

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?

Demo:-

Corrections Box block:-

Screen.Recording.2025-02-17.at.12.27.17.PM.mov

Archive Corrections Loop Item/Template block:-

Screen.Recording.2025-02-17.at.12.25.41.PM.mov

@Takshil-Kunadia Takshil-Kunadia marked this pull request as ready for review February 19, 2025 04:03
@Takshil-Kunadia Takshil-Kunadia requested a review from a team as a code owner February 19, 2025 04:03
@Takshil-Kunadia Takshil-Kunadia changed the title Feature/correction blocks feat: Correction box & Loop item blocks Feb 20, 2025
@thomasguillot
Copy link
Contributor

thomasguillot commented Feb 20, 2025

Hi @Takshil-Kunadia , I pushed a few changes. Overall it works well but I noticed the blocks need to support all the settings properly.

editor

Also, the idea of the Corrections block (the one you named Correction Box) is to have it within the Single template. Not inside an actual post.

With the "Block Spacing" setting, it's supposed to control the spacing between corrections

@thomasguillot
Copy link
Contributor

Can we change "Archive Newspack Corrections" to "Corrections Archive"?

Copy link
Contributor

@thomasguillot thomasguillot left a comment

Choose a reason for hiding this comment

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

@Takshil-Kunadia
Copy link
Collaborator Author

Takshil-Kunadia commented Feb 21, 2025

Thanks! @thomasguillot for taking a look.

Hi @Takshil-Kunadia , I pushed a few changes. Overall it works well but I noticed the blocks need to support all the settings properly.

I have fixed this, all settings are supported now.

With the "Block Spacing" setting, it's supposed to control the spacing between corrections

The blockGap setting will work partially ( spacing is visible in front-end but not in the editor ), blockGap doesn't work well with ServerSideRender. It seems to be a core issue. If you can confirm this, I will raise it on Gutenberg and solve it.

Also, the idea of the Corrections block (the one you named Correction Box) is to have it within the Single template. Not inside an actual post.

Yes, this block will work in the Single template.

Please review 🙇

Copy link
Contributor

@thomasguillot thomasguillot left a comment

Choose a reason for hiding this comment

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

double-divs

In the editor, the styles are being applied to 2 divs.

We also need the block to come with some default settings:

  • Font size: small
  • Text (and link) colour: contrast-3
  • Block spacing: spacing--30

template

Overall, I do think the empty state can be improved (and it will fix the way it looks when added to a Template):

  1. Change the placeholder to some text: "This is the Corrections block, it will display all the corrections and clarifications". If the block is added to a post we can even add more context to a new paragraph: "[...] There are no corrections or clarifications for this post."
  2. In a template, we don't need the refresh functionality
  3. Can we avoid the whole "loading corrections" placeholder since it's empty? Especially when it's added to a template

@Takshil-Kunadia
Copy link
Collaborator Author

Thanks for the input @thomasguillot .

The blockgap is not working because it doesn't seem to work well with SSR blocks. Should I raise an issue?(#312 (comment))

@thomasguillot
Copy link
Contributor

The blockgap is not working because it doesn't seem to work well with SSR blocks. Should I raise an issue?(#312 (comment))

Sorry @Takshil-Kunadia, I clearly missed this. I don't think it'll be fixed anytime soon but it's worth reporting, yes. 👍

@Takshil-Kunadia
Copy link
Collaborator Author

@thomasguillot Had a dig at the mentioned issues.

I do think the empty state can be improved

Agreed, added a separate UI for site editor with the custom message as you mentioned. No loading placeholders & refresh.

In the editor, the styles are being applied to 2 divs.

This shouldn't be the case. Can you please confirm this behaviour?
Screenshot 2025-02-26 at 3 29 06 PM

We also need the block to come with some default settings

I also hit a road block with this one as this is a know issue of Gutenberg( ref: WordPress/gutenberg#7342 ), we can set defaults for block support styles and they do appear in the editor as expected, but these attributes do not get saved unless there is a manual change in one of the settings. So if this block is added, since the styles are available in editor it will display the default styles but they won't be saved and take effect in the front-end. This is what it results in:-

Editor Front-end
Screenshot 2025-02-26 at 3 38 05 PM Screenshot 2025-02-26 at 3 39 03 PM
Default Markup on Block insert Ideally what should be saved
Screenshot 2025-02-26 at 3 40 08 PM Screenshot 2025-02-26 at 3 41 24 PM

Due to this, I don't feel confident in adding default block support styles for this block. Regardless, if you feel it is a necessity, I'll add it 🙇 .

@thomasguillot
Copy link
Contributor

This shouldn't be the case. Can you please confirm this behaviour?

Yes, it’s fixed. Not sure what happened.

@thomasguillot
Copy link
Contributor

I also hit a road block with this one as this is a know issue of Gutenberg

2018! Wow... ok let's ignore default settings 👍

@thomasguillot
Copy link
Contributor

Looks great. Thank you @Takshil-Kunadia. I have one more request... I forgot to comment on this:

Had to add the layout support as it is necessary for blockGap to work. (WordPress/gutenberg#53254)

I didn't realise we needed layout to support blockGap. I don't like this. Can we remove blockGap (and layout) and have the .correction margin top/bottom to be --wp--preset--spacing--30 (note: first-item should have top: 0, and last-item should have bottom: 0)

@leogermani
Copy link
Contributor

Thanks @thomasguillot and @Takshil-Kunadia ,

Sorry to do this again, but once this is ready to ship, I think it actually should live somewhere else. I discussed with @laurelfulford and it makes sense for this to live in the main plugin, alongside the rest of the feature implementation. Isn't that one of the beauties of Block Themes? Now we can more easily have theme agnostic features.

We could also argue to add it to the newspack-blocks plugin, but we often say we want to merge that with the main plugin so...

@Takshil-Kunadia
Copy link
Collaborator Author

No worries @leogermani 😄 , created a PR to add the blocks to plugin. Automattic/newspack-plugin#3787. We can safely close this PR.

cc: @thomasguillot @laurelfulford

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

Successfully merging this pull request may close these issues.

3 participants