Skip to content

Commit

Permalink
feat: use patterns instead of template parts for author-bio (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasguillot authored Jun 27, 2024
1 parent 5d81cc1 commit 147c315
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 16 deletions.
8 changes: 8 additions & 0 deletions includes/class-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ public static function block_pattern_categories() {
)
);

register_block_pattern_category(
'newspack-block-theme-author-bio',
array(
'label' => __( 'Newspack Theme - Author Bio', 'newspack-block-theme' ),
'description' => __( 'Patterns bundled with the Newspack Block Theme, specifically built for the author biography.', 'newspack-block-theme' ),
)
);

register_block_pattern_category(
'newspack-block-theme-post-meta',
array(
Expand Down
15 changes: 0 additions & 15 deletions parts/author-bio.html

This file was deleted.

2 changes: 1 addition & 1 deletion parts/post-footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="wp-block-group post-meta"><!-- wp:post-terms {"term":"post_tag","className":"is-style-buttons"} /-->

<!-- wp:group {"style":{"spacing":{"margin":{"top":"var:preset|spacing|80"},"blockGap":"var:preset|spacing|80"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="margin-top:var(--wp--preset--spacing--80)"><!-- wp:template-part {"slug":"author-bio","theme":"newspack-block-theme","tagName":"div","className":"author-bio"} /-->
<div class="wp-block-group" style="margin-top:var(--wp--preset--spacing--80)"><!-- wp:pattern {"slug":"newspack-block-theme/author-bio"} /-->

<!-- wp:template-part {"slug":"comments-menu","theme":"newspack-block-theme","tagName":"div","className":"comments-menu"} /--></div>
<!-- /wp:group --></div>
Expand Down
37 changes: 37 additions & 0 deletions patterns/author-bio-avatar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Title: Author Bio with Avatar
* Slug: newspack-block-theme/author-bio-avatar
* Categories: newspack-block-theme-author-bio
* Viewport Width: 632
* Block Types: core/avatar, core/post-author-name, core/post-author-biography
*
* @package Newspack_Block_Theme
*/

?>
<!-- wp:group {"metadata":{"name":"<?php esc_html_e( 'Author Bio', 'newspack-block-theme' ); ?>"},"layout":{"type":"flex","orientation":"vertical","justifyContent":"stretch"}} -->
<div class="wp-block-group">

<!-- wp:separator {"className":"is-style-wide"} -->
<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>
<!-- /wp:separator -->

<!-- wp:group {"metadata":{"name":"<?php esc_html_e( 'Content', 'newspack-block-theme' ); ?>"},"style":{"spacing":{"blockGap":"var:preset|spacing|20"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group">

<!-- wp:avatar {"size":128,"align":"right","style":{"spacing":{"margin":{"top":"0","bottom":"var:preset|spacing|20","right":"0","left":"var:preset|spacing|40"}}}} /-->

<!-- wp:post-author-name {"style":{"elements":{"link":{"color":{"text":"var:preset|color|contrast"}}},"typography":{"fontStyle":"normal","fontWeight":"700"},"spacing":{"margin":{"top":"0","bottom":"0"}}},"textColor":"contrast","fontSize":"large"} /-->

<!-- wp:post-author-biography /-->

</div>
<!-- /wp:group -->

<!-- wp:separator {"className":"is-style-wide"} -->
<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>
<!-- /wp:separator -->

</div>
<!-- /wp:group -->
35 changes: 35 additions & 0 deletions patterns/author-bio.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* Title: Author Bio
* Slug: newspack-block-theme/author-bio
* Categories: newspack-block-theme-author-bio
* Viewport Width: 632
* Block Types: core/post-author-name, core/post-author-biography
*
* @package Newspack_Block_Theme
*/

?>
<!-- wp:group {"metadata":{"name":"<?php esc_html_e( 'Author Bio', 'newspack-block-theme' ); ?>"},"layout":{"type":"flex","orientation":"vertical","justifyContent":"stretch"}} -->
<div class="wp-block-group">

<!-- wp:separator {"className":"is-style-wide"} -->
<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>
<!-- /wp:separator -->

<!-- wp:group {"metadata":{"name":"<?php esc_html_e( 'Content', 'newspack-block-theme' ); ?>"},"style":{"spacing":{"blockGap":"var:preset|spacing|20"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group">

<!-- wp:post-author-name {"style":{"elements":{"link":{"color":{"text":"var:preset|color|contrast"}}},"typography":{"fontStyle":"normal","fontWeight":"700"},"spacing":{"margin":{"top":"0","bottom":"0"}}},"textColor":"contrast","fontSize":"large"} /-->

<!-- wp:post-author-biography /-->

</div>
<!-- /wp:group -->

<!-- wp:separator {"className":"is-style-wide"} -->
<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>
<!-- /wp:separator -->

</div>
<!-- /wp:group -->

0 comments on commit 147c315

Please sign in to comment.