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

Add interface package with sidebar functionality #20698

Conversation

jorgefilipecosta
Copy link
Member

Description

Supersedes: #20336
This PR starts an admin-screen package suggested by @youknowriad in #20336 (review).

This package for now just contains the sidebar functionality but other functionality will be added (e.g: fullscreen mode).

The sidebar functionality is renamed the ComplementaryArea as suggested by @gziolo.
This package, for now, is experimental should be private and is bundled with other packages.

Regarding the admin screen store:

We implement an API in the store that allows keeping track of which area is active in a given zone when only one area can be active at a time. For example what sidebar is being rendered, what tab in a tab system is enabled etc...

wp.data.dispatch('core/admin-screen').setSingleActiveArea( 'edit-site/complementary-area', 'edit-site/block-inspector'  );

wp.data.select('core/admin-screen').getSingleActiveArea( 'edit-site/complementary-area' ); -> "edit-site/block-inspector"

wp.data.dispatch('core/admin-screen').setSingleActiveArea( 'edit-site/complementary-area', 'edit-site/global-styles'  );

wp.data.select('core/plugins').getSingleActiveArea( 'edit-site/complementary-area' ); -> "edit-site/global-styles"

wp.data.dispatch('core/plugins').setSingleActiveArea( 'edit-site/complementary-area' );

wp.data.select('core/plugins').getSingleActiveArea( 'edit-site/complementary-area' ); -> undefined

We implement an API in the store that allows keeping track of which areas are active in a given zone when multiple areas can be active at a time
E.g: which plugins are pinned, which panels are open.
This API allows plugins to keep track for example which panels are open and take advantage of the persisting mechanism (when we add it) without the need to implement their own store/persistence.

wp.data.select('core/admin-screen').isMultipleActiveAreaActive( 'edit-post/complementary-area', 'edit-post/block-patterns-sidebar' ); -> false

wp.data.dispatch('core/admin-screen').setMultipleActiveAreaEnableState( 'edit-post/complementary-area', 'edit-post/block-patterns-sidebar', true );

wp.data.select('core/admin-screen').isMultipleActiveAreaActive( 'edit-post/complementary-area', 'edit-post/block-patterns-sidebar' ); -> true

How has this been tested?

I verified the edit-post sidebar still works as expected (namely auto-closing on mobile, keyboard shortcuts, plugin sidebar).
I verified the sidebar mechanism added on edit-site works as expected.

@github-actions
Copy link

github-actions bot commented Mar 7, 2020

Size Change: +4.23 kB (0%)

Total Size: 861 kB

Filename Size Change
build/annotations/index.js 3.44 kB -3 B (0%)
build/autop/index.js 2.58 kB -1 B
build/block-directory/index.js 6.02 kB +2 B (0%)
build/block-editor/index.js 102 kB +71 B (0%)
build/block-library/index.js 110 kB +38 B (0%)
build/block-serialization-default-parser/index.js 1.64 kB -2 B (0%)
build/blocks/index.js 57.5 kB +1 B
build/components/index.js 190 kB +65 B (0%)
build/compose/index.js 6.2 kB -2 B (0%)
build/core-data/index.js 10.6 kB -1 B
build/data/index.js 8.26 kB +1 B
build/date/index.js 5.37 kB +2 B (0%)
build/edit-post/index.js 92.3 kB +1.3 kB (1%)
build/edit-post/style-rtl.css 8.35 kB -86 B (1%)
build/edit-post/style.css 8.34 kB -85 B (1%)
build/edit-site/index.js 8.63 kB +1.99 kB (23%) 🚨
build/edit-site/style-rtl.css 3.44 kB +455 B (13%) ⚠️
build/edit-site/style.css 3.44 kB +457 B (13%) ⚠️
build/edit-widgets/index.js 4.43 kB +1 B
build/editor/index.js 42.8 kB +30 B (0%)
build/element/index.js 4.44 kB -1 B
build/format-library/index.js 6.95 kB +2 B (0%)
build/media-utils/index.js 4.84 kB -1 B
build/notices/index.js 1.57 kB +1 B
build/plugins/index.js 2.54 kB -2 B (0%)
build/primitives/index.js 1.5 kB -2 B (0%)
build/redux-routine/index.js 2.83 kB -1 B
build/rich-text/index.js 14.5 kB -1 B
build/shortcode/index.js 1.7 kB -1 B
build/warning/index.js 1.14 kB +1 B
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 998 B 0 B
build/api-fetch/index.js 3.39 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-editor/style-rtl.css 11 kB 0 B
build/block-editor/style.css 11 kB 0 B
build/block-library/editor-rtl.css 7.21 kB 0 B
build/block-library/editor.css 7.21 kB 0 B
build/block-library/style-rtl.css 7.49 kB 0 B
build/block-library/style.css 7.5 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-spec-parser/index.js 3.1 kB 0 B
build/components/style-rtl.css 15.8 kB 0 B
build/components/style.css 15.7 kB 0 B
build/data-controls/index.js 1.04 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 568 B 0 B
build/dom/index.js 3.06 kB 0 B
build/edit-widgets/style-rtl.css 2.57 kB 0 B
build/edit-widgets/style.css 2.57 kB 0 B
build/editor/editor-styles-rtl.css 423 B 0 B
build/editor/editor-styles.css 426 B 0 B
build/editor/style-rtl.css 3.38 kB 0 B
build/editor/style.css 3.38 kB 0 B
build/escape-html/index.js 733 B 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.93 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.57 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.7 kB 0 B
build/list-reusable-blocks/index.js 2.99 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/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/priority-queue/index.js 781 B 0 B
build/server-side-render/index.js 2.55 kB 0 B
build/token-list/index.js 1.28 kB 0 B
build/url/index.js 4.01 kB 0 B
build/viewport/index.js 1.61 kB 0 B
build/wordcount/index.js 1.18 kB 0 B

compressed-size-action

@jorgefilipecosta jorgefilipecosta force-pushed the add/admin-screen-package-move-sidebar-functionality-admin-screen branch 2 times, most recently from 2ef0838 to ee38298 Compare March 8, 2020 12:03
@jorgefilipecosta jorgefilipecosta force-pushed the add/admin-screen-package-move-sidebar-functionality-admin-screen branch 4 times, most recently from 924d9b5 to e1ed846 Compare March 8, 2020 14:51
@mtias
Copy link
Member

mtias commented Mar 8, 2020

admin-screen seems like a weird name for this to me.

@jorgefilipecosta jorgefilipecosta force-pushed the add/admin-screen-package-move-sidebar-functionality-admin-screen branch 2 times, most recently from 46fa964 to 4343c53 Compare March 8, 2020 16:08
@youknowriad
Copy link
Contributor

@mtias we have different things we want to reuse across screens. Sidebar Plugins, EditorSkeleton (PageSkeleton), FullscreenMode

What do you suggest as a name?

@mtias
Copy link
Member

mtias commented Mar 9, 2020

I know it's already in use, but this would be the "editor" package to me (as opposed to the block editor).

@jorgefilipecosta
Copy link
Member Author

Maybe editor-screen would be a good name?

@mtias
Copy link
Member

mtias commented Mar 9, 2020

Can you list all the "editor" related packages we'd have?

@jorgefilipecosta
Copy link
Member Author

Can you list all the "editor" related packages we'd have?

Hi @mtias,
We would have "block-editor", "editor" and "editor-screen" plus three packages that would potentially use editor-screen: "edit-post", "edit-site", "edit-widgets".

@mtias
Copy link
Member

mtias commented Mar 9, 2020

What are the conceptual differences among block-editor, editor and editor-screen?

@jorgefilipecosta
Copy link
Member Author

What are the conceptual differences among block-editor, editor and editor-screen?

Hi @mtias,

  • block-editor -> Generic block editor, responsible for dealing with the blocks. Given a data structure that represents a set of blocks renders a UI to edit these blocks, to remove, move, and insert new blocks. Not WordPress specific.
  • editor -> Provides a set of helpers to deal with WordPress posts and its edits. I think today we could do almost everything this module does with our data APIs; in the long term, this module should probably be deprecated.
  • editor-screen -> Provides a set of helpers to build a screen UI in WordPress similar to the post edit screen Gutenberg offers. Allows controlling which areas are active or not, e.g., block-inspector, a plugin sidebar, what modes are active, e.g., fullscreen., what items are open or closed the panels, and deals with persisting these settings.

@mtias
Copy link
Member

mtias commented Mar 10, 2020

editor and editor-screen should likely be folded together then.

@youknowriad
Copy link
Contributor

Do you think these components/tools (Skeleton, Sidebar, Fullscreen) are things specific to editor screens or any Admin screen? Personally, I'm thinking the latter.

@gziolo
Copy link
Member

gziolo commented Mar 11, 2020

Whatever the final decision is, we should improve the documentation for all mentioned packages and provide a high-level overview of how they all fit together. It's always been an issue for all people that start with Gutenberg development.

@jorgefilipecosta
Copy link
Member Author

Do you think these components/tools (Skeleton, Sidebar, Fullscreen) are things specific to editor screens or any Admin screen? Personally, I'm thinking the latter.

Good point, I agree these UI artifacts may be the basis to a screen in WordPress that may not necessarily contain an editor, e.g: I may imagine this artifact may contain a system to manage tickets, and the sidebars show information about the person that submitted the ticket.

What do you think @mtias?

@jorgefilipecosta jorgefilipecosta force-pushed the add/admin-screen-package-move-sidebar-functionality-admin-screen branch from cc9ae9b to af54fbb Compare March 27, 2020 16:47
jorgefilipecosta and others added 7 commits March 30, 2020 12:58
Squashed commits:
[55e02fd47e] Update packages/edit-post/src/components/layout/index.js

Co-Authored-By: Grzegorz (Greg) Ziółkowski <[email protected]>
[7aa42cba13] Update packages/interface/src/components/plugin-complementary-area-header/index.js

Co-Authored-By: Grzegorz (Greg) Ziółkowski <[email protected]>
[13abfa99d2] Update packages/interface/package.json

Co-Authored-By: Grzegorz (Greg) Ziółkowski <[email protected]>
[61b5b1086e] Update packages/interface/package.json

Co-Authored-By: Grzegorz (Greg) Ziółkowski <[email protected]>
[b5f425096c] Update packages/interface/src/components/pinned-items/index.js

Co-Authored-By: Grzegorz (Greg) Ziółkowski <[email protected]>
[2e5bb80774] Update packages/edit-post/src/components/header/index.js

Co-Authored-By: Grzegorz (Greg) Ziółkowski <[email protected]>
[40e1bb4c4e] Add interface package with sidebar functionality
Co-Authored-By: Grzegorz (Greg) Ziółkowski <[email protected]>
@jorgefilipecosta jorgefilipecosta force-pushed the add/admin-screen-package-move-sidebar-functionality-admin-screen branch from af54fbb to 78d8de7 Compare March 30, 2020 11:59
@jorgefilipecosta jorgefilipecosta merged commit 16e4f20 into master Mar 30, 2020
@jorgefilipecosta jorgefilipecosta deleted the add/admin-screen-package-move-sidebar-functionality-admin-screen branch March 30, 2020 12:37
@github-actions github-actions bot added this to the Gutenberg 7.9 milestone Mar 30, 2020
function Sidebar() {
return (
<div className="edit-site-sidebar">
Copy link
Member

Choose a reason for hiding this comment

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

@jorgefilipecosta want to check why we removed this, because I'm adding it back at https://github.com/WordPress/gutenberg/pull/20530/files?file-filters%5B%5D=.js#diff-3924a41ad88da62082971d8c0aa8b20fL14

The style.css is still targeting that class. I've only noticed after the changes made to the hooks (color, line-height), because some styles were leaking to the edit-site sidebar.

@@ -62,7 +62,7 @@ export default function Header() {
</div>
<div className="edit-site-header__actions">
<SaveButton />
<MoreMenu />
Copy link
Member

Choose a reason for hiding this comment

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

Was this removal intentional or did it just end up there during the rebase?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably a rebase issue.

Copy link
Member

@vindl vindl Mar 31, 2020

Choose a reason for hiding this comment

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

Probably a rebase issue.

Ok, I'll spin up a quick PR to bring it back. Update: merged in #21288

@youknowriad
Copy link
Contributor

@vindl @jorgefilipecosta Should we move EditorSkeleton and Fullscreen to the new package?

@gziolo
Copy link
Member

gziolo commented Mar 31, 2020

Just wanted to highlight my comments that weren't addressed:

I don't remember if I mentioned it but users will lost their saved preferences for pinned items because the migration path is missing. It was persisted in the local storage in the core/edit-post store so far.

@vindl
Copy link
Member

vindl commented Mar 31, 2020

@vindl @jorgefilipecosta Should we move EditorSkeleton and Fullscreen to the new package?

As for the Fullscreen - yes, I think so and I can look into this soon. As for the EditorSkeleton, I'd have to check its code a bit more before I can say for sure.

@vindl vindl mentioned this pull request Mar 31, 2020
6 tasks
vindl added a commit that referenced this pull request Mar 31, 2020
Brings back the Site Editor more menu that was likely
lost as a result of a rebase in a #20698.
@vindl
Copy link
Member

vindl commented Apr 1, 2020

@vindl @jorgefilipecosta Should we move EditorSkeleton and Fullscreen to the new package?

@youknowriad I started the PRs for moving those in: #21334 and #21335.

@aduth
Copy link
Member

aduth commented Apr 2, 2020

Note: I added the interface package as an unchecked task as part of #18838, since it was not included with the introduction of the package.

@gziolo
Copy link
Member

gziolo commented Apr 6, 2020

Addressed in #21417.

@jorgefilipecosta
Copy link
Member Author

unit tests for old store logic were removed, there are no tests for the new store

Hi @gziolo, I will soon submit a set of unit tests the functionally of this package. I just want to understand the shape the package will follow as things can still change so we don't waste effort on tests that may need updates.

I don't remember if I mentioned it but users will lost their saved preferences for pinned items because the migration path is missing. It was persisted in the local storage in the core/edit-post store so far.

I think it was discussed before, personally I think losing the pinned items is not a big issue as users can easily update them, add the migration path may make our code more complex. But if you all think we should have some migration I can propose something. Any thoughts on this @gziolo, @youknowriad?

const { pinItem, unpinItem } = useDispatch( 'core/interface' );
return (
<>
{ isPinned && (
Copy link
Member

Choose a reason for hiding this comment

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

The fact that isPinned is now outside of the <PinnedItems /> fill created a regression as described in #28546 =.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system [Package] Edit Post /packages/edit-post [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants