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

Update applying-styles-with-stylesheets.md #45604

Conversation

jonathanbossenger
Copy link
Contributor

What?

Updates the documentation for the developing blocks How To guide, specifically the step on applying styles with stylesheets, to include instructions on either running the build step or manually updating the block.asset.php file, so that it adds the 'wp-block-editor' object as a dependency.

Why?

For the new block developer, adding this step will ensure that they update the asset file, and don't run into any errors, if they are trying out this code for the first time.

How?

Adds documentation steps for both JSX and plain JavaScript to add this as a dependency

@codesandbox
Copy link

codesandbox bot commented Nov 8, 2022

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

Copy link
Contributor

@ryanwelcher ryanwelcher left a comment

Choose a reason for hiding this comment

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

Instructing the user to manually edit the index.asset.php feels a bit brittle to me as those changes will be lost immediately once the start or build commands are run. This will be especially confusing to those that are new to building blocks.

What is the use case, where we need to enqueue the wp-block-editor script but not use it in the the block JS?

@jonathanbossenger
Copy link
Contributor Author

@ryanwelcher the use case is for folks who want to learn to build blocks without using JSX/React, and therefore the build command is not run.

As you know, it's possible to develop blocks without using React/JSX, and the Block Tutorial offers both JSX and Plain JavaScript code examples. While this is not the recommended way, it is possible and might help lower the barrier to entry for block developers who don't want to have to set up the whole Node/npm environment.

In the previous step of the guide, instructions are given on how to create the block.asset.php file, when following the "Plain" option.

However, in the Using Styles and Stylesheets guide, the blockEditor package is implemented in order to use useBlockProps, without the original asset file updated with the wp-block-editor dependency. If someone were following this guide on developing blocks and opting for the Plain option, their code would not work, as I discovered in my live stream today

I'm open to moving this change to elsewhere in the documentation, perhaps an update to the original mention of creating the file, but I think it's important to point out that if one is following the Plain JavaScript solution, one needs to manually add any additional dependencies to the asset file.

@ryanwelcher ryanwelcher self-requested a review November 9, 2022 03:39
Copy link
Contributor

@ryanwelcher ryanwelcher left a comment

Choose a reason for hiding this comment

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

@jonathanbossenger thank for the clarification and sorry for my misunderstanding.

@carolinan carolinan merged commit 3076dec into WordPress:trunk Nov 9, 2022
@github-actions github-actions bot added this to the Gutenberg 14.6 milestone Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants