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

Show patterns in theme directory. #83

Closed
wants to merge 1 commit into from
Closed

Show patterns in theme directory. #83

wants to merge 1 commit into from

Conversation

StevenDufresne
Copy link
Contributor

@StevenDufresne StevenDufresne commented Jul 7, 2022

I've opened up this PR as a place for discussion on https://meta.trac.wordpress.org/ticket/5995. While this PR comes with code updates, it's purely experimental and not necessarily the best implementation or experience. I would have preferred to use an issue but they are closed for this repository and having the discussion in trac feels a bit limiting.

Assumption

It would be helpful for users to be able to preview patterns that are bundled with themes in the theme directory.

Details

How can we detect patterns?

Static code analysis

  • Search for:
    • register_block_pattern (JS, PHP)
    • theme.json (Link)
    • /patterns (Link)

Dynamic analysis (with running environment)

  • JS: wp.data.select('core').getBlockPatterns() (Link)
  • PHP: WP_Block_Patterns_Registry::get_all_registered() (Link)

When can we detect patterns?

  • Theme Upload
    • class-wporg-themes-upload.php (Static) (Link)
    • Get Results from Theme Review Action (Dynamic) (Link)
  • Cron Job
    • I don't think any exist yet

... store results in meta for repopackage...

  • Dynamically on page load
    • This would only work for the Theme Preview since it has a running environment when the user interacts with it.

Where could we show patterns?

Theme Directory

  • Directory View (Link)
  • Single Theme View (Link)
  • Theme Preview (Link -> Click "Preview Button")

Ideas

The theme directory is likely to undergo a redesign in the next year or so. If we want to get something up before that completes, which probably makes sense, we should aim to make the most minimal changes.

Directory View

We could add Icons to the theme tile to denote that a theme bundles patterns.

A B
Screen Shot 2022-07-08 at 8 24 15 AM Screen Shot 2022-07-08 at 8 36 13 AM

Single Theme View

We can add a section below the tags. It could be a list of the pattern names or could also use pattern directory previewer. If so, It would have to have some sort pagination control experience since some themes bundle 10+ patterns.

Screen Shot 2022-07-08 at 8 46 25 AM

Theme Preview

What if we give a navigation item that users can click that loads a dynamically generated page with all the patterns? I've added blocks to the menu just as an example.

Screen Shot 2022-07-08 at 9 10 36 AM

@StevenDufresne StevenDufresne changed the title Grab patterns when theme is uploaded. Show patterns in theme directory. Jul 8, 2022
@adamwoodnz
Copy link

adamwoodnz commented Jul 8, 2022

For the Single Theme view, even simpler than using a pattern preview could be having a carousel of patterns, with each pattern using something like a pattern grid item:
Screen Shot 2022-07-08 at 1 24 56 PM

I'm not sure if having all the functionality of the preview is necessary here (drag to resize, etc.), although I guess that could be disabled.

@adamwoodnz
Copy link

I think all these ideas have merit. If we were to have a Patterns view from the Theme Preview page that could probably use a pattern grid too.

@adamwoodnz
Copy link

On theme upload seems the most efficient, as long as that lifecycle runs every time a theme is changed.

@mtias
Copy link
Member

mtias commented Jul 8, 2022

Note that themes can auto-register patterns by placing them in a /patterns folder with the appropriate headers: WordPress/gutenberg#36751

@StevenDufresne
Copy link
Contributor Author

StevenDufresne commented Jul 11, 2022

For the Single Theme view, even simpler than using a pattern preview could be having a carousel of patterns, with each pattern using something like a pattern grid item: [...]

I'm not sure if having all the functionality of the preview is necessary here (drag to resize, etc.), although I guess that could be disabled.

Just noting, we don't have screenshots of patterns yet, and the image you shared uses the underlying control of the pattern preview control, without the controls.

On theme upload seems the most efficient, as long as that lifecycle runs every time a theme is changed.

Yep, new uploads and updates to themes are centralized.

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.

3 participants