-
Notifications
You must be signed in to change notification settings - Fork 2k
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
SPT: preview into an iFrame element #39628
Conversation
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
content: __( 'Select a layout to preview.', 'full-site-editing' ), | ||
} ) | ||
: [ | ||
createBlock( 'core/heading', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that core/site-title
is now available too, if it helps. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes a lot of sense. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean I'm not able to create a core/site-title
block.
> wp.data
.select( 'core/blocks' )
.getBlockTypes()
.map( block => block.name )
.filter( name => name.match( /title/ ) );
it returns an empty []
array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right. We have Gutenberg 7.3.0 on wpcom currently (about to be updated to 7.6.0, p7DVsv-8c5-p2) and it likely doesn't have it yet.
Even once that's rolled out, I'd expect to have Atomic sites which are on an older versions of Gutenberg or have disabled it completely. I don't know if the whole FSE plugin with SPTs loads in that case tho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simison Can you spin out a separate Issue for this one so it can be tracked? I think it's unlikely that we'll tackle it here. Much appreciated.
It looks like the FSE plugin test failures are only because the behavior of FSE has changed :) |
} | ||
|
||
// coblocks/gallery mock | ||
.coblocks-gallery { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we please not include override-CSS like this if it's normally generated by JS? Let's solve the root problem instead.
It's going to be hugely problematic for keeping this CSS updated together with CoBlocks plugin version updates.
The JS also takes into account the viewport width, number, and size of images, so this CSS will need updating each time we change anything in the template or if we want to implement mobile previews, or just scale down the page in the browser window.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's a good point. It will be a tricky one to tackle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also nervous about handling Block specific overrides in this way.
Also, can I check this is definitely within the scope of this PR? If not then I'd recommend we split this out and handle separately in order to keep your PR super focused.
It's looking pretty good! I noticed that in the Contact templates there are still some style issues (first, second, and fifth) and the Menu template is pretty broken. Could you rebase with master so the preview icons are back to being square etc? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doing a first pass of this to try and get my head into it. As I did this I noticed some minor issues we could address together.
...editing-plugin/starter-page-templates/page-template-modal/components/block-iframe-preview.js
Outdated
Show resolved
Hide resolved
...editing-plugin/starter-page-templates/page-template-modal/components/block-iframe-preview.js
Outdated
Show resolved
Hide resolved
...editing-plugin/starter-page-templates/page-template-modal/components/block-iframe-preview.js
Outdated
Show resolved
Hide resolved
...editing-plugin/starter-page-templates/page-template-modal/components/block-iframe-preview.js
Outdated
Show resolved
Hide resolved
...editing-plugin/starter-page-templates/page-template-modal/components/block-iframe-preview.js
Outdated
Show resolved
Hide resolved
@@ -291,8 +281,7 @@ body.admin-bar:not( .is-fullscreen-mode ) .page-template-modal-screen-overlay { | |||
right: $preview-right-margin; | |||
background: $template-selector-empty-background; | |||
border-radius: 2px; | |||
overflow-x: hidden; | |||
overflow-y: auto; | |||
overflow: hidden; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why this changed to a single value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, it's not needed I think. Let me check it. Nice 👁
...-plugin/starter-page-templates/page-template-modal/styles/starter-page-templates-editor.scss
Show resolved
Hide resolved
} | ||
|
||
// coblocks/gallery mock | ||
.coblocks-gallery { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also nervous about handling Block specific overrides in this way.
Also, can I check this is definitely within the scope of this PR? If not then I'd recommend we split this out and handle separately in order to keep your PR super focused.
...editing-plugin/starter-page-templates/page-template-modal/components/block-iframe-preview.js
Outdated
Show resolved
Hide resolved
...editing-plugin/starter-page-templates/page-template-modal/components/block-iframe-preview.js
Outdated
Show resolved
Hide resolved
I'm concerned that this PR touches so many files that it could introduce regressions. For example I'm seeing the Contact Forms "placeholder" state showing up again in previews. Just a note of caution as I know we're keen to land this one. |
ac40e9b
to
03e9464
Compare
Caution: This PR has changes that must be merged to WordPress.com |
This PR performs a refactoring in the templates previewing process, among other important changes. About the previewing, it moves the rendered blocks into an iFrame in order to apply CSS queries properly into the preview viewport. Other changes: remove the template title component and adding it as a template block for the preview, reduce CSS, etc.
03e9464
to
6a26bb5
Compare
retrofox, Your synced wpcom patch D39555-code has been updated. |
retrofox, Your synced wpcom patch D39555-code has been updated. |
retrofox, Your synced wpcom patch D39555-code has been updated. |
retrofox, Your synced wpcom patch D39555-code has been updated. |
Aside, and no need in this PR, but you can now include many of these variables directly from a Lines 14 to 38 in c034682
|
retrofox, Your synced wpcom patch D39555-code has been updated. |
retrofox, Your synced wpcom patch D39555-code has been updated. |
1 similar comment
retrofox, Your synced wpcom patch D39555-code has been updated. |
retrofox, Your synced wpcom patch D39555-code has been updated. |
retrofox, Your synced wpcom patch D39555-code has been updated. |
retrofox, Your synced wpcom patch D39555-code has been updated. |
retrofox, Your synced wpcom patch D39555-code has been updated. |
The component’s new behaviour means that the BlockPreview contents are moved into the iframe on render. This means the test cannot find it. Therefore we switch to assert on the prescence of the iframe.
retrofox, Your synced wpcom patch D39555-code has been updated. |
1 similar comment
retrofox, Your synced wpcom patch D39555-code has been updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice job @retrofox! Thank you for your help @jeryj @getdave @frontdevde
Another enhancement idea would be to avoid those flickering images when we load into the preview. I think we could solve this by:
|
Among these changes, we should figure out how to reduce the images sizes |
Changes proposed in this Pull Request
This PR injects starter page template blocks into an
iframe
in order to more accurately preview what the templates look like.A user wants the starter page template previews to match what they will see when they apply the template selection and are moved into the editor.
Related issues:
Fixes #39341.
Fixes #38779.
Related #39348, #39352, #39355.
Dev Setup For Testing
See existing documentation for setting up FSE plugin development. In addition, you will need these plugins active on your local environment, likely via a mounted volume:
apps/full-site-editing
directory in calypso:Testing instructions
Once the env dev is set up:
WIP...
TODO
We need to test each starter template to see if the preview matches the editor view. (select the template, then apply the layout by selecting the top right "Use ___ Layout" button). If one of them is broken, please document:
master
or not.Template Sections to Check
Other
master
core/cover
block previewing