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

Allow themes to surface specific patterns from the Patterns Directory #35364

Closed
Tracked by #31153
kjellr opened this issue Oct 5, 2021 · 7 comments · Fixed by #38323
Closed
Tracked by #31153

Allow themes to surface specific patterns from the Patterns Directory #35364

kjellr opened this issue Oct 5, 2021 · 7 comments · Fixed by #38323
Assignees
Labels
[Feature] Pattern Directory The Pattern Directory, a place to find patterns [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@kjellr
Copy link
Contributor

kjellr commented Oct 5, 2021

With the launch of the pattern directory (and the upcoming ability for folks to submit their own patterns to it), we should consider building a route through which themes can highlight specific patterns to their users.

Traditionally, themes have bundled their own proprietary patterns directly via PHP, and tend to highlight them in a category named after the theme:

Screen Shot 2021-10-05 at 1 56 50 PM

This is fine, but it locks those patterns into that one specific theme. What if (for example) a theme could place all of those patterns directly in the Pattern Directory itself, and then reference them from within theme.json. These referenced patterns could either be highlighted in the inserter via a "Theme Name" category, or bubbled up to the top of the list and given a special "theme" badge of some kind.

This would:

  • Cut down considerably on theme code.
  • Make theme patterns far easier to update, test, and review.
  • Encourage theme authors to seed the pattern directory with even more patterns.
  • Reduce pattern redundancy in the Pattern Directory by letting multiple themes reference the same simple patterns.

If a theme's pattern relied on special block styles, then the theme would still be free to register them the traditional way.

Related to #33046, #35115
This should maybe be part of #31153?

@kjellr kjellr added [Type] Enhancement A suggestion for improvement. [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Feature] Pattern Directory The Pattern Directory, a place to find patterns labels Oct 5, 2021
@priethor priethor mentioned this issue Oct 12, 2021
22 tasks
@ntsekouras
Copy link
Contributor

@ryelle how do you think this would be best implemented in patterns directory? I guess people would need to create/select their own category and also maybe have a way to get the data needed for fetching individual patterns(like an id)? 🤔

Do you have any info about the roadmap of opening the patterns submission there? This issue needs some work on pattern directory first and the implementation in GB would be match simpler by adding some fields in theme.json to retrieve and register some patterns.

@ryelle
Copy link
Contributor

ryelle commented Oct 28, 2021

I don't think we've discussed this, but the pattern slug (ex, cover-with-title-and-audio) would probably be a good identifier. The API could then be updated to accept name=cover-with-title-and-audio or something similar, and return a single pattern result… or a list of names and return the full list of patterns for the theme, to avoid multiple API calls.

create/select their own category

Could patterns defined in the theme.json default to being shown in a category with the theme name? Like how the Twenty*s work now.

@ntsekouras
Copy link
Contributor

Could patterns defined in the theme.json default to being shown in a category with the theme name? Like how the Twenty*s work now.

I'm not sure about the nuances of the theme.json property implementation, but when we have an API to fetch them, we'll find a good solution. My first thoughts is that the categories will be from the fetched pattern, because if a theme fetches patterns created from others, is it okay to show them under a the theme's label? 🤷

Could the patterns have a new theme property as well to get them all together?

@ryelle
Copy link
Contributor

ryelle commented Oct 29, 2021

My first thoughts is that the categories will be from the fetched pattern

Ah, true. I was still thinking we would want them also grouped under a "Theme" label. They could be all of the above, since patterns can have multiple categories. You could find a pattern under "Theme Name" and also under "Header" and "Text".

Could the patterns have a new theme property as well to get them all together?

Do you mean on the Pattern Directory side?

@ntsekouras
Copy link
Contributor

ntsekouras commented Oct 31, 2021

Could the patterns have a new theme property as well to get them all together?

Do you mean on the Pattern Directory side?

I meant in their definition in general, but if we register a theme's category in their patterns, we will fetch them all by this specific category. So the question was more whether we store the theme's category in patterns or in a separate field and is probably about if this matters with how patterns directory works internally.

@kjellr
Copy link
Contributor Author

kjellr commented Nov 1, 2021

Could the patterns have a new theme property as well to get them all together?
Do you mean on the Pattern Directory side?

I may not be following this correctly, but in general, I don't think we want to be tagging patterns for a specific theme in the pattern directory, since an individual pattern could (theoretically at least) be used for more than one theme.

@bph
Copy link
Contributor

bph commented Jun 6, 2022

In issue #41282 you'll find a suggested way on how to implement a curated list of patterns from the pattern directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Pattern Directory The Pattern Directory, a place to find patterns [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants