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

Plugin patterns appear under "Theme patterns" heading #52498

Closed
jameskoster opened this issue Jul 11, 2023 · 15 comments
Closed

Plugin patterns appear under "Theme patterns" heading #52498

jameskoster opened this issue Jul 11, 2023 · 15 comments
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") Needs Design Feedback Needs general design feedback. Needs Design Needs design efforts. [Type] Enhancement A suggestion for improvement.

Comments

@jameskoster
Copy link
Contributor

In the Site Editor Pattern library, patterns added by plugins appear under the "Theme patterns" heading which is inaccurate:

Screenshot 2023-07-11 at 09 48 20
@jameskoster jameskoster added Needs Design Needs design efforts. [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") labels Jul 11, 2023
@jameskoster
Copy link
Contributor Author

Possible solutions:

  1. Update "Theme patterns" to "Theme & plugin patterns".
  2. Add a separate "Plugin patterns" group.

@jameskoster jameskoster added the Needs Design Feedback Needs general design feedback. label Jul 11, 2023
@bgardner
Copy link

Hard vote for #2.

@jeffikus
Copy link

@jameskoster I've been thinking about this for templates as well. I think clarity is the most important thing, so I would want to know where a pattern is coming from/sourced. My vote would be for #2 as well.

@richtabor
Copy link
Member

Could probably just be “Theme” and “Plugin” headings, as “Patterns” is already declared above.

@glendaviesnz
Copy link
Contributor

glendaviesnz commented Jul 11, 2023

In relation to option 2 I had a quick look and I am not sure how we would reliably identify plugin patterns as separate to theme patterns as it seems like both just use register_block_pattern. This currently doesn't provide any source information other than the voluntary use of a hopefully meaningful slug.

We could potentially try and filter out theme patterns by matching the first part of the slug against the theme name, but that seems a little unreliable. I may be missing some other way of identifying that a pattern came from a plugin as apposed to a theme though.

@vcanales
Copy link
Member

vcanales commented Jul 12, 2023

An optional source property was added recently.

  • source (optional): A string that denotes the source of the pattern. For a plugin registering a pattern, pass the string 'plugin'. For a theme, pass the string 'theme'.

It doesn't seem to be used within the Gutenberg codebase as of yet, but I'd imagine we can:

  1. Add source = theme to all patterns registered by a theme, ie. because they are in a theme's patterns/ directory.
  2. Using the source property when available to separate patterns in categories (eg. "Theme patterns", "Plugin patterns", "Other patterns").

@glendaviesnz
Copy link
Contributor

  1. Add source = theme to all patterns registered by a theme, ie. because they are in a theme's patterns/ directory.

I was overlooking the fact that theme patterns are actually registered from the patterns/ dir with _register_theme_block_patterns() , so modifying that method to add the source seems like a good option @vcanales

@jameskoster
Copy link
Contributor Author

@vcanales @glendaviesnz thank you for looking into this. Do you think it's possible this gets done in time for 6.3?

If not we may need to go with option 1, or another equally simple idea. Perhaps we could remove the "Theme patterns" heading entirely, and move template parts beneath them:

Screenshot 2023-07-12 at 10 52 28

@carolinan
Copy link
Contributor

There are many older patterns in themes that were registered before the patterns folder was an option.

@carolinan
Copy link
Contributor

Perhaps we could remove the "Theme patterns" heading entirely, and move template parts beneath them:

Yeah, that would work I think? Now that "My patterns" always show.

@vcanales
Copy link
Member

@carolinan There are many older patterns in themes that were registered before the patterns folder was an option.

Good point; I wasn't aware.

@jameskoster If not we may need to go with option 1, or another equally simple idea. Perhaps we could remove the "Theme patterns" heading entirely, and move template parts beneath them

How about changing it to "Included patterns" for now?

image

Created #52568 to get things rolling.

@carolinan
Copy link
Contributor

As someone who reads things literally, "my patterns" and "included patterns" read strange to me, like, "What do you mean, are my patterns not included?"

@bvlgn
Copy link

bvlgn commented Jul 14, 2023

Yeah, that would work I think? Now that "My patterns" always show.

Actually, "My patterns" won't show when there are no custom patterns:
Scherm­afbeelding 2023-07-14 om 09 38 18

But maybe "My patterns" could/should be shown always, even when no custom patterns are defined, with the count set to 0?

@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Jul 18, 2023
@ndiego
Copy link
Member

ndiego commented Jul 18, 2023

@jameskoster are you ok with punting this one given RC1 is later today? Or will this be considered closed once #52568 is merged?

@jameskoster
Copy link
Contributor Author

Ah I think this is already closed via #52570. Thanks for the ping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") Needs Design Feedback Needs general design feedback. Needs Design Needs design efforts. [Type] Enhancement A suggestion for improvement.
Projects
No open projects
Development

No branches or pull requests

10 participants