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

Revert "Fullscreen Mode: Change the "Back" button to toggle the sidebar (#21121)" #21929

Merged
merged 1 commit into from
Apr 27, 2020
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
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@ describe( 'Fullscreen Mode', () => {
} );

expect( isFullscreenEnabled ).toBe( true );

const fullscreenCloseButton = await page.$(
'.edit-post-fullscreen-mode-close'
);

expect( fullscreenCloseButton ).not.toBeNull();
} );
} );
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* External dependencies
*/
import { get } from 'lodash';

/**
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { Button } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { addQueryArgs } from '@wordpress/url';
import { wordpress } from '@wordpress/icons';

function FullscreenModeClose() {
const { isActive, postType } = useSelect( ( select ) => {
const { getCurrentPostType } = select( 'core/editor' );
const { isFeatureActive } = select( 'core/edit-post' );
const { getPostType } = select( 'core' );

return {
isActive: isFeatureActive( 'fullscreenMode' ),
postType: getPostType( getCurrentPostType() ),
};
}, [] );

if ( ! isActive || ! postType ) {
return null;
}

return (
<Button
className="edit-post-fullscreen-mode-close"
icon={ wordpress }
iconSize={ 36 }
href={ addQueryArgs( 'edit.php', {
post_type: postType.slug,
} ) }
label={ get( postType, [ 'labels', 'view_items' ], __( 'Back' ) ) }
/>
);
}

export default FullscreenModeClose;
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.edit-post-fullscreen-mode-close.has-icon {
// Do not show the toolbar icon on small screens,
// when Fullscreen Mode is not an option in the "More" menu.
display: none;

@include break-medium() {
display: flex;
align-items: center;
align-self: stretch;
border: none;
background: #23282e; // WP-admin gray.
color: $white;
border-radius: 0;
height: auto;
width: $header-height;

&:hover {
background: #32373d; // WP-admin light-gray.
}

&:active {
color: $white;
}

&:focus {
box-shadow: inset 0 0 0 $border-width-focus $theme-color, inset 0 0 0 ($border-width-focus + 1px) $white;
}
}
}
9 changes: 3 additions & 6 deletions packages/edit-post/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { Button } from '@wordpress/components';
import { PostSavedState, PostPreviewButton } from '@wordpress/editor';
import { useSelect, useDispatch } from '@wordpress/data';
import { cog } from '@wordpress/icons';
import { PinnedItems, AdminMenuToggle } from '@wordpress/interface';
import { PinnedItems } from '@wordpress/interface';

/**
* Internal dependencies
*/
import FullscreenModeClose from './fullscreen-mode-close';
import HeaderToolbar from './header-toolbar';
import MoreMenu from './more-menu';
import PostPublishButtonOrToggle from './post-publish-button-or-toggle';
Expand All @@ -24,7 +25,6 @@ function Header( { onToggleInserter, isInserterOpen } ) {
isPublishSidebarOpened,
isSaving,
getBlockSelectionStart,
isFullscreenActive,
} = useSelect(
( select ) => ( {
shortcut: select(
Expand All @@ -41,9 +41,6 @@ function Header( { onToggleInserter, isInserterOpen } ) {
getBlockSelectionStart: select( 'core/block-editor' )
.getBlockSelectionStart,
isPostSaveable: select( 'core/editor' ).isEditedPostSaveable(),
isFullscreenActive: select( 'core/edit-post' ).isFeatureActive(
'fullscreenMode'
),
deviceType: select(
'core/edit-post'
).__experimentalGetPreviewDeviceType(),
Expand All @@ -65,7 +62,7 @@ function Header( { onToggleInserter, isInserterOpen } ) {

return (
<div className="edit-post-header">
{ isFullscreenActive && <AdminMenuToggle /> }
<FullscreenModeClose />
<div className="edit-post-header__toolbar">
<HeaderToolbar
onToggleInserter={ onToggleInserter }
Expand Down
1 change: 1 addition & 0 deletions packages/edit-post/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $footer-height: $button-size-small;
@import "../../interface/src/style.scss";

@import "./components/header/style.scss";
@import "./components/header/fullscreen-mode-close/style.scss";
@import "./components/header/header-toolbar/style.scss";
@import "./components/header/more-menu/style.scss";
@import "./components/keyboard-shortcut-help-modal/style.scss";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { Button } from '@wordpress/components';
import { Path, SVG } from '@wordpress/primitives';
import { __ } from '@wordpress/i18n';

const wordPressLogo = (
<SVG width="28" height="28" viewBox="0 0 128 128" version="1.1">
<Path d="M100 61.3c0-6.6-2.4-11.2-4.4-14.7-2.7-4.4-5.2-8.1-5.2-12.5 0-4.9 3.7-9.5 9-9.5h.7c-9.5-8.7-22.1-14-36-14-18.6 0-35 9.6-44.6 24 1.3 0 2.4.1 3.4.1 5.6 0 14.2-.7 14.2-.7 2.9-.2 3.2 4.1.3 4.4 0 0-2.9.3-6.1.5l19.4 57.8 11.7-35L54.1 39c-2.9-.2-5.6-.5-5.6-.5-2.9-.2-2.5-4.6.3-4.4 0 0 8.8.7 14 .7 5.6 0 14.2-.7 14.2-.7 2.9-.2 3.2 4.1.3 4.4 0 0-2.9.3-6.1.5l19.3 57.3L96 78.9c2.6-7.6 4-13 4-17.6zM10.7 64c0 21.1 12.3 39.4 30.1 48L15.3 42.3c-3 6.6-4.6 14-4.6 21.7zm54.2 4.7l-16 46.5c4.8 1.4 9.8 2.2 15.1 2.2 6.2 0 12.2-1.1 17.7-3-.1-.2-.3-.5-.4-.7l-16.4-45zM64 0C28.7 0 0 28.7 0 64s28.7 64 64 64 64-28.7 64-64S99.3 0 64 0zm49.9 97.6c-2.2 3.2-4.6 6.2-7.3 8.9s-5.7 5.2-8.9 7.3c-3.2 2.2-6.7 4-10.2 5.5-7.4 3.1-15.3 4.7-23.4 4.7s-16-1.6-23.4-4.7c-3.6-1.5-7-3.4-10.2-5.5-3.2-2.2-6.2-4.6-8.9-7.3s-5.2-5.7-7.3-8.9c-2.2-3.2-4-6.7-5.5-10.2-3.4-7.4-5-15.3-5-23.4s1.6-16 4.7-23.4c1.5-3.6 3.4-7 5.5-10.2 2.2-3.2 4.6-6.2 7.3-8.9s5.7-5.2 8.9-7.3c3.2-2.2 6.7-4 10.2-5.5C48 5.4 55.9 3.8 64 3.8s16 1.6 23.4 4.7c3.6 1.5 7 3.4 10.2 5.5 3.2 2.2 6.2 4.6 8.9 7.3s5.2 5.7 7.3 8.9c2.2 3.2 4 6.7 5.5 10.2 3.1 7.4 4.7 15.3 4.7 23.4s-1.6 16-4.7 23.4c-1.4 3.8-3.2 7.2-5.4 10.4zm-2.7-53.7c0 5.4-1 11.5-4.1 19.1l-16.3 47.1c15.9-9.2 26.5-26.4 26.5-46.1 0-9.3-2.4-18-6.5-25.6.2 1.7.4 3.5.4 5.5z" />
</SVG>
);

function FullscreenModeClose() {
const isActive = useSelect( ( select ) => {
return select( 'core/edit-site' ).isFeatureActive( 'fullscreenMode' );
}, [] );

if ( ! isActive ) {
return null;
}

return (
<Button
className="edit-site-fullscreen-mode-close"
icon={ wordPressLogo }
iconSize={ 36 }
href="index.php"
label={ __( 'Back' ) }
/>
);
}

export default FullscreenModeClose;
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.edit-site-fullscreen-mode-close.has-icon {
// Do not show the toolbar icon on small screens,
// when Fullscreen Mode is not an option in the "More" menu.
display: none;

@include break-medium() {
display: flex;
align-items: center;
align-self: stretch;
border: none;
background: #23282e; // WP-admin gray.
color: $white;
border-radius: 0;
height: auto;
width: $header-height;

&:hover {
background: #32373d; // WP-admin light-gray.
}

&:active {
color: $white;
}

&:focus {
box-shadow: inset 0 0 0 $border-width-focus $theme-color, inset 0 0 0 3px $white;
}
}
}
14 changes: 3 additions & 11 deletions packages/edit-site/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import {
__experimentalPreviewOptions as PreviewOptions,
} from '@wordpress/block-editor';
import { useSelect, useDispatch } from '@wordpress/data';
import { PinnedItems, AdminMenuToggle } from '@wordpress/interface';
import { PinnedItems } from '@wordpress/interface';

/**
* Internal dependencies
*/
import { useEditorContext } from '../editor';
import FullscreenModeClose from './fullscreen-mode-close';
import MoreMenu from './more-menu';
import TemplateSwitcher from '../template-switcher';
import SaveButton from '../save-button';
Expand Down Expand Up @@ -51,15 +52,6 @@ export default function Header() {
[]
);

const { isFullscreenActive } = useSelect(
( select ) => ( {
isFullscreenActive: select( 'core/edit-site' ).isFeatureActive(
'fullscreenMode'
),
} ),
[]
);

const deviceType = useSelect( ( select ) => {
return select( 'core/edit-site' ).__experimentalGetPreviewDeviceType();
}, [] );
Expand All @@ -70,7 +62,7 @@ export default function Header() {

return (
<div className="edit-site-header">
{ isFullscreenActive && <AdminMenuToggle /> }
<FullscreenModeClose />
<div className="edit-site-header__toolbar">
<Inserter
position="bottom right"
Expand Down
1 change: 1 addition & 0 deletions packages/edit-site/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

@import "./components/block-editor/style.scss";
@import "./components/header/style.scss";
@import "./components/header/fullscreen-mode-close/style.scss";
@import "./components/header/more-menu/style.scss";
@import "./components/notices/style.scss";
@import "./components/sidebar/style.scss";
Expand Down
1 change: 0 additions & 1 deletion packages/interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"@wordpress/element": "file:../element",
"@wordpress/i18n": "file:../i18n",
"@wordpress/icons": "file:../icons",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/plugins": "file:../plugins",
"classnames": "^2.2.5",
"lodash": "^4.17.15"
Expand Down
105 changes: 0 additions & 105 deletions packages/interface/src/components/admin-menu-toggle/index.js

This file was deleted.

Loading