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

Reorganize the site editor to introduce Browse Mode. #44770

Merged
merged 84 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
2090043
Bootstrap the new admin navigation screen (start with the site editor)
youknowriad Sep 15, 2022
16b18f8
Fix unit tests
youknowriad Oct 14, 2022
82d3778
Tweak the sidebar animation
youknowriad Oct 14, 2022
c72f552
Fix toggle button height
youknowriad Oct 14, 2022
7b43bc2
Improve the animation
youknowriad Oct 14, 2022
525ce71
Add save button to the canvas header
youknowriad Oct 17, 2022
6ae91c8
Fix e2e tests
youknowriad Oct 17, 2022
11ba051
Auto switch to edit mode when clicking templates or template parts
youknowriad Oct 17, 2022
87df95d
Adjust menu spacing and animation vfx
jameskoster Oct 17, 2022
c08add2
Small style refactoring
youknowriad Oct 18, 2022
d6983d3
Add the currently edited template title to the view mode header
youknowriad Oct 18, 2022
1d81206
Add a home button
youknowriad Oct 18, 2022
2269126
a11y improvements
youknowriad Oct 20, 2022
54b547f
Fix more e2e tests
youknowriad Oct 21, 2022
c5cf7d9
Fix performance tests
youknowriad Oct 21, 2022
b5cae0e
more e2e test fixes
youknowriad Oct 21, 2022
5dcaea3
smoother animation
youknowriad Oct 21, 2022
096b23b
Fix the site editor toggle
youknowriad Oct 25, 2022
62328a6
Remove duplicated doc
youknowriad Oct 25, 2022
86914ed
Fix the site editor on mobile
youknowriad Oct 26, 2022
ab14e6f
Remove the editor menu item
youknowriad Oct 26, 2022
c070c55
Fix header padding
youknowriad Oct 26, 2022
0e139af
Selecting a template doesn't move into edit mode right away
youknowriad Oct 26, 2022
7331a5e
Redesign the sidebar title
youknowriad Oct 26, 2022
1e1b378
Remove home and save buttons
youknowriad Oct 26, 2022
ce5f07f
Scale down the frame content
youknowriad Oct 27, 2022
138bb5b
Better spacing and colors for the menu items
youknowriad Oct 27, 2022
da7fd8d
Tweak the sidebar width
youknowriad Oct 28, 2022
0a04fe4
Remove home page template setting
youknowriad Oct 28, 2022
b964e7c
Move the edit button outside of the canvas
youknowriad Oct 31, 2022
fd12005
only apply radius in view mode
youknowriad Oct 31, 2022
1505ab7
Fix sidebar alignment
youknowriad Oct 31, 2022
dd9a0f6
Remove the background and fix radius
youknowriad Oct 31, 2022
adbdafc
Update spacing
jameskoster Nov 1, 2022
eddd2b5
Increase frame border radius
jameskoster Nov 1, 2022
3cd8109
Remove iframe background and add elevation
jameskoster Nov 1, 2022
b2e08f7
Fix list header appearance
jameskoster Nov 2, 2022
b2aff8a
Use -size for nav margin
jameskoster Nov 2, 2022
5594734
Consistent canvas style
youknowriad Nov 7, 2022
133bdde
Remove back button
youknowriad Nov 7, 2022
06d7833
Fix template parts in view mode
youknowriad Nov 7, 2022
63a4180
Reshuffle the structure to animate the header from the top
youknowriad Nov 10, 2022
cd51ae8
Keep the sidebar visible while animating the canvas
youknowriad Nov 10, 2022
913322f
Scaling the whole canvas
youknowriad Nov 10, 2022
64a75b7
Remove useless code
youknowriad Nov 11, 2022
e78bd97
Remove the sidebar animation
youknowriad Nov 11, 2022
9b437e1
Restore the sidebar animation
youknowriad Nov 11, 2022
d01e26a
Fix text color
youknowriad Nov 11, 2022
1a0f80e
Animate the iframe
youknowriad Nov 11, 2022
68fd4af
Move the edit button to the sidebar
youknowriad Nov 14, 2022
e954612
Fix mobile
youknowriad Nov 14, 2022
a4fbe48
Improve the canvas animation
youknowriad Nov 15, 2022
0b36c3c
Remove scaling and simplify animation
youknowriad Nov 15, 2022
258622b
Tweak animation easing and frame shadow.
mtias Nov 15, 2022
4b312eb
Hide the sidebar behind the canvas
youknowriad Nov 16, 2022
8d7e1d5
Improve the animation
youknowriad Nov 16, 2022
72f74fc
Restore the sidebar padding
youknowriad Nov 16, 2022
c228eb6
Rebase cleanup
youknowriad Nov 16, 2022
0263436
Update shadow on the frame.
mtias Nov 16, 2022
7b92eb8
Fix inserter height
youknowriad Nov 16, 2022
3aaad16
Improve the animation of the edit button
youknowriad Nov 16, 2022
e8918cd
Move the edit button next to design
youknowriad Nov 17, 2022
940250e
Fix e2e tests
youknowriad Nov 17, 2022
ae2c7d0
fix more e2e tests
youknowriad Nov 17, 2022
82af6ca
Restore aria region
youknowriad Nov 17, 2022
fb76172
Fix the padding of the template list
youknowriad Nov 17, 2022
3efae5a
Hide edit button in template list
youknowriad Nov 17, 2022
39b86fd
Remove link from the site title
youknowriad Nov 17, 2022
16de8a2
Fix post rebase
youknowriad Nov 17, 2022
d5bc732
Quit zoom-out when switching to view mode
youknowriad Nov 21, 2022
96e43b3
Switch to edit mode when creating templates
youknowriad Nov 21, 2022
7f91013
Remove useless condition
youknowriad Nov 21, 2022
c27764a
Code simplification
youknowriad Nov 21, 2022
d54f42b
Hide publish flow in view mode
youknowriad Nov 21, 2022
5676e75
Fix layout shift
youknowriad Nov 21, 2022
ecfc594
Remove useless showDropdown
youknowriad Nov 21, 2022
04f8d7e
Remove useless prop
youknowriad Nov 21, 2022
d53a47f
Split site icon and title component
youknowriad Nov 21, 2022
732cea6
Fix showIconLabels behavior
youknowriad Nov 24, 2022
ad0ff98
Restore the onError prop
youknowriad Nov 24, 2022
acb368f
Fix code editor position
youknowriad Nov 24, 2022
3191104
Catch the error in setTemplate
youknowriad Nov 24, 2022
d5dcbc7
Remove list view styling changes
youknowriad Nov 24, 2022
a8683bd
Allow scrolling in view mode
youknowriad Nov 30, 2022
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
49 changes: 9 additions & 40 deletions docs/reference-guides/data/data-core-edit-site.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,7 @@ _Returns_

### getCurrentTemplateNavigationPanelSubMenu

Returns the current template or template part's corresponding
navigation panel's sub menu, to be used with `openNavigationPanelToMenu`.

_Parameters_

- _state_ `Object`: Global application state.

_Returns_

- `string`: The current template or template part's sub menu.
> **Deprecated**

### getCurrentTemplateTemplateParts

Expand Down Expand Up @@ -93,15 +84,7 @@ _Returns_

### getNavigationPanelActiveMenu

Returns the active menu in the navigation panel.

_Parameters_

- _state_ `Object`: Global application state.

_Returns_

- `string`: Active menu.
> **Deprecated**

### getPage

Expand Down Expand Up @@ -179,15 +162,7 @@ _Returns_

### isNavigationOpened

Returns the current opened/closed state of the navigation panel.

_Parameters_

- _state_ `Object`: Global application state.

_Returns_

- `boolean`: True if the navigation panel should be open; false if closed.
> **Deprecated**

### isSaveViewOpened

Expand Down Expand Up @@ -233,11 +208,9 @@ _Parameters_

### openNavigationPanelToMenu

Opens the navigation panel and sets its active menu at the same time.

_Parameters_
> **Deprecated**

- _menu_ `string`: Identifies the menu to open.
Opens the navigation panel and sets its active menu at the same time.

### removeTemplate

Expand Down Expand Up @@ -290,11 +263,9 @@ _Parameters_

### setIsNavigationPanelOpened

Sets whether the navigation panel should be open.

_Parameters_
> **Deprecated**

- _isOpen_ `boolean`: If true, opens the nav panel. If false, closes it. It does not toggle the state, but sets it directly.
Sets whether the navigation panel should be open.

### setIsSaveViewOpened

Expand All @@ -306,11 +277,9 @@ _Parameters_

### setNavigationPanelActiveMenu

Action that sets the active navigation panel menu.

_Parameters_
> **Deprecated**

- _menu_ `string`: Menu prop of active menu.
Action that sets the active navigation panel menu.

_Returns_

Expand Down
20 changes: 0 additions & 20 deletions lib/compat/wordpress-6.0/site-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,3 @@ function gutenberg_site_editor_maybe_redirect() {
}
}
add_action( 'load-site-editor.php', 'gutenberg_site_editor_maybe_redirect' );

/**
* Add home template settings for WP 5.9.
*
* @param array $settings Existing block editor settings.
* @param WP_Block_Editor_Context $context The current block editor context.
* @return array
*/
function gutenberg_site_editor_homepage_setting( $settings, $context ) {
if ( isset( $context->post ) ) {
return $settings;
}

if ( ! isset( $settings['__unstableHomeTemplate'] ) ) {
$settings['__unstableHomeTemplate'] = gutenberg_resolve_home_template();
}

return $settings;
}
add_filter( 'block_editor_settings_all', 'gutenberg_site_editor_homepage_setting', 10, 2 );
9 changes: 0 additions & 9 deletions lib/compat/wordpress-6.1/template-parts-screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,8 @@ static function( $classes ) {
'defaultTemplatePartAreas' => get_allowed_block_template_part_areas(),
'supportsLayout' => wp_theme_has_theme_json(),
'supportsTemplatePartsMode' => ! wp_is_block_theme() && current_theme_supports( 'block-template-parts' ),
'__unstableHomeTemplate' => gutenberg_resolve_home_template(),
);

/**
* We don't need home template resolution when block template parts are supported.
* Set the value to true to satisfy the editor initialization guard clause.
*/
if ( $custom_settings['supportsTemplatePartsMode'] ) {
$custom_settings['__unstableHomeTemplate'] = true;
}

// Add additional back-compat patterns registered by `current_screen` et al.
$custom_settings['__experimentalAdditionalBlockPatterns'] = WP_Block_Patterns_Registry::get_instance()->get_all_registered( true );
$custom_settings['__experimentalAdditionalBlockPatternCategories'] = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered( true );
Expand Down
24 changes: 24 additions & 0 deletions lib/compat/wordpress-6.2/site-editor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Updates the site-editor.php file
*
* @package gutenberg
*/

/**
* Remove home template setting for WP 6.2.
*
* @param array $settings Existing block editor settings.
* @param WP_Block_Editor_Context $context The current block editor context.
* @return array
*/
function gutenberg_site_editor_unset_homepage_setting( $settings, $context ) {
if ( isset( $context->post ) ) {
return $settings;
}

unset( $settings['__unstableHomeTemplate'] );
youknowriad marked this conversation as resolved.
Show resolved Hide resolved

return $settings;
}
add_filter( 'block_editor_settings_all', 'gutenberg_site_editor_unset_homepage_setting', 10, 2 );
1 change: 1 addition & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/compat/wordpress-6.2/class-wp-theme-json-resolver-6-2.php';
require __DIR__ . '/compat/wordpress-6.2/class-wp-theme-json-6-2.php';
require __DIR__ . '/compat/wordpress-6.2/edit-form-blocks.php';
require __DIR__ . '/compat/wordpress-6.2/site-editor.php';

// Experimental features.
remove_action( 'plugins_loaded', '_wp_theme_json_webfonts_handler' ); // Turns off WP 6.0's stopgap handler for Webfonts API.
Expand Down
1 change: 1 addition & 0 deletions packages/base-styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ $admin-sidebar-width-big: 190px;
$admin-sidebar-width-collapsed: 36px;
$modal-min-width: 360px;
$spinner-size: 16px;
$canvas-padding: $grid-unit-30;


/**
Expand Down
8 changes: 0 additions & 8 deletions packages/base-styles/_z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,6 @@ $z-layers: (
// Show interface skeleton footer above interface skeleton drawer
".interface-interface-skeleton__footer": 90,

// Show the navigation toggle above the skeleton header
".edit-site-navigation-toggle": 31,
// Show the navigation link above the skeleton header
".edit-site-navigation-link": 31,

// Show the FSE template previews above the editor and any open block toolbars
".edit-site-navigation-panel__preview": 32,

// Above the block list and the header.
".block-editor-block-popover": 31,

Expand Down
14 changes: 0 additions & 14 deletions packages/block-editor/src/components/block-list/content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -434,18 +434,4 @@
.block-editor-iframe__body {
transition: all 0.3s;
transform-origin: top center;

&.is-zoomed-out {
margin: 100px 0;
transform: scale(0.45);

// Add a bit more space between the top level blocks.
.wp-site-blocks > * + * {
margin-block-start: 2.5rem;
}

> .block-list-appender {
display: none;
}
}
}
43 changes: 25 additions & 18 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,17 @@ async function loadScript( head, { id, src } ) {
}

function Iframe(
{ contentRef, children, head, tabIndex = 0, assets, isZoomedOut, ...props },
{
contentRef,
children,
head,
tabIndex = 0,
assets,
scale = 1,
frameSize = 0,
readonly,
...props
},
ref
) {
const [ , forceRender ] = useReducer( () => ( {} ) );
Expand Down Expand Up @@ -322,7 +332,7 @@ function Iframe(
{ head }
<style>
{ `html { transition: background 5s; ${
isZoomedOut
frameSize
? 'background: #2f2f2f; transition: background 0s;'
: ''
} }` }
Expand All @@ -333,23 +343,20 @@ function Iframe(
className={ classnames(
'block-editor-iframe__body',
BODY_CLASS_NAME,
...bodyClasses,
{
'is-zoomed-out': isZoomedOut,
}
...bodyClasses
) }
style={
isZoomedOut
? {
// This is the remaining percentage from the scaling down
// of the iframe body(`scale(0.45)`). We also need to subtract
// the body's bottom margin.
marginBottom: `-${
contentHeight * 0.55 - 100
}px`,
}
: {}
}
style={ {
// This is the remaining percentage from the scaling down
// of the iframe body(`scale(0.45)`). We also need to subtract
// the body's bottom margin.
marginBottom: `-${
contentHeight * ( 1 - scale ) -
frameSize
}px`,
marginTop: frameSize,
transform: `scale( ${ scale } )`,
} }
inert={ readonly ? 'true' : undefined }
>
{ contentResizeListener }
{ /*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
height: auto;
padding: ($grid-unit-15 * 0.5) $grid-unit-05 ($grid-unit-15 * 0.5) 0;
text-align: left;
color: $gray-900;
border-radius: $radius-block-ui;
position: relative;
white-space: nowrap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,9 @@
outline: 4px solid $components-color-accent;
outline-offset: -4px;
}

// Edit site Navigation Drawer.
.interface-interface-skeleton__drawer {
z-index: z-index(".edit-site-navigation-toggle");

.interface-navigable-region__stacker,
.edit-site-navigation-toggle {
outline: inherit;
outline-offset: inherit;
}

.edit-site-navigation-toggle.is-open {
outline: none;
}

.edit-site-navigation-toggle__button {
z-index: -1;
}
}
}

// Fixes for edge cases.
// Edit site Drawer.
.interface-interface-skeleton__drawer .interface-navigable-region__stacker {
.interface-navigable-region__stacker {
height: 100%;
width: 100%;
}
2 changes: 1 addition & 1 deletion packages/components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export {
default as Animate,
getAnimateClassName as __unstableGetAnimateClassName,
} from './animate';
export { __unstableMotion } from './animation';
export { __unstableMotion, __unstableAnimatePresence } from './animation';
export { default as AnglePickerControl } from './angle-picker-control';
export {
default as Autocomplete,
Expand Down
1 change: 1 addition & 0 deletions packages/e2e-test-utils-playwright/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export { Admin } from './admin';
export { Editor } from './editor';
export { PageUtils } from './page-utils';
export { RequestUtils } from './request-utils';
export { SiteEditor } from './site-editor';
export { test, expect } from './test';
23 changes: 23 additions & 0 deletions packages/e2e-test-utils-playwright/src/site-editor/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* External dependencies
*/
import type { Page } from '@playwright/test';

/**
* Internal dependencies
*/
import { enterEditMode } from './toggle-canvas-mode';

type AdminConstructorProps = {
page: Page;
};

export class SiteEditor {
page: Page;

constructor( { page }: AdminConstructorProps ) {
this.page = page;
}

enterEditMode = enterEditMode.bind( this );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Enters the site editor edit mode.
*
* @this {import('.').SiteEditor}
*/
export async function enterEditMode() {
await this.page.click( '.edit-site-layout__edit-button' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally don't think it's necessary to add a new SiteEditor class and util for just one line of code. Though I realise you may be intending to add more utils to the class.

It'd also be good to favor role selectors this.page.click( 'role=button[name="Open the editor"i]' ); or I think there's a getByRole function, but I don't know the function signature without looking it up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to follow what we did for the current utils but I'm happy to adjust if necessary. Where would you put this utility if it's not in a new SiteEditor class?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could go in the Editor class if you don't like the idea of inlining it. Maybe with a method name or docs that make it clear it's for the site editor only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the idea of inlining because it's a very common utility in the site editor.

Actually, thinking more, I think personally I like it better as it is. I can see us adding utilities to navigate between sidebar items in the site editor as we expand them. (going to templates, template parts, styles, navigation)

}
6 changes: 5 additions & 1 deletion packages/e2e-test-utils-playwright/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { ConsoleMessage } from '@playwright/test';
/**
* Internal dependencies
*/
import { Admin, Editor, PageUtils, RequestUtils } from './index';
import { Admin, Editor, PageUtils, RequestUtils, SiteEditor } from './index';

const STORAGE_STATE_PATH =
process.env.STORAGE_STATE_PATH ||
Expand Down Expand Up @@ -102,6 +102,7 @@ const test = base.extend<
editor: Editor;
pageUtils: PageUtils;
snapshotConfig: void;
siteEditor: SiteEditor;
},
{
requestUtils: RequestUtils;
Expand All @@ -113,6 +114,9 @@ const test = base.extend<
editor: async ( { page }, use ) => {
await use( new Editor( { page } ) );
},
siteEditor: async ( { page }, use ) => {
await use( new SiteEditor( { page } ) );
},
page: async ( { page }, use ) => {
page.on( 'console', observeConsoleLogging );

Expand Down
Loading