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

Try using blocks for block content #270

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

adamwoodnz
Copy link

@adamwoodnz adamwoodnz commented Apr 19, 2024

Replace wporg_support_get_forums_list() in functions.php which returns block content, with a server rendered block.

This follows the approach we took with Developer Resources.

There are several more functions which do the same, if we decide this approach is beneficial we can convert them too.

Includes dependencies and scripts for building blocks.

Pros: feels less hacky to have this code which converts bbPress templates into blocks, contained in blocks, rather than output from functions.php

Cons: requires a build process

Is this worth doing?

@ryelle
Copy link
Contributor

ryelle commented Apr 19, 2024

I suppose the question is whether we would eventually iterate to a point where bbpress/loop-forums-homepage.php is a block template (html) instead of a PHP template? Because since it's not a block template, we're not restricted by the same technical issues that require a block wrapper in true block themes.

Do any other benefits of blockifying exist here?

  • Could layout and other block styles reduce CSS?
  • Would blocks help in organizing CSS?
  • Any interactive sections with custom JS that could be modernized with the interactivity API?
  • Are any simple sections that could be done with core blocks + block bindings? (for example, the Edit button in patterns is a core button block, with bindings that pass through the button URL and text, avoids creating a custom button block)
  • Are there existing issues with the new theme that this will fix? or planned enhancements that this will help?

I don't think requiring a build process is a true drawback here, in fact if we move the CSS to src/style, we could drop the grunt step like the other theme redesigns.

@adamwoodnz
Copy link
Author

I suppose the question is whether we would eventually iterate to a point where bbpress/loop-forums-homepage.php is a block template (html) instead of a PHP template? Because since it's not a block template, we're not restricted by the same technical issues that require a block wrapper in true block themes.

At this point I don't have a good grasp on how much work this would require, but my understanding is that we're not going to be iterating on this much in the near future.

Do any other benefits of blockifying exist here?

I don't think so, these functions are just returning non-interactive content and require no extra CSS. They already use block markup for styles.

Seems like the previously mentioned pros and cons are actually both pros. For the small amount of effort required maybe it's worth doing just for these and to set us up for the future.

Replace functions which return block content with blocks.
Includes dependencies and scripts for building blocks
@adamwoodnz adamwoodnz force-pushed the try/forums-theme-blocks branch 2 times, most recently from dd499df to d5c6efc Compare April 22, 2024 00:10
@adamwoodnz
Copy link
Author

adamwoodnz commented Apr 22, 2024

I don't think requiring a build process is a true drawback here, in fact if we move the CSS to src/style, we could drop the grunt step like the other theme redesigns.

I've now migrated from grunt to wp-scripts, based on the config from the Main theme. All seems to be working fine, although haven't tested RTL yet. Not sure what kind of state that is in before or after these changes.

@StevenDufresne
Copy link
Contributor

I don't see the reward in making this change unless it comes with tangible benefits for our users.

I don't think it makes the developer experience much better, if at all, nor does it future-proof the code based on my understanding of what's being proposed.

@adamwoodnz
Copy link
Author

My motivation was mostly coming from a best practice/devex angle, so if no-one else finds the current solution too unpleasant we can leave as is.

@adamwoodnz
Copy link
Author

One nice devex improvement with the wp-scripts build is that the CSS sourcemaps work, unlike the current one. I haven't spent the time to fix that, didn't seem worth it.

@adamwoodnz
Copy link
Author

One nice devex improvement with the wp-scripts build is that the CSS sourcemaps work, unlike the current one. I haven't spent the time to fix that, didn't seem worth it.

in fact just this build change is worth doing IMO. Replacing the old grunt build removes tech debt and brings devex consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants