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

List: add spacing block supports #43402

Merged
merged 1 commit into from
Aug 23, 2022
Merged

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Aug 19, 2022

Related:

What?

Enabling spacing support for the list block.

Why?

To create consistency across blocks.

How?

Adding the relevant block supports in block.json

Testing Instructions

  1. Load the block editor and add a list block. Add some list items or use the example block code below.
  2. Confirm that the dimensions control panel is there.
  3. Add padding and margin values to the list block.
  4. Save and confirm the styles appear on the frontend.
  5. Test the new support works for the block via theme.json and global styles. See example JSON below.
Example blockcode
<!-- wp:list {"style":{"spacing":{"padding":{"top":"var:preset|spacing|80","right":"var:preset|spacing|80","bottom":"var:preset|spacing|80","left":"var:preset|spacing|80"},"margin":{"top":"8.94rem","right":"var:preset|spacing|80","bottom":"var:preset|spacing|80","left":"var:preset|spacing|80"}}},"backgroundColor":"vivid-green-cyan"} -->
<ul class="has-vivid-green-cyan-background-color has-background" style="margin-top:8.94rem;margin-right:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80);margin-left:var(--wp--preset--spacing--80);padding-top:var(--wp--preset--spacing--80);padding-right:var(--wp--preset--spacing--80);padding-bottom:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--80)"><li>Account</li><li>Agenda</li><li>Archive</li><li>Ballot</li><li>Bill</li><li>Calendar</li><li>Catalog</li><li>Checklist</li><li>Dictionary</li><li>Directory</li></ul>
<!-- /wp:list -->
	"styles": {
		"blocks": {
			"core/list": {
				"spacing": {
					"margin": "66px",
					"padding": "122px",
				}
			}
		}
	}

Screen Shot 2022-08-19 at 2 19 44 pm

@ramonjd ramonjd added [Type] Enhancement A suggestion for improvement. [Block] List Affects the List Block [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi labels Aug 19, 2022
@ramonjd ramonjd self-assigned this Aug 19, 2022
@glendaviesnz
Copy link
Contributor

Not sure if it is an issue or not, but in TT2 the left and right margins applied in the editor get overridden in the frontend:
Screen Shot 2022-08-19 at 4 55 01 PM

@glendaviesnz
Copy link
Contributor

Also, padding applied in global styles doesn't show in the editor, but does in frontend ... just going to check if that is an issue in general or just with this block

@glendaviesnz
Copy link
Contributor

Also, padding applied in global styles doesn't show in the editor, but does in frontend

ignore that, couldn't replicate after a page refresh.

@ramonjd
Copy link
Member Author

ramonjd commented Aug 19, 2022

Not sure if it is an issue or not, but in TT2 the left and right margins applied in the editor get overridden in the frontend:

Thanks, I saw that too.

It's being overwritten by !important layout styles where there is a layout content size:

'selector' => "$selector > :where(:not(.alignleft):not(.alignright):not(.alignfull))",

I figured that it's still possible to do this:

2022-08-19.15.22.40.mp4
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 putting this together @ramonjd 👍

✅ Works as advertised in the editor
✅ Padding and margin are applied on the frontend
✅ Spacing can be set via theme.json and Global Styles

As you pointed out, there is a use case still for left/right margins. This is also consistent with other blocks that have recently added spacing support. So I think this should be ok to proceed with.

@ramonjd ramonjd merged commit b36364a into trunk Aug 23, 2022
@ramonjd ramonjd deleted the add/list-block-spacing-block-supports branch August 23, 2022 22:40
@github-actions github-actions bot added this to the Gutenberg 14.0 milestone Aug 23, 2022
@femkreations femkreations added the Needs User Documentation Needs new user documentation label Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] List Affects the List Block [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi Needs User Documentation Needs new user documentation [Type] Enhancement A suggestion for improvement.
4 participants