Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Add "Bordered" style and "Media & Text article title" block pattern #150

Merged
merged 11 commits into from
Sep 29, 2020

Conversation

kjellr
Copy link
Collaborator

@kjellr kjellr commented Sep 25, 2020

This PR tackles another one of the block patterns from #50:

Media & Text article title

In doing so, it also adds a new "Bordered" block style for the media and text block. I extended this for use in the Group and Cover blocks too, since those will come in handy for other block patterns. #140 added a similar style for the Image block, but it mandates some padding. For completeness, I added this plain, unpadded border style to the image block too.

Screenshots

Block Pattern

Screen Shot 2020-09-25 at 12 42 26 PM

Block Styles

gutenberg test_wp-admin_post php_post=1 action=edit

@kjellr kjellr added [Type] Enhancement New feature or request [Component] Block patterns Issues related to block patterns shipped with theme labels Sep 25, 2020
@kjellr kjellr self-assigned this Sep 25, 2020
'title' => __( 'Media & Text Article Title', 'twentytwentyone' ),
'categories' => array( 'twentytwentyone' ),
'viewportWidth' => 1440,
'content' => '<!-- wp:media-text {"mediaId":1752,"mediaLink":"' . esc_url( get_template_directory_uri() ) . '/assets/images/the_poplars_at_saint_remy.jpg","mediaType":"image","className":"is-style-twentytwentyone-border"} --><div class="wp-block-media-text alignwide is-stacked-on-mobile is-style-twentytwentyone-border"><figure class="wp-block-media-text__media"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/the_poplars_at_saint_remy.jpg" alt="' . esc_attr__( '&quot;The Poplars at Saint-Rémy&quot; by Vincent Van Gogh (1889)', 'twentytwentyone' ) . '" class="wp-image-1752 size-full"/></figure><div class="wp-block-media-text__content"><!-- wp:heading {"align":"center"} --><h2 class="has-text-align-center">' . wp_kses_post( __( 'The Poplars at<br>Saint-Rémy', 'twentytwentyone' ) ) . '</h2><!-- /wp:heading --><!-- wp:separator --><hr class="wp-block-separator"/><!-- /wp:separator --><!-- wp:paragraph {"align":"center","fontSize":"small"} --><p class="has-text-align-center has-small-font-size">' . wp_kses_post( __( 'Vincent van Gogh<br>(Dutch, 1853-1890)', 'twentytwentyone' ) ) . '</p><!-- /wp:paragraph --></div></div><!-- /wp:media-text -->',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wp_kses_post( __( 'The Poplars at<br>Saint-Rémy', 'twentytwentyone' ) )

^ Is that the right way to escape + translate this? It's just normal post content.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes this works well, since there is HTML inside of it.

@melchoyce
Copy link
Contributor

Can we add some padding to the image caption here, or should that be a new PR?

@melchoyce
Copy link
Contributor

Yeah any padding we could add here would help:

image

(Group block)

@kjellr
Copy link
Collaborator Author

kjellr commented Sep 25, 2020

@melchoyce Should be all set in b4e6027.

Screen Shot 2020-09-25 at 3 56 49 PM

I noticed some weirdness with Group block spacing in the front end too (the container had some extra padding by default), so I took that out in the same commit:

Before (Editor) Before (Front end) After (Front end)
Screen Shot 2020-09-25 at 3 58 58 PM Screen Shot 2020-09-25 at 3 58 50 PM Screen Shot 2020-09-25 at 4 00 09 PM

@carolinan
Copy link
Contributor

carolinan commented Sep 28, 2020

When I insert the media and text block pattern, there is a block validation error in the editor.
But If I save and refresh the page (editor), the error is gone.

(Gutenberg is not active)

@kjellr
Copy link
Collaborator Author

kjellr commented Sep 28, 2020

@carolinan Mind giving this another try? I recreated the pattern without the plugin active, and now it seems to work fine in both contexts.

Copy link
Contributor

@melchoyce melchoyce left a comment

Choose a reason for hiding this comment

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

LGTM from the design side 👍

@carolinan
Copy link
Contributor

The pattern works now, but the border color has reverted back to black.

@kjellr
Copy link
Collaborator Author

kjellr commented Sep 29, 2020

The pattern works now, but the border color has reverted back to black.

Just needed to be synced up with trunk. 🙂

Thanks, all!

@kjellr kjellr merged commit f071ae4 into trunk Sep 29, 2020
@kjellr kjellr deleted the add/more-block-patterns branch September 29, 2020 12:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
[Component] Block patterns Issues related to block patterns shipped with theme [Type] Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants