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

Add the “Live Preview” button on the Theme Detail page #79775

Merged
merged 12 commits into from
Jul 31, 2023

Conversation

okmttdhr
Copy link
Member

@okmttdhr okmttdhr commented Jul 24, 2023

Related to #79218, #78456

Proposed Changes

This PR adds the “Live Preview” button on the Theme Detail page.

before after
Screen Shot 2023-07-27 at 11 30 20 Screen Shot 2023-07-27 at 11 30 12

Testing Instructions

Simple sites

  • Patch D117384-code into your sandbox.
  • Go to the Theme Showcase page.
  • Click any theme and go to the Theme Detail page.
  • See if clicking the "Live Preview" button redirects you to the Site Editor (Block Theme Previews).
    • You will not see the button when a theme is;
      • your active theme
      • is not FullSiteEditing compatible
      • a theme with a static page as a homepage
      • a 3rd party theme
      • a premium theme
      • a woocommerce theme

Atomic sites

  • Go to the Theme Showcase page.
  • Click any theme and go to the Theme Detail page.
  • You must install a theme before using the Live Preview on Atomic sites. pbxlJb-3Uv-p2#known-issues
    • When you're using Calypso, activate it once and then reactivate the original theme.
    • When you're using the classic view, just install it.
  • See if clicking the "Live Preview" button redirects you to the Site Editor (Block Theme Previews).
    • You will not see the button when a theme is;
      • your active theme
      • is not FullSiteEditing compatible
      • a theme with a static page as a homepage
      • not installed (not listed in "My Themes")

Please see pbxlJb-3Uv-p2#known-issues about unsupported themes.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-ajp-p2)?

@matticbot
Copy link
Contributor

matticbot commented Jul 24, 2023

@matticbot
Copy link
Contributor

matticbot commented Jul 24, 2023

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~795 bytes added 📈 [gzipped])

name                parsed_size           gzip_size
theme                   +2462 B  (+0.4%)     +717 B  (+0.4%)
themes                   +478 B  (+0.1%)      +61 B  (+0.0%)
update-design-flow       +261 B  (+0.0%)      +38 B  (+0.0%)
site-setup-flow          +261 B  (+0.0%)      +38 B  (+0.0%)
import-flow              +261 B  (+0.0%)      +38 B  (+0.0%)
free-flow                +261 B  (+0.0%)      +38 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~40 bytes added 📈 [gzipped])

name                                     parsed_size           gzip_size
async-load-signup-steps-theme-selection       +261 B  (+0.2%)      +40 B  (+0.1%)
async-load-design-blocks                      +261 B  (+0.0%)      +40 B  (+0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@okmttdhr okmttdhr force-pushed the add/btp-theme-page branch from 8fec8f3 to cf1b020 Compare July 25, 2023 07:32
@okmttdhr okmttdhr marked this pull request as ready for review July 27, 2023 02:32
@okmttdhr okmttdhr requested review from valterlorran and kangzj July 27, 2023 02:32
@matticbot matticbot added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jul 27, 2023
@okmttdhr okmttdhr requested a review from a team July 27, 2023 02:32
@okmttdhr okmttdhr self-assigned this Jul 27, 2023
@okmttdhr okmttdhr added [Status] String Freeze Add the [Status] String Freeze label to your PR to ensure new strings are translated before merging and removed [Status] String Freeze Add the [Status] String Freeze label to your PR to ensure new strings are translated before merging labels Jul 27, 2023
}

// A theme should be FullSiteEditing compatible to use Block Theme Previews.
if ( ! isFullSiteEditingTheme ) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not use showTryAndCustomize here as showTryAndCustomize = true does not mean it's not FullSiteEditing compatible. I thought it'd be nice to show the Live Preview button anytime in cases Block Theme Previews is available.

*
* @see pekYwv-284-p2#background
*/
if ( isNotCompatibleThemes( stylesheet ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to account for Atomic site here? Or just Simple sites? Asking because the theme slugs on Atomic sites probably won't be prefixed with /pub or /premium CMIIW

Copy link
Member Author

@okmttdhr okmttdhr Jul 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stylesheet includes prefixes (pub/, premium/) even on Atomic sites!

This is the reason I switch themePath depending on if it's Atomic or Simple here. https://github.com/Automattic/wp-calypso/pull/79775/files/ac6c6b80c7ed9a71ab8d736db5254a1e8ce4eceb#diff-6535b936322e5679c10cdf1adeac00cda6c355312582892d7a634c4e2d6fbd64R120-R124

Let me know if I did not answer your comment 🙏

@okmttdhr okmttdhr requested review from taipeicoder, fushar and a team July 28, 2023 02:24
@okmttdhr

This comment was marked as outdated.

@okmttdhr okmttdhr marked this pull request as draft July 28, 2023 02:49
@taipeicoder

This comment was marked as resolved.

@okmttdhr okmttdhr force-pushed the add/btp-theme-page branch from d8c1c21 to 2fe123f Compare July 28, 2023 07:26
@okmttdhr
Copy link
Member Author

I might find the flaw in #79775 (comment). Let me check for a moment... 🔄

I thought it was a bug on my side since BTP did not load, but it was caused by the core change.
I temporarily created a diff D117384-code, and added testing instruction that we need to patch it.

@okmttdhr okmttdhr marked this pull request as ready for review July 28, 2023 07:30
Copy link
Contributor

@taipeicoder taipeicoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as intended, LGTM! 🎉

@taipeicoder
Copy link
Contributor

A minor detail, the Live Preview button should have border-radius: 4px.
Screenshot 2023-07-31 at 12 31 13 PM

@okmttdhr okmttdhr force-pushed the add/btp-theme-page branch from 2fe123f to ad9376f Compare July 31, 2023 05:21
@okmttdhr okmttdhr merged commit 3205b9b into trunk Jul 31, 2023
@okmttdhr okmttdhr deleted the add/btp-theme-page branch July 31, 2023 05:43
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 31, 2023
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.

4 participants