Skip to content

Shuffle content blocks when templateLock is contentOnly #44581

Closed

Description

@jameskoster

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:

shuffle

Note how the layout / colors etc change, but the content blocks (heading, button, image) remain consistent.

Activity

  1. added
    [Feature] PatternsA collection of blocks that can be synced (previously reusable blocks) or unsynced
    on Sep 29, 2022
  2. jameskoster commented on Oct 21, 2022

    @jameskoster
    ContributorAuthor

    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 :)

  3. javierarce commented on Oct 21, 2022

    @javierarce
    Contributor

    This is neat!

    If this is not going to be random I think that the reusable-block icon could be more appropriate to communicate the idea of cycling between patterns.

    image

    Maybe we could add the number of patterns on the label: "Cycle through 3 patterns"

  4. paaljoachim commented on Oct 21, 2022

    @paaljoachim
    Contributor

    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.

  5. richtabor commented on Oct 21, 2022

    @richtabor
    Member

    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.

    Agreed. "Replacing" a template part is still a cumbersome exp.

  6. jameskoster commented on Oct 24, 2022

    @jameskoster
    ContributorAuthor

    If this is not going to be random I think that the reusable-block icon could be more appropriate to communicate the idea of cycling between patterns.

    I agree, that icon can work well to begin with.

    Actually I would like to see this also apply for template parts

    Yeah that would be handy. I think the implementation would be slightly different though, so probably best to do that separately. Related: #44582

  7. javierarce commented on Oct 24, 2022

    @javierarce
    Contributor

    @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.

  8. kevin940726 commented on Oct 24, 2022

    @kevin940726
    Member

    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?

  9. jameskoster commented on Oct 24, 2022

    @jameskoster
    ContributorAuthor

    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.

  10. self-assigned this
    on Oct 25, 2022
  11. kevin940726 commented on Oct 28, 2022

    @kevin940726
    Member

    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.

  12. 4 remaining items

  13. moved this to 🔖 Needs development in Gutenberg Phase 2: Customizationon Nov 2, 2022
  14. annezazu commented on Nov 7, 2022

    @annezazu
    Contributor

    @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 :)

  15. kevin940726 commented on Nov 8, 2022

    @kevin940726
    Member

    @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 ;)

  16. kevin940726 commented on Nov 9, 2022

    @kevin940726
    Member

    I opened #45618 for further discussion on one of the approaches mentioned here 🚶

  17. moved this from 💻 Needs development to 🏗 In progress in Gutenberg Phase 2: Customizationon Nov 15, 2022
  18. ellenbauer commented on Nov 21, 2022

    @ellenbauer

    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.

  19. jameskoster commented on Nov 22, 2022

    @jameskoster
    ContributorAuthor

    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.

  20. paaljoachim commented on Apr 7, 2023

    @paaljoachim
    Contributor

    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.

  21. moved this from 🏗 In progress to 💻 Needs development in Gutenberg Phase 2: Customizationon Apr 19, 2023
  22. moved this from 💻 Needs development to 📋 Backlog in Gutenberg Phase 2: Customizationon May 31, 2023
  23. annezazu commented on May 31, 2023

    @annezazu
    Contributor

    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.

  24. jameskoster commented on Jul 12, 2023

    @jameskoster
    ContributorAuthor

    The full scope of pattern shuffling will likely be identified during #27575.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Needs DevReady for, and needs developer efforts[Feature] Pattern DirectoryThe Pattern Directory, a place to find patterns[Feature] PatternsA collection of blocks that can be synced (previously reusable blocks) or unsynced

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions