Skip to content

Commit ab65349

Browse files
authored
Merge pull request #4397 from ampproject/fix/amp-button-placement
Improve AMP preview button in WP 5.4 and with Gutenberg
2 parents ff8e61c + e3b8ea2 commit ab65349

File tree

7 files changed

+27
-189
lines changed

7 files changed

+27
-189
lines changed

assets/css/src/amp-block-editor.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@
66
/* AMP preview button wrapper */
77
.wp-core-ui #amp-wrapper-post-preview {
88
margin-left: -6px;
9+
margin-right: 6px;
910
}
1011

1112
/* AMP preview button */
1213
.wp-core-ui .amp-editor-post-preview {
1314
height: 34px;
14-
padding-left: 6px;
15-
padding-right: 6px;
15+
padding: 6px 12px;
1616
border-top-left-radius: 0;
1717
border-bottom-left-radius: 0;
18+
justify-content: center;
19+
align-items: center;
1820
}
1921

2022
.wp-core-ui .amp-editor-post-preview svg {
21-
width: 15px;
22-
height: 15px;
23+
width: 18px;
24+
height: 18px;
2325
margin: 0;
2426
}
2527

assets/images/amp-icon.svg

Lines changed: 0 additions & 1 deletion
Loading

assets/images/amp-white-icon.svg

Lines changed: 1 addition & 2 deletions
Loading

assets/src/block-editor/components/amp-preview.js

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import PropTypes from 'prop-types';
88
* WordPress dependencies
99
*/
1010
import { Component, createRef, renderToString } from '@wordpress/element';
11-
import { Icon, IconButton } from '@wordpress/components';
11+
import { Button, Icon, Tooltip } from '@wordpress/components';
1212
import { __ } from '@wordpress/i18n';
1313
import { withSelect, withDispatch } from '@wordpress/data';
14-
import { DotTip } from '@wordpress/nux';
1514
import { compose } from '@wordpress/compose';
1615
import { addQueryArgs } from '@wordpress/url';
1716

@@ -237,27 +236,25 @@ class AMPPreview extends Component {
237236

238237
return (
239238
isEnabled && ! errorMessages.length && ! isStandardMode && (
240-
<IconButton
241-
icon={ ampFilledIcon( { viewBox: '0 0 62 62' } ) }
242-
isLarge
243-
className="amp-editor-post-preview"
244-
href={ href }
245-
label={ __( 'Preview AMP', 'amp' ) }
246-
target={ this.getWindowTarget() }
247-
disabled={ ! isSaveable }
248-
onClick={ this.openPreviewWindow }
249-
ref={ this.buttonRef }
250-
>
251-
<span className="screen-reader-text">
252-
{
253-
/* translators: accessibility text */
254-
__( '(opens in a new tab)', 'amp' )
255-
}
256-
</span>
257-
<DotTip tipId="amp/editor.preview">
258-
{ __( 'Click “Preview” to load a preview of this page in AMP, so you can make sure you are happy with your blocks.', 'amp' ) }
259-
</DotTip>
260-
</IconButton>
239+
<Tooltip text={ __( 'Preview AMP', 'amp' ) } >
240+
<Button
241+
className="amp-editor-post-preview"
242+
href={ href }
243+
label={ __( 'Preview AMP', 'amp' ) }
244+
isSecondary
245+
disabled={ ! isSaveable }
246+
onClick={ this.openPreviewWindow }
247+
ref={ this.buttonRef }
248+
>
249+
{ ampFilledIcon( { viewBox: '0 0 62 62', width: 18, height: 18 } ) }
250+
<span className="screen-reader-text">
251+
{
252+
/* translators: accessibility text */
253+
__( '(opens in a new tab)', 'amp' )
254+
}
255+
</span>
256+
</Button>
257+
</Tooltip>
261258
)
262259
);
263260
}

package-lock.json

Lines changed: 0 additions & 157 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"@wordpress/hooks": "2.7.0",
4242
"@wordpress/i18n": "3.9.0",
4343
"@wordpress/jest-puppeteer-axe": "1.6.0",
44-
"@wordpress/nux": "3.12.3",
4544
"@wordpress/plugins": "2.12.0",
4645
"@wordpress/scripts": "5.1.0",
4746
"@wordpress/url": "2.9.0",

tests/php/test-class-amp-meta-box.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ public function test_enqueue_block_assets() {
143143
'wp-element',
144144
'wp-hooks',
145145
'wp-i18n',
146-
'wp-nux',
147146
'wp-plugins',
148147
'wp-polyfill',
149148
'wp-url',

0 commit comments

Comments
 (0)