Skip to content

Commit

Permalink
Improve AMP preview button in WP 5.4 and with Gutenberg
Browse files Browse the repository at this point in the history
Use <Button> instead of the now deprecated <IconButton>:
WordPress/gutenberg#19299
The styling here isn't ideal,
but it's the best compromise of all of the scenarios
that I could come up with.
  • Loading branch information
kienstra committed Mar 16, 2020
1 parent 1fb04a7 commit 2e70671
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
10 changes: 6 additions & 4 deletions assets/css/src/amp-block-editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@
/* AMP preview button wrapper */
.wp-core-ui #amp-wrapper-post-preview {
margin-left: -6px;
margin-right: 6px;
}

/* AMP preview button */
.wp-core-ui .amp-editor-post-preview {
height: 34px;
padding-left: 6px;
padding-right: 6px;
padding: 6px 12px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
justify-content: center;
align-items: center;
}

.wp-core-ui .amp-editor-post-preview svg {
width: 15px;
height: 15px;
width: 18px;
height: 18px;
margin: 0;
}

Expand Down
11 changes: 5 additions & 6 deletions assets/src/block-editor/components/amp-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
* WordPress dependencies
*/
import { Component, createRef, renderToString } from '@wordpress/element';
import { Icon, IconButton } from '@wordpress/components';
import { Button, Icon } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { withSelect, withDispatch } from '@wordpress/data';
import { DotTip } from '@wordpress/nux';
Expand Down Expand Up @@ -237,17 +237,16 @@ class AMPPreview extends Component {

return (
isEnabled && ! errorMessages.length && ! isStandardMode && (
<IconButton
icon={ ampFilledIcon( { viewBox: '0 0 62 62' } ) }
isLarge
<Button
className="amp-editor-post-preview"
href={ href }
label={ __( 'Preview AMP', 'amp' ) }
target={ this.getWindowTarget() }
isSecondary
disabled={ ! isSaveable }
onClick={ this.openPreviewWindow }
ref={ this.buttonRef }
>
{ ampFilledIcon( { viewBox: '0 0 62 62', width: 18, height: 18 } ) }
<span className="screen-reader-text">
{
/* translators: accessibility text */
Expand All @@ -257,7 +256,7 @@ class AMPPreview extends Component {
<DotTip tipId="amp/editor.preview">
{ __( 'Click “Preview” to load a preview of this page in AMP, so you can make sure you are happy with your blocks.', 'amp' ) }
</DotTip>
</IconButton>
</Button>
)
);
}
Expand Down

0 comments on commit 2e70671

Please sign in to comment.