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

Creating Block Patterns - Lesson #894

Open
Tracked by #1041
jonathanbossenger opened this issue Aug 19, 2022 · 17 comments
Open
Tracked by #1041

Creating Block Patterns - Lesson #894

jonathanbossenger opened this issue Aug 19, 2022 · 17 comments
Assignees

Comments

@jonathanbossenger
Copy link
Collaborator

jonathanbossenger commented Aug 19, 2022

IMPORTANT

This lesson plan belongs to part of a greater course, Extend a Low Code Block Theme which depends on the completion of Create a Custom Block Theme #1

Please reach out to @jonathanbossenger (Jonathan Bossenger) in the #training team Slack if you would like to help with this lesson plan.

Topic Description

The goal of this lesson is to introduce the concept of block patterns in building block themes

Objectives

After completing this lesson, participants will be able to:

  • Understand what a block pattern is
  • Create a block pattern
  • Register a block pattern for the theme

Guidelines

Review the [team guidelines] (https://make.wordpress.org/training/handbook/guidelines/)

@jonathanbossenger jonathanbossenger added [Experience Level] Intermediate Awaiting Triage Issues awaiting triage. See Training Team handbook for how to triage issues. labels Aug 19, 2022
@jonathanbossenger jonathanbossenger changed the title [Related Course: Extend a Low Code Block Theme] An Introduction to Block Patterns - Lesson Plan An Introduction to Block Patterns - Lesson Plan Aug 26, 2022
@jonathanbossenger
Copy link
Collaborator Author

jonathanbossenger commented Sep 13, 2022

Block pattern registered in the patterns directory (available since 6.0)

<?php
/**
 * Title: Footer with text, social links, and an image.
 * Slug: block-course-theme/footer-default
 * Categories: text, site-footer
 * Block Types: block-course-theme/template-part/footer
 * Viewport Width: 1280
 */

?>

<!-- wp:group {"align":"full","layout":{"inherit":true}} -->
<div class="wp-block-group alignfull">
	<!-- wp:group {"align":"wide","layout":{"type":"flex","allowOrientation":false,"justifyContent":"space-between"}} -->
	<div class="wp-block-group alignwide">
		<!-- wp:paragraph -->
		<p>&copy; <?php echo esc_html( gmdate( 'Y' ) ); ?> <?php esc_html_e( 'Your Company LLC', 'theme-slug' ); ?> · <a href="#"><?php esc_html_e( 'Contact Us', 'theme-slug' ); ?></a></p>
		<!-- /wp:paragraph -->

        <!-- wp:image {"width":100,"height":100,"sizeSlug":"full","linkDestination":"none"} -->
        <figure class="wp-block-image size-full is-resized"><img src="<?php echo esc_url( get_template_directory_uri() ); ?>/assets/images/water-1.jpeg" alt="Water Background" width="100" height="100"/></figure>
        <!-- /wp:image -->

		<!-- wp:social-links {"className":"is-style-logos-only"} -->
		<ul class="wp-block-social-links has-icon-color is-style-logos-only">
			<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->
		</ul>
		<!-- /wp:social-links -->
	</div>
	<!-- /wp:group -->
</div>
<!-- /wp:group -->

@jonathanbossenger
Copy link
Collaborator Author

Block pattern registered in functions.php

add_action( 'init', 'block_course_theme_two_button_pattern' );

function block_course_theme_two_button_pattern() {
	register_block_pattern(
		'block-course-theme/two-buttons',
		array(
			'title'       => __( 'Two buttons', 'block-course-theme' ),
			'description' => _x( 'Two horizontal buttons.', 'Block pattern description', 'block-course-theme' ),
			'categories'  => array( 'block-course-theme-custom-category' ),
			'content'     => '<!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} --><div class="wp-block-buttons"><!-- wp:button --><div class="wp-block-button"><a class="wp-block-button__link">' . __( 'Go home', 'theme-slug' ) . '</a></div><!-- /wp:button --><!-- wp:button --><div class="wp-block-button"><a class="wp-block-button__link">' . __( 'Go shopping', 'theme-slug' ) . '</a></div><!-- /wp:button --></div><!-- /wp:buttons -->',
		)
	);
}

@jonathanbossenger
Copy link
Collaborator Author

Deregister core block patterns

remove_theme_support( 'core-block-patterns' );

@courtneyr-dev
Copy link
Collaborator

@jonathanbossenger jonathanbossenger changed the title An Introduction to Block Patterns - Lesson Plan An Introduction to Block Patterns - Lesson Sep 21, 2022
@jonathanbossenger jonathanbossenger removed [Content Type] Lesson Plan Awaiting Triage Issues awaiting triage. See Training Team handbook for how to triage issues. labels Sep 21, 2022
@justintadlock
Copy link

@jonathanbossenger Assign this to me. I've got the initial outline here: https://github.com/justintadlock/block-theme-course/tree/main/module-06

@jonathanbossenger
Copy link
Collaborator Author

@justintadlock awesome. I took a look at the outline, and I think it's great. 🎉

I ran a twitch stream on patterns today in preparation for my online workshop on Thursday, you can see the outline I'm planning for the workshop here, there is a lot of overlap with your lesson outline.

The only thing I might do differently (which I will be doing in the workshop) is to teach the PHP registration first, if only because it's sort of complicated mixing block markup and PHP in a string, and I'd probably recommend folks go the "file in the patterns directory" as a recommended practice. However, I don't think it really matters which way around it works for the lesson.

@justintadlock
Copy link

The draft for the Theme Patterns module is here: https://github.com/justintadlock/block-theme-course/tree/main/module-06

I have finished code review but not quite done with copyediting yet.

@jonathanbossenger
Copy link
Collaborator Author

@justintadlock I'm in the process of reviewing, but I had one realization I wanted to share with you.

One of the things I noticed @wparasae doing in her block theme course was using the different callout blocks on Learn WordPress, for example, the tutorial callout block to indicate steps for the course learner to follow. So I started implementing the same callouts in my course lessons. You can see the info and tutorial callouts used on the first lesson in my block theme course.

I see these callouts as similar to the types of callouts you would use in a technical book, which I'm sure you used working on a certain plugin development book we all know and love. 😁

The four different possible callouts in Learn are:

  • info (useful for links to further reading)
  • tip
  • alert (call out to be aware of something)
  • tutorial (used to indicate action steps)

I realize that I am only raising this now after you've already submitted your fonts module, so my apologies, but for these newer modules, could I ask that you try and isolate any items that might benefit from using these callouts, for example, any "action" steps that we'd like to try and get the learner to perform, further reading resources or tips.

To indicate these in markdown, you can look at some of my lessons from the first 4 modules, but I used a combination of the quote markdown formatting, and an action word highlighted in bold text. For example, this is how I formatted a tutorial callout in markdown.

> **Do** 
> 1. Download the font file
> 2. Install it in your theme

You're welcome to use the same title as the name of the callouts above to make it easier (for example Tutorial instead of Do)

When I add the lesson to Learn, I'll convert the markdown to the relevant blocks.

I'll do a sweep of the font module and implement this when I add it to learn, but I could I ask you to update your other modules in this way, as you know the content best.

@jonathanbossenger
Copy link
Collaborator Author

@justintadlock just did a review of your lessons. Great stuff 🎉 I have no change requests (besides that which I added above) and I'm excited to see the PR to add this to the final course, when you are ready.

@jonathanbossenger
Copy link
Collaborator Author

@justintadlock just leaving a note here (nothing to change) that there is a separate module on Internationalization, so when I create the course content in Sensei, I'll move your Block Patterns section on Internationalizing text in patterns to that module/lesson. This will actually be good, as it will give the course learner two examples to work with in that lesson.

@jonathanbossenger jonathanbossenger changed the title An Introduction to Block Patterns - Lesson Creating Block Patterns - Lesson Nov 21, 2022
@westnz
Copy link
Collaborator

westnz commented Nov 23, 2022

Review:

Patterns are beautifully explained.

I have seen some words in bold here for emphasis, but also elsewhere in the course so far.
image
I completely get it, but as far as I remember, it is not helpful for screen readers. Just thought I will point that out: https://help.siteimprove.com/support/solutions/articles/80000448460-accessibility-the-use-of-emphasis-in-text.

Something else I picked up in this call-out is that one sentence has a full stop, and the others don't.

Also, point 4, add 'a' before 'add Buttons block'. Change to: "Add a Buttons block".

@jonathanbossenger
Copy link
Collaborator Author

I completely get it, but as far as I remember, it is not helpful for screen readers. Just thought I will point that out: https://help.siteimprove.com/support/solutions/articles/80000448460-accessibility-the-use-of-emphasis-in-text.

Thanks for pointing this out. Fortunately for us, the block editor uses the <strong> to mark bold text, not the <b>, which according to the article you linked is considered acceptable.

@jonathanbossenger
Copy link
Collaborator Author

jonathanbossenger commented Nov 29, 2022

Something else I picked up in this call-out is that one sentence has a full stop, and the others don't.

I never know if lists of instructions should have full stops or not... removed the one full stop for now.

@westnz
Copy link
Collaborator

westnz commented Nov 29, 2022

You can leave out full stops for lists 👍

@courtneyr-dev
Copy link
Collaborator

WP 6.4 WordPress/gutenberg#52270 please review for revisions

@courtneyr-dev courtneyr-dev added the hacktoberfest To mark issues for the Hacktoberfest event each October. label Oct 2, 2023
@kaitohm kaitohm moved this from 👋 Ready to Create to 🚧 Drafts in Progress in LearnWP Content - Development Dec 5, 2023
@github-project-automation github-project-automation bot moved this to 👋 Ready to Create in LearnWP Content - Development Dec 5, 2023
@kaitohm kaitohm added fields-done and removed 6.4 hacktoberfest To mark issues for the Hacktoberfest event each October. labels Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🚧 Drafts in Progress
Development

No branches or pull requests

5 participants