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

Site Editor: add Fullscreen mode #20691

Merged
merged 7 commits into from
Mar 16, 2020
Merged

Conversation

vindl
Copy link
Member

@vindl vindl commented Mar 6, 2020

Description

A quick experiment that attempts to reuse existing FullscreenMode component in Site Editor. In order to achieve this I've moved this component to block-editor package so that it can be reused by edit-post and edit-site (as suggested by @youknowriad here).

Note: For now I didn't want to add UI for toggling (similar to post editor ellipsis menu) until the designs for the Site Editor are ready. We'd like to force the fullscreen mode on Site Editor in our integration, and this should be enough to achieve that.

How has this been tested?

I tested the exiting post editor to make sure that there are no regressions to existing functionality.

In case of Site Editor, since there is still no UI for this, you can toggle the Fullscreen mode by running wp.data.dispatch( 'core/edit-site' ).toggleFeature( 'fullscreenMode' ) in the console.

I also carried over the relevant featureToggle tests from edit-post package here.

npm test packages/edit-site/src/store/test/

Screenshots

Screenshot 2020-03-06 at 21 15 06

Types of changes

New feature (non-breaking change which adds functionality).

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@github-actions
Copy link

github-actions bot commented Mar 6, 2020

Size Change: -7.31 kB (0%)

Total Size: 857 kB

Filename Size Change
build/annotations/index.js 3.43 kB -2 B (0%)
build/block-directory/index.js 6.03 kB +6 B (0%)
build/block-editor/index.js 101 kB -3.9 kB (3%)
build/block-editor/style-rtl.css 10.9 kB +203 B (1%)
build/block-editor/style.css 10.9 kB +199 B (1%)
build/block-library/index.js 111 kB -4.59 kB (4%)
build/blocks/index.js 57.7 kB -2 B (0%)
build/components/index.js 191 kB -238 B (0%)
build/components/style-rtl.css 15.7 kB +217 B (1%)
build/components/style.css 15.7 kB +218 B (1%)
build/compose/index.js 6.22 kB +462 B (7%) 🔍
build/data-controls/index.js 1.04 kB +1 B
build/data/index.js 8.21 kB -7 B (0%)
build/date/index.js 5.37 kB +4 B (0%)
build/dom-ready/index.js 568 B -1 B
build/edit-post/index.js 91.3 kB -40 B (0%)
build/edit-post/style-rtl.css 8.52 kB -122 B (1%)
build/edit-post/style.css 8.51 kB -127 B (1%)
build/edit-site/index.js 5.07 kB +432 B (8%) 🔍
build/edit-widgets/index.js 4.44 kB -2 B (0%)
build/editor/index.js 43.8 kB -13 B (0%)
build/element/index.js 4.45 kB -1 B
build/escape-html/index.js 733 B -1 B
build/format-library/index.js 7.09 kB +4 B (0%)
build/html-entities/index.js 621 B -1 B
build/i18n/index.js 3.49 kB -1 B
build/list-reusable-blocks/index.js 2.99 kB -1 B
build/primitives/index.js 1.49 kB -1 B
build/priority-queue/index.js 779 B -1 B
build/redux-routine/index.js 2.84 kB +1 B
build/rich-text/index.js 14.3 kB -1 B
build/url/index.js 4.01 kB +1 B
build/warning/index.js 1.14 kB +1 B
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.01 kB 0 B
build/api-fetch/index.js 3.39 kB 0 B
build/autop/index.js 2.58 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/style-rtl.css 760 B 0 B
build/block-directory/style.css 760 B 0 B
build/block-library/editor-rtl.css 7.23 kB 0 B
build/block-library/editor.css 7.24 kB 0 B
build/block-library/style-rtl.css 7.38 kB 0 B
build/block-library/style.css 7.39 kB 0 B
build/block-library/theme-rtl.css 669 B 0 B
build/block-library/theme.css 671 B 0 B
build/block-serialization-default-parser/index.js 1.65 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/core-data/index.js 10.6 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom/index.js 3.06 kB 0 B
build/edit-site/style-rtl.css 2.48 kB 0 B
build/edit-site/style.css 2.48 kB 0 B
build/edit-widgets/style-rtl.css 2.58 kB 0 B
build/edit-widgets/style.css 2.58 kB 0 B
build/editor/editor-styles-rtl.css 381 B 0 B
build/editor/editor-styles.css 382 B 0 B
build/editor/style-rtl.css 3.97 kB 0 B
build/editor/style.css 3.96 kB 0 B
build/format-library/style-rtl.css 502 B 0 B
build/format-library/style.css 502 B 0 B
build/hooks/index.js 1.92 kB 0 B
build/is-shallow-equal/index.js 710 B 0 B
build/keyboard-shortcuts/index.js 2.3 kB 0 B
build/keycodes/index.js 1.68 kB 0 B
build/list-reusable-blocks/style-rtl.css 226 B 0 B
build/list-reusable-blocks/style.css 226 B 0 B
build/media-utils/index.js 4.85 kB 0 B
build/notices/index.js 1.57 kB 0 B
build/nux/index.js 3.01 kB 0 B
build/nux/style-rtl.css 616 B 0 B
build/nux/style.css 613 B 0 B
build/plugins/index.js 2.54 kB 0 B
build/server-side-render/index.js 2.55 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/viewport/index.js 1.61 kB 0 B
build/wordcount/index.js 1.18 kB 0 B

compressed-size-action

@@ -155,3 +155,4 @@ export { default as PluginPostStatusInfo } from './components/sidebar/plugin-pos
export { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';
export { default as PluginSidebar } from './components/sidebar/plugin-sidebar';
export { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';
export { default as FullscreenMode } from './components/fullscreen-mode';
Copy link
Contributor

Choose a reason for hiding this comment

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

We were talking about this recently in another PR. I believe we shouldn't export this from edit-post.
We were considering creating a @wordpress/admin-screen package for reusable stuff across WP Admin screens.
it can include "Page/EditorSkeleton", "FullscreenMode", Potentially sidebar plugins...

Copy link
Member Author

Choose a reason for hiding this comment

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

We were considering creating a @wordpress/admin-screen package for reusable stuff across WP Admin screens.

Cool, that definitely makes more sense and it was just the thing I was looking for. Is there an open issue/pr for it that I can track and update this when it's ready?

Copy link
Contributor

Choose a reason for hiding this comment

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

There's none. @jorgefilipecosta might be working on a PR and you can also add the package as part of this PR 🤷‍♂

Copy link
Member

Choose a reason for hiding this comment

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

We have a PR with admin screen available at #20698.

Copy link
Contributor

Choose a reason for hiding this comment

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

While we figure out the best naming... for this package, I think we can land this as an experimental component in block-editor for now (like the skeleton)

Copy link
Member Author

Choose a reason for hiding this comment

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

While we figure out the best naming... for this package, I think we can land this as an experimental component in block-editor for now (like the skeleton)

@youknowriad I moved this component to block-editor package as suggested. So far its activation state has been persisted in edit-post store. I factored that out from the component itself so we can have a separate state in case of edit-site.

@vindl vindl force-pushed the add/site-editor-fullscreen-mode branch from 57ba4cd to f683cca Compare March 12, 2020 18:34
@vindl vindl requested a review from ellatrix as a code owner March 12, 2020 18:34
@vindl vindl force-pushed the add/site-editor-fullscreen-mode branch from f683cca to 08067f3 Compare March 12, 2020 18:36
@@ -1,6 +1,6 @@
$footer-height: $button-size-small;

@import "./components/fullscreen-mode/style.scss";
@import "../../block-editor/src/components/fullscreen-mode/style.scss";
Copy link
Member Author

Choose a reason for hiding this comment

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

@youknowriad I'm thinking these styles should probably be moved out of block-editor and every editor implementation should be able to specify their own styles when is-fullscreen-mode class is added by FullscreenMode component. Since both edit-post and edit-site are running in the same wp-admin context, we'd probably end up duplicating the code from it, but that might be fine. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with the moving, for the global style, maybe it's fine to just pick one as a convention.

Copy link
Member Author

@vindl vindl Mar 13, 2020

Choose a reason for hiding this comment

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

Based on our Slack discussion I moved this import to block-editor package in 9e2b8de.

@vindl vindl removed the request for review from ellatrix March 12, 2020 18:46
This is needed to persist fullscreen mode activation independently
of edit-post package.
@vindl vindl force-pushed the add/site-editor-fullscreen-mode branch from 08067f3 to 081d4b5 Compare March 12, 2020 18:49
Copy link
Contributor

@Addison-Stavlo Addison-Stavlo left a comment

Choose a reason for hiding this comment

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

This works great on my end. Testing both the site editor and page/post editor fullscreen modes.

The code looks good too, I just had 1 question about a function there.

I'm kind of surprised there had yet to be a store set up for the edit-site package yet. But this is a very thorough start that should be easy to add onto in the future!

*
* @return {Object} control descriptor.
*/
export function select( storeName, selectorName, ...args ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does this export get used?
I see the default export in this file gets used in registerStore in the index, but what is this function doing?

Copy link
Member Author

Choose a reason for hiding this comment

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

I copied over the scaffolding from edit-post store to speed things up so likely an unintended leftover. Will recheck and remove it if it's not necessary. I also have to look into failing CI tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed in 1ce8f0d.

@@ -12,6 +12,7 @@ import { render } from '@wordpress/element';
* Internal dependencies
*/
import './hooks';
import './store';
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel this config should be reused somehow as well, some options:

  • Move it to the block-editor store (doesn't make sense for me as it's just a temporary location for the component)
  • Use a store in the new package, downside is that it makes it a singleton package (another one). (option we used everywhere for the moment)

Options we didn't use anywhere yet but could be good for reusabliity

  • Export a store config from the new package and leave the responsibility to register it to the caller wp.data.registerStore( 'core/edit-post-full-screen', fullscreenStoreConfig )
  • Don't use a store, use a React context provider.

I don't think it needs to be solved in this PR, but something to think about.

cc @aduth if you have thoughts.

Copy link
Member

Choose a reason for hiding this comment

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

To clarify, by "config", do you mean the user's general preference of "full site mode" being activated or not, across different implementations of the block editor?

Copy link
Contributor

@youknowriad youknowriad Mar 13, 2020

Choose a reason for hiding this comment

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

yes. But not necessarily the persisted preference since the persisted one can be different from screen to other. (just the memory handling of the preference)

@vindl vindl added this to the Gutenberg 7.8 milestone Mar 13, 2020
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

LGTM

Would be good to follow up with a UI to disable/enable the mode and potentially the "W" button to go back.

@vindl
Copy link
Member Author

vindl commented Mar 16, 2020

Would be good to follow up with a UI to disable/enable the mode and potentially the "W" button to go back.

Thanks for the reviews and testing @youknowriad! I'll look into these next.

@vindl vindl merged commit 79735ff into master Mar 16, 2020
@vindl vindl deleted the add/site-editor-fullscreen-mode branch March 16, 2020 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants