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

Page List : Add border and spacing support #66385

Merged
merged 10 commits into from
Nov 18, 2024

Conversation

benazeer-ben
Copy link
Contributor

@benazeer-ben benazeer-ben commented Oct 23, 2024

What?

Adding block & spacing support for Page list block.

Part of #43247 and #43243

Why?

Page list block is missing border & spacing support

How?

Adds the border & spacing support via block.json

Testing Instructions

  • Go to Global Styles setting ( under appearance > editor > styles > edit styles > blocks )
  • Make sure that Page List block's border is configurable via Global Styles
  • Verify that Global Styles are applied correctly in the editor and frontend
  • Edit template/page, Add Page List block and apply the border styles & spacing (padding, margin)styles
  • Verify that block styles take precedence over global styles
  • Verify that block borders & spacing display correctly in both the editor and frontend

Screenshots or screencast

In Backend:
pagelistbackend

In Frontend:
pagelistfrontend

Copy link

github-actions bot commented Oct 23, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @benazeerhassan1909.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: benazeerhassan1909.

Co-authored-by: benazeer-ben <benazeer@git.wordpress.org>
Co-authored-by: akasunil <sunil25393@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 23, 2024
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @benazeer-ben! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@benazeer-ben benazeer-ben changed the title Border support added for Page list block Page List : Add border support Oct 23, 2024
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

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

Thank you for putting together this PR @benazeer-ben 👍

For the most part it's working pretty well for me. There are a few things we might need to tweak before landing it though.

✅ Global styles apply correctly to the block
✅ Block instance styles override global styles
✅ Box sizing allows parent to control width effectively while borders are present

❓ Default controls - There's a general direction at present that border controls are only displayed by default if the block already had spacing controls e.g. padding/margin, and the spacing controls were displayed by default.

❓ Lack of padding support - Adopting border radius can mean clipping content. Normally this is mitigated somewhat by the user also having control over padding on the block. We might need to expand the scope of this PR to also adopt spacing supports.

Here's what I see when testing this branch:

Screen.Recording.2024-10-24.at.3.58.31.pm.mp4

Thanks again for tackling this, @benazeer-ben, appreciate it!

packages/block-library/src/page-list/block.json Outdated Show resolved Hide resolved
@benazeer-ben benazeer-ben changed the title Page List : Add border support Page List : Add border and spacing support Oct 24, 2024
@benazeer-ben
Copy link
Contributor Author

Hi @aaronrobertshaw, Thanks for your detailed feedback.

I have added padding and margin support for the page list block. Please have a look at it and share your thoughts.

@akasunil akasunil added [Type] Enhancement A suggestion for improvement. [Block] Page List Affects the Page List Block labels Oct 24, 2024
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

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

Thanks for iterating on this one @benazeer-ben 👍

It's very close. All that is missing is to tweak which block support controls are displayed by default.

✅ Global styles apply correctly to the block
✅ Block instance styles override global styles
✅ Box sizing allows parent to control width effectively while borders are present
❓ Controls still need to be hidden by default

Given the Page List block didn't previously have spacing support and is only getting it due to the border radius support, all the controls should be optional i.e. hidden by default.

I've left a couple of tweaks via inline comments. With those applied this is working as expected for me.

Screenshot 2024-11-11 at 3 41 54 pm

packages/block-library/src/page-list/block.json Outdated Show resolved Hide resolved
packages/block-library/src/page-list/block.json Outdated Show resolved Hide resolved
benazeer-ben and others added 3 commits November 11, 2024 12:24
Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
Suggestion commit

Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

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

Loving the quick turnaround on iterations here @benazeer-ben

I was giving this a final test and noticed that the box-sizing: border-box CSS is only applied in the editor. We'll need to add it to the blocks styles so parent blocks can still enforce a max width on Page List blocks.

Here's a quick diff you can apply to get the job done:

diff --git a/packages/block-library/src/page-list/style.scss b/packages/block-library/src/page-list/style.scss
index d06a614257..a77fb85903 100644
--- a/packages/block-library/src/page-list/style.scss
+++ b/packages/block-library/src/page-list/style.scss
@@ -15,3 +15,9 @@
 		background-color: inherit;
 	}
 }
+
+.wp-block-page-list {
+	// This block has customizable padding, border-box makes that more predictable.
+	box-sizing: border-box;
+}
+

To test this:

  1. Add a Page List block and apply both padding and a border
  2. Wrap it in a Group block
  3. Set a content width like 300px on the Group block
  4. Save and switch to the frontend
  5. Note that the Page List should now respect the 300px width applied by the parent Group block.

@benazeer-ben
Copy link
Contributor Author

Thanks again for your detailed feedback @aaronrobertshaw . border-box styling added in the last commit.

@benazeer-ben
Copy link
Contributor Author

Hi @aaronrobertshaw Kindly let me know if there is any more feedback.
Thanks.

Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

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

This is now working for me now after @aaronrobertshaw's suggestion, and that box-sizing: border-box; is applied in styles.scss.

I checked:

  • theme.json block styles
  • global styles in the site editor for page list block
  • block styles

All are working for me.

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

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

LGTM as well ✨

✅ Global styles are applied correctly in editor and on frontend
✅ Block support styles override global styles appropriately
✅ Box sizing allows parent block to enforce width

I can confirm the issue from my last review has been resolved. After wrapping a page list in a group block and setting its content width to 250px, this is what I get:

Screenshot 2024-11-18 at 6 09 53 pm

@ramonjd ramonjd merged commit 89cba32 into WordPress:trunk Nov 18, 2024
63 checks passed
@github-actions github-actions bot added this to the Gutenberg 19.8 milestone Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Page List Affects the Page List Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants