Skip to content
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

Show Preview button on mobile viewports #16496

Merged
merged 1 commit into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions packages/edit-post/src/components/header/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@
}
}

.editor-post-switch-to-draft + .editor-post-preview {
display: none;

@include break-small {
display: inline-flex;
}
}

// Some browsers, most notably IE11, honor an older version of the flexbox spec
// which takes absolutely positioned items into account when calculating `space-between`.
// https://www.w3.org/TR/2012/WD-css3-flexbox-20120612/#abspos-flex-items
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PostSavedState returns a switch to draft link if the post is published 1`] = `<WithSelect(WithDispatch(PostSwitchToDraftButton)) />`;
exports[`PostSavedState returns a switch to draft link if the post is published 1`] = `<WithSelect(WithDispatch(WithViewportMatch(PostSwitchToDraftButton))) />`;

exports[`PostSavedState should return Save button if edits to be saved 1`] = `
<ForwardRef(Button)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ import { Button } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { withSelect, withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { withViewportMatch } from '@wordpress/viewport';

function PostSwitchToDraftButton( { isSaving, isPublished, isScheduled, onClick } ) {
function PostSwitchToDraftButton( {
isSaving,
isPublished,
isScheduled,
onClick,
isMobileViewport,
} ) {
if ( ! isPublished && ! isScheduled ) {
return null;
}
Expand All @@ -31,7 +38,7 @@ function PostSwitchToDraftButton( { isSaving, isPublished, isScheduled, onClick
disabled={ isSaving }
isTertiary
>
{ __( 'Switch to Draft' ) }
{ isMobileViewport ? __( 'Draft' ) : __( 'Switch to Draft' ) }
</Button>
);
}
Expand All @@ -54,5 +61,6 @@ export default compose( [
},
};
} ),
withViewportMatch( { isMobileViewport: '< small' } ),
] )( PostSwitchToDraftButton );