Props to @daisyo and @jffng for the massive amount of help in writing and perfecting this call for testing.
At the highest level, theme.json is a configuration file used to enable or disable features and set default styles for both a website and blocks. Rather than dealing with a ton of theme support flags or alternative methods, theme.json provides a consolidated and canonical way to manage it all. These settings include options like:
- What customization options should be made available or hidden from the user.
- What are the default colors, font sizes, etc available to the user.
- Defines the default layout of the editor (widths and available alignments).
This configuration file is a big part of what makes block Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. themes so powerful as it allows for finer-grained control, and introduces the first step in “managing styles” for future WordPress releases. Here are a few of the top benefits of using this new mechanism:
- It allows themes to provide settings per block which wasn’t possible before since add_theme_support targets settings for the entire editor.
- Themes using theme.json will automatically get classes and CSS CSS is an acronym for cascading style sheets. This is what controls the design or look and feel of a site. Custom Properties enqueued for the presets they declare instead of needing to handle this themselves. Plus, this means translations of preset names are also managed for them!
- Theme.json will coordinate core Core is the set of software required to run WordPress. The Core Development Team builds WordPress., theme, and user styles in a way that reduces the amount of CSS that needs to ship as well as help resolve specificity problems.
While block themes won’t work with WordPress 5.8 without the Gutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ plugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party due to some theme blocks being left out of the release that weren’t quite ready to ship, it’s still an important feature coming to 5.8 that needs testing and exploration. If you’ve been curious about the world of block themes or have started building your own, this call for testing is for you and should help you to continue to explore what’s possible with theme.json while giving you a chance to share what else you’d like to see.
You can read more about this feature in the documentation here.
Beginner Testing Steps
This section is for those wanting to get a sense of what theme.json can control and what the output will look like.
- Head to https://gutenberg-theme.xyz/. This is a tool that can help generate the settings section of the theme.json file.
- From there, try toggling on and off various theme supports. This will help you explore just a few settings that are possible to control with theme.json. For example, you can toggle on and off Custom Colors or Custom Link controls. Notice that the output in the browser changes based on your selection.
- Use the + button next to Palette, Gradients, or Font Sizes to explore adding customizations. Keep in mind that you can edit both the slug and specific variables, like color name or font size.
- Add a few customizations and review the output! If you want to go a step further and use what you’ve created, check out the intermediate steps.
Intermediate Testing Steps
This section is for those wanting to dig deeper into theme.json by writing their own file and exploring the various settings it can control.
Note: this mainly focuses on just theme supports and presets for blocks in the settings section of theme.json rather than Global Styles.
Set up your testing environment
- Create a Fresh WordPress Install.
- Install and Activate Gutenberg Plugin while using the latest version (10.9.0 as of writing this).
- Download and Install TT1 Blocks from the Theme Directory.
- Navigate to the TT1 Blocks Theme directory and open the theme.json file in a text editor or IDE.
- Replace the theme.json file with this gist before starting the next steps. It’s expected that this will really simplify what the theme looks like so don’t panic if you see a lot of options removed. This is intentional to simplify the settings you’re changing.
Generally speaking, please use the latest versions of each part of the setup and keep in mind that versions might have changed since this post was shared.
- Create a new post.
- Add a cover block with a solid colored background and several lines of content in an inner paragraph block to the post.
- Add another cover block with a solid colored background and several lines of content in an inner paragraph block. Set this block to “Wide Width”.
- Add a third cover block with a solid colored background and several lines of content to the post and set the block to “Full Width”.
- Publish Post.
- Load the post on the front end and note the width of the cover blocks.
- Change the
contentSize value to a different pixel value in the layout section of theme.json.
wideSize value to a different pixel value in the Layout section of theme.json.
- Load the edit view of the previously created post and confirm that new widths are reflected in the editor
- Load the post on the front end and confirm that the new widths are reflected on the front end of the site
- Extra Credit: Try setting the width values to something other than “px” such as “em”, “rem”, “vh”, “vw”, or “%”.
- Set the following typography settings to
- customFontWeight (Heading Block)
- customFontSize (Paragraph Block)
- customLineHeight (Paragraph Block)
- dropCap (Paragraph Block)
- Test the visibility of typography settings in a paragraph block (font size, line height and drop cap).
- Test the visibility of typography settings in a Heading block (font size, font weight, line height).
- Test that each of settings apply to the block on the front end.
- Change the typography settings to false in theme.json.
- Confirm that each of the custom typography settings in the paragraph block are no longer present in the block editor (Note the typography settings applied previously may still apply to existing blocks).
- Extra credit: Add one or more font families and font sizes to the typography section of the theme.json file. Test your custom font families and sizes using a Button block.
- Set the following border settings to
- Create a group block with an inner paragraph block with several lines of text.
- Test visibility of border settings in a group block (Style, Width, Radius, Custom Color).
- Test that settings apply to the block on the front end.
- Change the above border settings to
false in theme.json.
- Confirm that border settings in group block are no longer present in the block editor.
- Set the following color settings for custom and customGradient to
- Add a cover block with a custom gradient background and several lines of content in an inner paragraph block to the post.
- Add a link to the paragraph block and set the link color to a custom color.
- Add another cover block with an image background and several lines of content in an inner paragraph block to the post. Set the cover background to use a duotone preset.
- Change the duotone colors for the background image to use custom colors for the duotone shadows and highlights settings.
- Extra Credit: Add one or more additional colors to the palette and duotone or gradient presets. For more information about CSS gradients check these resources from CSS Tricks and CSS Gradient. Keep in mind that for duotone presets, you’ll need to use RGB, Hex or specifically named colors when adding custom colors.
(Very) Advanced Testing Steps
This section is for those looking to create a more robust block theme using theme.json and who are experienced theme developers. This isn’t for everyone!
If you feel more comfortable with block themes and have ample time to dig into theme.json, try replicating a classic theme. Here are two options that should be fun to dig into but keep in mind any default theme should work well:
As you try to do this, write down what gaps remain, what proves to be the most difficult to do, and what feels surprisingly easy! Share in the comments below so we can learn from your experience. This is intentionally extremely open ended and advanced so don’t worry if you don’t feel up for the challenge. If you want to follow along while someone else explores doing this, check out @mkaz‘s exploration video on learning to create a block theme.
What to notice:
These questions are specifically for the Intermediate and Advanced sections:
- Do the colors added to the theme.json file appear with the assigned names visible on hover in the color palette for various blocks?
- Do the font sizes added to the theme.json file appear with the assigned names and sizes in the font size dropdowns in blocks?
- Do the colors and font sizes appear correctly when used with blocks in the editor?
- Do the colors and font sizes appear correctly when used with blocks on the front end?
- What did you find particularly confusing or frustrating about the experience?
- What did you especially enjoy or appreciate about the experience?
Leave Feedback by July 14th
Please leave feedback (questions, comments, concerns) in the comments of this post and be sure to note which section you followed. If you’d prefer, you’re always welcome to create issues in this GitHub repo directly for Gutenberg but, for this test, it’s unlikely you’ll need to. However, if you do leave feedback in GitHub GitHub is a website that offers online implementation of git repositories that can easily be shared, copied and modified by other developers. Public repositories are free to host, private repositories require a paid subscription. GitHub introduced the concept of the ‘pull request’ where code changes done in branches by contributors can be reviewed and discussed before being merged be the repository owner. https://github.com/, please comment below with the link.
Join a hallway hangout for theme.json testing on July 7th
To help those who might want to explore this test and theme.json in a group, @daisyolsen will be hosting a hallway hangout specifically for this exercise. If you have never attended a hallway hangout, you can read more about them here. Ultimately, they are meant to be casual and collaborative sessions to bring like minds together.
Hope to see you there.
#fse-outreach-program, #fse-testing-call, #full-site-editing