-
Notifications
You must be signed in to change notification settings - Fork 272
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
Blueprints sidebar section for single-click Playground presets #1759
Conversation
Nice, this is cool |
This is great! Let's see with @jarekmorawski how to integrate it into the new UI.
I don't think that we need this for v1. It's frequently hard to visualize a blueprint in an interesting way (examples add mu-plugin, install theme from git).
I would keep it consistent with the rest of the UI. Clicking on preview should start that site on the right side of the sidebar. Ideally as a temporary site so that users can save it from the manage UI if they want to. |
Right, but would clicking through 10 Blueprints leave me with 10 temporary sites? Or would it clean up those sites as I browse? An idea: create a single temporary Playground called "Blueprint preview" and reset it with the last selected Blueprint every time. |
The temp site could be created when you expand the site, so if you are just clicking on items, they wouldn't be created. This would also be useful for temporary sites in general. |
This is such a great idea.
Since #1731 is keeping multiple temporary sites in-memory, this sounds like a good compromise to me. Perhaps we could create a separate temporary site (and notify the user) whenever they start interacting with "Blueprint preview". At that point, they aren't merely clicking through options but have started "trying things on". |
7d97425
to
fce5346
Compare
I'm wondering if using the blueprint gallery will be the best thing in the long term. This section is technically Playground Apps. You go there and add a WordPress-based app to your Playground. The Blueprint gallery is more about showing the technical capabilities of Playground while this could be much more. Imagine going to Playground.WordPress.net or your locally installed PWA and seeing all your apps there. To get more apps you just go to the apps section and install more. |
Can someone inspect the underlying json? |
@asirota I'm happy to help, please open new issue and share the file with us. |
@bgrgicak sorry I wasn't more clear. I meant could there be a feature in this to inspect the json of the blueprint being previewed? Useful for learners. |
To me, showcasing technical capabilities is just a convenient starting point for the Blueprints gallery. It can be both a source of demos and a source of powerful apps. Both use-cases require a central location, contributing workflows, integrations, ways of forking and remixing the Blueprints. Why split that in two places? Once we have powerful app-like Blueprints, we can just add a Note all WordPress directories already work this way. There are demo themes like stacks, and there are powerful themes like TwentyTwentyFour. There are demo blocks and app-like block suites. There are demo plugins like hello-dolly or classic-editor, and there are app-like plugins such as WooCommerce. And in an even longer term, we can propose Blueprints for WordPress core and it will already have an extensive Blueprints directory on day 1. |
I agree, it's more about the naming, but I'm probably jumping 5 steps ahead. |
680cd19
to
2e376d2
Compare
8bbb06c
to
49d0c43
Compare
Closing this related issue: #1463 |
## Motivation for the change, related issues We added a general CSS reset to the web app styles in #1759, and some modal dialog content depended on user agent styles for rendering properly. For example, before the CSS reset, the GitHub auth dialog used to be styled like this: <img src="https://github.com/user-attachments/assets/b3a2c91b-6a30-4385-9a90-190b510bcd44" width="600"> After the reset, its paragraphs lost default vertical margins, and content in a `<b>` element lost its bold look. After the reset, the dialog looked like this: <img src="https://github.com/user-attachments/assets/005b8d9f-3fe2-446b-ab7f-0f9fccb47854" width="600"> ## Implementation details The PR attempts to restore the styles assumed by modals before this change. This PR adds some style rules for modals to restore vertical margins to paragraph elements and boldness to `<b>` tags. A downside to this approach is that we'll have to manually add CSS rules every time we miss a user agent style that was reset, but an upside to the approach is that we can have consistent, explicit rules for the styles we require. ## Testing Instructions (or ideally a Blueprint) Run `npm run dev`, open all the different dialogs, and confirm they are styled as expected.
Motivation for the change, related issues
Adds the Blueprint Gallery to the Playground UI as a first-class feature.
Implementation
Sourcing the list of Blueprints
GitHub automation maintains a JSON index of all the Blueprints in the directory at https://raw.githubusercontent.com/WordPress/blueprints/trunk/index.json. This PR just sources that data and adds a DataView where it can be browsed.
It ships a new
useFetch()
React hook that makes the state management aroundfetch()
easier. Maybe this simplistic hook will be enough, or maybe we'll quickly replace it withreact-query
or so. We'll see.Fetch proxy for offline caching
This PR ships a "proxy" service worker route for offline caching of cross-origin requests.
Playground is now an offline-enabled PWA and anytime we rely on network resources, we must consider what happens when there's network connectivity.
For same-origin request, that's easy. We can just cache them in the
fetch
event handler in the service worker. However, that event handler won't handle cross-origin requests. Therefore, this PR ships a special same-origin/proxy/network-first-fetch/
route that can cache cross-origin requests inCacheStorage
.For example, the following request would fetch the list of all the Blueprints from the Blueprints directory:
The service worker would be notified, then it would strip the
https://playground.wordpress.net/proxy/network-first-fetch/
prefix, and source the actual information fromhttps://raw.githubusercontent.com/WordPress/blueprints/trunk/index.json
. If the network is available, it will always request the fresh data. If the network is not available, it would source the data fromCacheStorage
if available.Testing Instructions
Interact with the gallery, confirm it works in the offline mode, confirm the blueprints load without issues and that the rest of the UI works the same as before this PR.
Follow-up work
cc @brandonpayton @bgrgicak @mtias