-
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
Sidebar: use the "preview" layoutFocus to preview the current site #5117
Conversation
90890c0
to
d48b89a
Compare
Rebased against parent branch's rebase. |
814c4a4
to
38d373e
Compare
0296023
to
8bbbe87
Compare
Still works fine after rebase. |
a5a6d99
to
aad9d11
Compare
Rebased against master :) |
Noting here that, due to the way the backend generates the preview, we're not necessarily showing the user the same view that they would otherwise see via the actual frontend. For instance, private posts aren't shown: I added a tentative task in this PR's TODO, which you should feel free to slate for later. |
Added an external link icon in 4fd9547 |
Navigating in the preview doesn't work because of https://github.com/Automattic/wp-calypso/blob/master/client/my-sites/design-preview/index.js#L132 I wonder if this is something we can implement fairly easily. |
Sounds fairly doable. |
if ( ! state.preview || ! state.preview[ selectedSiteId ] ) { | ||
return { selectedSiteId }; | ||
} | ||
const { previewMarkup, customizations, isUnsaved } = state.preview[ selectedSiteId ]; | ||
return { | ||
selectedSite, |
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.
You'll probably also want to return selectedSite
in the early return a few lines up.
9332f55
to
411661d
Compare
@sirbrillig: while trying to fix the occurrence of blank previews, I noticed the implementation of Please let me know if it makes sense or if I missed a detail. |
@mcsf: oh, thank you. That's something I was mentally trying to get at but it never quite happened. That should help prevent flickering when the preview hasn't changed. |
c1b5608
to
8807ca1
Compare
I briefly spoke with @lsinger in Slack about what it would look like to load the
Most of those aren't insurmountable, but they do require some planning. Number 4 is perhaps the most troubling to me because I'm not sure how to "fix" it, although hiding the masterbar sure would help. |
Note that this is already available: It's used by the Theme Showcase's preview and the iOS/Android apps afaik. |
AFAIK that only works for the initial view, so any links clicked within the iframe will show the masterbar. |
I guess we could load something like a more robust version of the following server side, to get around the masterbar issue at least: (function(){
window.onload = function() {
var anchors = document.getElementsByTagName( 'a' );
for (var i = 0; i < anchors.length; i++) {
anchors[i].href = anchors[i].href + '?iframe=true&theme_preview=true';
}
}
})(); |
), delay ); | ||
}; | ||
|
||
export default wait; |
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 put this little guy inside the Guided Tours directory as a quick fix, but where do you guys think it really belongs?
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.
lodash? ¯_(ツ)_/¯
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.
Should be fine here for now. We can always move it into lib
when it's more mature.
a4259cb
to
e441666
Compare
a2ea2aa
to
6b141fc
Compare
|
@@ -151,7 +152,9 @@ module.exports = React.createClass( { | |||
homeLink={ true } | |||
enableActions={ true } | |||
externalLink={ true } | |||
onSelect={ this.trackHomepageClick } | |||
onClick={ this.previewSite } | |||
onSelect={ this.previewSite } |
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.
Do we want onSelect
here?
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.
AFAICT onSelect
translates into the onTouchTap
event? I'd assume we want that.
86acbe9
to
f866eb4
Compare
Squished. |
@@ -104,8 +104,9 @@ module.exports = React.createClass( { | |||
); | |||
}, | |||
|
|||
trackHomepageClick: function() { | |||
previewSite: function( event ) { | |||
analytics.ga.recordEvent( 'Sidebar', 'Clicked View Site' ); |
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.
Clicked View Site
=> Clicked Preview Site
?
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.
This event predates this PR, so we don't want to change it.
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, right, it's an actual event name—I'd assumed it was just a string representation for easier reading. Yes, in that light it makes total sense to keep!
The tooltip for the site card is |
Generally, this works for and looks good to me. From time to time the preview takes a bit long to load--but I don't think that's something we could make work better. The "background image for Dyad theme only shows when browser is forced to repaint through scrolling" is still happening for me, but it seems isolated to my machine. Would be thankful if someone else could try to reproduce:
|
Changed this and the aria text in 24d46a5c5240df0e405da19f843053945c930961 — also, made sure we're not trying to open a preview when |
👍 GOOD call, that one. |
Works properly for me! It seems the theme works a bit strange when updating it through Customizer, because if you have featured content and a header image, the one or other are not properly "switched" until a full refresh after saving and publishing the changes. Code looks good to me! 👍 A few things I noticed while testing:
|
Thanks @bisko :)
Interesting, that's Trampoline, and that shouldn't be happening. |
24d46a5
to
3ac7bd5
Compare
Uses the
preview
layoutFocus to preview the current site when clicking it in the sidebar:To test:
DISABLE_FEATURES=preview-layout make run
— check behaviour is the same asmaster