-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Preview popup loader #3157
Preview popup loader #3157
Changes from 3 commits
533da25
27b7f83
6a06fd4
1b37e12
51ef53d
69e07e3
52f6d22
76acdc5
739880a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import { connect } from 'react-redux'; | |
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Component } from '@wordpress/element'; | ||
import { Component, renderToString } from '@wordpress/element'; | ||
import { IconButton } from '@wordpress/components'; | ||
import { _x } from '@wordpress/i18n'; | ||
|
||
|
@@ -73,6 +73,16 @@ export class PreviewButton extends Component { | |
'about:blank', | ||
this.getWindowTarget() | ||
); | ||
|
||
const popupLoader = renderToString( | ||
<div> | ||
<p>Please wait…</p> | ||
<p>Generating preview.</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to translate this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #3301 |
||
</div> | ||
); | ||
const css = '<style type="text/css"> div { margin-top: 25%; } p { text-align: center; } </style>'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the intention that this be centered? Seems like flexbox might serve better, if so. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style |
||
this.previewWindow.document.write( css ); | ||
this.previewWindow.document.write( popupLoader ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docs for
https://developer.mozilla.org/en-US/docs/Web/API/Document/write#Notes |
||
} | ||
|
||
render() { | ||
|
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.
Honestly seems like we could get away with just creating a string of HTML instead of using React to convert an element to string, particularly if we're separately creating a style tag anyways (which could itself be represented as an element).
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.
Good shout - I was only doing this because I'd originally used the
<Spinner />
component. No longer necessary 🙂