-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Components: Expose the Editor's reusable components #3389
Conversation
ff78455
to
b4c5512
Compare
Codecov Report
@@ Coverage Diff @@
## master #3389 +/- ##
==========================================
+ Coverage 31.98% 33.15% +1.17%
==========================================
Files 249 249
Lines 6901 6711 -190
Branches 1254 1206 -48
==========================================
+ Hits 2207 2225 +18
+ Misses 3945 3786 -159
+ Partials 749 700 -49
Continue to review full report at Codecov.
|
b4c5512
to
ea25ca5
Compare
@@ -14,8 +14,8 @@ import { __ } from '@wordpress/i18n'; | |||
*/ | |||
import './style.scss'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that we don't prefix document-outline
class name with editor-
like in all other places. We can fix it in another PR if it isn't designed this way on purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, it should be prefixed. This is documented in coding guidelines, but I'm now noticing they were written prior to other folders containing components:
https://github.com/WordPress/gutenberg/blob/master/docs/coding-guidelines.md#css
Any default export of a folder's index.js must be prefixed with editor- followed by the directory name in which it resides:
.editor-[ directory name ]
The intended convention is:
[ root module name ]-[ current directory name ]
- Example:
editor-foo
- Example:
[ root module name ]-[ current directory name ]__[ descendant description ]
- Example:
editor-foo__child
- Example:
[ root module name ]-[ current directory name ]__[ descendant description ].is-[ modifier description ]
- Example:
editor-foo__child.is-green
- Example:
Code changes look good. I need to give it a spin locally and make sure everything works as before. I like how we expose all those components and provide unified naming and structure. Awesome work 👍
Let's open a follow-up issue with the list of all components and label this issue as a |
export { default as PostTrash } from './post-trash'; | ||
export { default as PostVisibility } from './post-visibility'; | ||
export { default as PostVisibilityLabel } from './post-visibility/label'; | ||
export { default as UnsavedChangesWarning } from './unsaved-changes-warning'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like some components that depend on the post state could have Post
prefix, too. PageAttributes
makes it harder to come up with a good pattern here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, did this change for one or two components but gave up, we could do it separately one by one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel your pain, it can be combined with README
task. We would have to leave an additional note when applicable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested locally, I didn't find any issues. Let's merge it as it is and continue refinements in the follow-up PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple initial concerns looking through this:
- The naming "components"; could cause some confusion with the top-level components module, but also even within
editor
itself we still have other components that aren't in this folder. Is it obvious why? I understand only in the context of this pull request that they are intended to be part of the public API of components. - Maybe a more general concern of how do we decide which components do and don't belong in this directory
@aduth Fair point This comment #2761 (comment) clarifies the intentation here (and the next steps better). The idea is to end up with an - editor/components
- editor/post-editor/ (header, sidebar, layout ...)
- editor/store
- editor/utils This would address the concern about the components because we'd have only two folders containing components. The exposed components in We could also argue that the
Good question and we should make this clear in the README of this folder I think. A component in this folder is any component you can reuse to build your own editor's layout. It shouldn't include any "layout styling" and the only requirement to use this component is to to be included as a children of |
Okay, I agree some amount of organization will be necessary and this could help distinguish between pieces of a post editor and the plain editor itself. It's yet to be seen how exactly this would play out (post editor in a separate top-level folder? post editor needing its own state that could be confused with editor common state? alternative names to a "components" directory?) but as long as the public API remains relatively stable, it should be okay to make revisions to this later. |
ea25ca5
to
8ebe579
Compare
refs #2761
This PR groups the reusable components of the
Editor
module under thecomponents
directory. And export them as External API for the module.All these components should be documented with a README for each one of them. I'd appreciate a team effort to add these READMEs.
Next Steps
There are still some components that need to be moved to this directory and are not exposed yet:
BlockList: This includes the BlockToolbar, the BlockSettingsMenu, and the BlockInspector. This needs a bit of reorganisation to make them really reusable. We need to clarify the external API and remove any "PostEditor" releated styles. A PR specific to these components should address this.
PostTitle and PostPermalink: The only changes left for these is to move out the PostEditor specific Styles
TextEditor: Same needs a bit of refactoring to drop the PostEditor's styles.
Once done, we could reorganize the remaining components under a "post-editor" directory or similar.
Note
I'd appreciate a quick review as this may create a lot of conflicts.