You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Shuffle content blocks when templateLock is contentOnly #44581
When a container has templateLock is contentOnly applied, it would be neat to offer a way to cycle between patterns that utilise the same 'content' blocks.
Here's a demo:
Note how the layout / colors etc change, but the content blocks (heading, button, image) remain consistent.
Reacted by Paal Joachim Romdahl, annezazu, Carolina Nymark, Boyan Bratvanov, Francesco Pepe and Sascha Paukner
I suspect the details of this one (the icon, it's position in the toolbar) can be ironed out during implementation. Marking as needs dev and sending a ping to @WordPress/gutenberg-design for feedback on those details :)
Actually I would like to see this also apply for template parts. A cycle through to test out various headers and footers or other template parts as I experiment with various designs while in the Site Editing mode.
@jameskoster after I published that comment I realized that if there are a lot of patterns, reaching the ones at the end of the list could take a while, and picking random patterns could actually be better.
Hi! I'm interested in giving this a shot! If I'm not mistaken, I think we should use the blockTypes field to search for matched patterns. I don't think most of the default loaded patterns have blockTypes set though?
after I published that comment I realized that if there are a lot of patterns, reaching the ones at the end of the list could take a while, and picking random patterns could actually be better.
Oh yes, I agree it should be random. I think the icon still works though.
If I'm not mistaken, I think we should use the blockTypes field to search for matched patterns. I don't think most of the default loaded patterns have blockTypes set though?
I'm not sure exactly how it works, but I believe blocks can be marked as having a content component? Ideally the shuffle functionality would count the number of content blocks in the container and cycle through patterns that include the same quantities. Any other block is ignored for the purpose of matching. IE a pattern with 1 heading and 2 paragraphs would cycle through other patterns containing 1 heading and 2 paragraphs.
Ideally the shuffle functionality would count the number of content blocks in the container and cycle through patterns that include the same quantities.
I tried this approach out but I don't think it worked out nicely in practice. We have this __experimentalRole field for each attribute, and they can be marked as content to allow editing in contentOnly mode. However, they don't have any semantic meanings, which means they will likely match very different patterns in result. For instance, a cover block pattern will match not only other cover block patterns but also any pattern that has a paragraph block. It could match a footer pattern or a text pattern. I'm not sure if that is what the user would expect?
Maybe we should use blockTypes instead, as that is defined by the block authors and can be conveyed their semantic meanings. Header patterns will only match their header patterns and footer patterns will only match their footer patterns.
Moreover, currently a navigation block (and some other blocks) is not considered a content block, but we should also provide the ability to shuffle to other navigation patterns as well. That is, a pattern with no content blocks should still have a list to shuffle.
@kevin940726 wanted to check in here! What do you need to get unblocked? We're coming up on two weeks since you were jumping in so I wanted to ensure you had the support you needed to keep this work going :)
@annezazu I'm working on a draft PR for a partial implementation so that we can discuss it further with a working branch. I'll polish it a bit and open it tomorrow ;)
Reacted by annezazu, Rich Tabor, Ellen Bauer and Paal Joachim Romdahl
I really like this. I wonder if it could even be extended to entire templates? E.g. if we have an About page and the user can shuffle the patterns to show variations?
We could create a similar result like AI tools are exploring (like durable.co) but with a bit of curation from the theme/pattern builder. Is this something this is explored already?
If we could define the patterns more precisely, for instance using categories, it could be a powerful experience for users.
A key principle of the shuffle mechanic is that the constituent content blocks remain the same every time. In that light I feel it's best suited to smaller patterns. That's not to say your suggestion isn't a good one, it is! But it feels like something we can explore more as a part of the page / template creation flows. You may be interested in #42325 which is somewhat related.
I am adding a comment which might not fit in here. Anyhow here goes. I can always add it to another issue as well.
I believe a pattern block has been suggested in another issue. I find that an interesting idea.
Anyhow adding a pattern could include a cycle icon in the toolbar so that one can easily select the pattern group toolbar to cycle through available patterns for the specific category one selected it from.
Perhaps adding a pattern should have it add as a pattern group option. Kind of like a new Group block option along with the various other options that currently exist for the Group block.
More brainstorming.
Let's say that I change a standard Group block into a Pattern block. It now can be saved as a Pattern. I would need to select the category and select to Save it as a pattern. It would also need to be selected as a synced or not synced block (Reusable or not). This way the flow between a Group <-> Pattern would be much smoother experience. Because all patterns exist inside a Group block.
This means a Pattern is a kind of special Group block which currently exist in the pattern categories.
Actually one more thing came up while I was doing the latest call for FSE testing.
Adding in a pattern I had no way to change the pattern into a template part.
Adding to the above brainstorming.
Let's say that I add in a Pattern Group block. As long as I use this pattern option in the Group block I could have a way through the sidebar options to select which template part this should replace. Be it Header, General or Footer.
Activity
jameskoster commentedon Oct 21, 2022
I suspect the details of this one (the icon, it's position in the toolbar) can be ironed out during implementation. Marking as needs dev and sending a ping to @WordPress/gutenberg-design for feedback on those details :)
javierarce commentedon Oct 21, 2022
This is neat!
If this is not going to be random I think that the
reusable-blockicon could be more appropriate to communicate the idea of cycling between patterns.Maybe we could add the number of patterns on the label: "Cycle through 3 patterns"
paaljoachim commentedon Oct 21, 2022
A very cool idea James!
Actually I would like to see this also apply for template parts. A cycle through to test out various headers and footers or other template parts as I experiment with various designs while in the Site Editing mode.
richtabor commentedon Oct 21, 2022
Agreed. "Replacing" a template part is still a cumbersome exp.
jameskoster commentedon Oct 24, 2022
I agree, that icon can work well to begin with.
Yeah that would be handy. I think the implementation would be slightly different though, so probably best to do that separately. Related: #44582
javierarce commentedon Oct 24, 2022
@jameskoster after I published that comment I realized that if there are a lot of patterns, reaching the ones at the end of the list could take a while, and picking random patterns could actually be better.
kevin940726 commentedon Oct 24, 2022
Hi! I'm interested in giving this a shot! If I'm not mistaken, I think we should use the
blockTypesfield to search for matched patterns. I don't think most of the default loaded patterns haveblockTypesset though?jameskoster commentedon Oct 24, 2022
Oh yes, I agree it should be random. I think the icon still works though.
I'm not sure exactly how it works, but I believe blocks can be marked as having a
contentcomponent? Ideally the shuffle functionality would count the number ofcontentblocks in the container and cycle through patterns that include the same quantities. Any other block is ignored for the purpose of matching. IE a pattern with 1 heading and 2 paragraphs would cycle through other patterns containing 1 heading and 2 paragraphs.kevin940726 commentedon Oct 28, 2022
I tried this approach out but I don't think it worked out nicely in practice. We have this
__experimentalRolefield for each attribute, and they can be marked ascontentto allow editing incontentOnlymode. However, they don't have any semantic meanings, which means they will likely match very different patterns in result. For instance, a cover block pattern will match not only other cover block patterns but also any pattern that has a paragraph block. It could match a footer pattern or a text pattern. I'm not sure if that is what the user would expect?Maybe we should use
blockTypesinstead, as that is defined by the block authors and can be conveyed their semantic meanings. Header patterns will only match their header patterns and footer patterns will only match their footer patterns.Moreover, currently a navigation block (and some other blocks) is not considered a
contentblock, but we should also provide the ability to shuffle to other navigation patterns as well. That is, a pattern with nocontentblocks should still have a list to shuffle.4 remaining items
annezazu commentedon Nov 7, 2022
@kevin940726 wanted to check in here! What do you need to get unblocked? We're coming up on two weeks since you were jumping in so I wanted to ensure you had the support you needed to keep this work going :)
kevin940726 commentedon Nov 8, 2022
@annezazu I'm working on a draft PR for a partial implementation so that we can discuss it further with a working branch. I'll polish it a bit and open it tomorrow ;)
kevin940726 commentedon Nov 9, 2022
I opened #45618 for further discussion on one of the approaches mentioned here 🚶
ellenbauer commentedon Nov 21, 2022
I really like this. I wonder if it could even be extended to entire templates? E.g. if we have an About page and the user can shuffle the patterns to show variations?
We could create a similar result like AI tools are exploring (like durable.co) but with a bit of curation from the theme/pattern builder. Is this something this is explored already?
If we could define the patterns more precisely, for instance using categories, it could be a powerful experience for users.
jameskoster commentedon Nov 22, 2022
A key principle of the shuffle mechanic is that the constituent content blocks remain the same every time. In that light I feel it's best suited to smaller patterns. That's not to say your suggestion isn't a good one, it is! But it feels like something we can explore more as a part of the page / template creation flows. You may be interested in #42325 which is somewhat related.
paaljoachim commentedon Apr 7, 2023
I am adding a comment which might not fit in here. Anyhow here goes. I can always add it to another issue as well.
I believe a pattern block has been suggested in another issue. I find that an interesting idea.
Anyhow adding a pattern could include a cycle icon in the toolbar so that one can easily select the pattern group toolbar to cycle through available patterns for the specific category one selected it from.
Perhaps adding a pattern should have it add as a pattern group option. Kind of like a new Group block option along with the various other options that currently exist for the Group block.
More brainstorming.
Let's say that I change a standard Group block into a Pattern block. It now can be saved as a Pattern. I would need to select the category and select to Save it as a pattern. It would also need to be selected as a synced or not synced block (Reusable or not). This way the flow between a Group <-> Pattern would be much smoother experience. Because all patterns exist inside a Group block.
This means a Pattern is a kind of special Group block which currently exist in the pattern categories.
Actually one more thing came up while I was doing the latest call for FSE testing.
Adding in a pattern I had no way to change the pattern into a template part.
Adding to the above brainstorming.
Let's say that I add in a Pattern Group block. As long as I use this pattern option in the Group block I could have a way through the sidebar options to select which template part this should replace. Be it Header, General or Footer.
annezazu commentedon May 31, 2023
Marking this as a backlog item at this point with this work being impacted by larger wp:pattern efforts #48458 yet being lower priority in comparison.
jameskoster commentedon Jul 12, 2023
The full scope of pattern shuffling will likely be identified during #27575.