-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Visual Editor: Adding the arrangement toolbar (up/down arrows) #412
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
Conversation
|
This is really solid! I like it! 👍 If you can add |
| return ( | ||
| <div className="editor-arrangement-toolbar"> | ||
| <button | ||
| className={ classnames( 'editor-arrangement-toolbar__control', { 'is-disabled': isFirst } ) } |
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.
Line is a little long. If not as separate variables, at least some line breaks could help clear it up:
className={ classnames( 'editor-arrangement-toolbar__control', {
'is-disabled': isFirst
} ) }| function BlockArrangement( { onMoveUp, onMoveDown, isFirst, isLast } ) { | ||
| return ( | ||
| <div className="editor-arrangement-toolbar"> | ||
| <button |
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.
Seems appropriate as rendering with the IconButton component?
| top: 10px; | ||
| left: 0; | ||
|
|
||
| .editor-arrangement-toolbar__control { |
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.
Does this need to be nested?
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.
Probably not! sorry copy/pasted
editor/modes/visual-editor/block.js
Outdated
| isSelected={ isSelected } | ||
| attributes={ block.attributes } | ||
| setAttributes={ setAttributes } /> | ||
| <div className="editor-visual-editor__block-edit"> |
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.
Hmm would it be possible to effect the padding on the parent .editor-visual-editor__block instead of creating a wrapper 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.
The desired behavior was really hard to achieve. I'll see if this works and update.
| case 'REPLACE_BLOCKS': | ||
| return action.blockNodes.map( ( { uid } ) => uid ); | ||
|
|
||
| case 'MOVE_BLOCK_UP': |
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 wonder if it would be easier to have only a single action, something like INCREMENT_BLOCK_POSITION, where an increment: 1 or increment: -1 property value could be passed to determine the increment effect.
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 have a small preference for the explicit actions but I don't mind if we change this later.
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.
Also need to consider drag and drop.
| export default connect( | ||
| ( state, ownProps ) => ( { | ||
| isFirst: first( state.blocks.order ) === ownProps.uid, | ||
| isLirst: last( state.blocks.order ) === ownProps.uid |
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.
Typo: isLirst -> isLast
| @@ -0,0 +1,52 @@ | |||
| /** | |||
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.
@jasmussen I think we need to take a look at the glossary and figure out how to describe and group things. I've been thinking we could do block-controls and within that have the different pieces: toolbar, placement, switcher, etc.
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 will put on my todo-list to create a labelled blueprint for the UI as a start, that can hopefully grease the discussion for what the individual components and classes should be called.
|
Feedback addressed, this may be good to go? |
| return ( | ||
| <div className="editor-block-mover"> | ||
| <IconButton | ||
| className={ classnames( 'editor-block-mover__control', { 'is-disabled': isFirst } ) } |
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.
The classes should be block-mover__ only.
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.
🤔 We should update our coding guidelines https://github.com/WordPress/gutenberg/blob/master/docs/coding-guidelines.md
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.
Maybe we should keep it this way in this PR and drop the editor prefix from all the components in a specific PR. (To avoid having a mix of conventions)
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.
Right, this is following the fact I want to move these components out of the editor and make them only about blocks.
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.
See #408 (comment)
|
I'm ok with merging and iterating. |
|
Appears that an empty |
This PR adds the up/down arrows to move blocks. The arrangement toolbar is shown if the block is selected or hovered.
Missing in this PR: Selecting the block being moved, I'm waiting to the simplification of the reducers in #407 to add this.