Skip to content

Conversation

@youknowriad
Copy link
Contributor

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.

@youknowriad youknowriad added the Framework Issues related to broader framework topics, especially as it relates to javascript label Apr 12, 2017
@youknowriad youknowriad self-assigned this Apr 12, 2017
@youknowriad youknowriad requested review from aduth and jasmussen April 12, 2017 14:40
@jasmussen
Copy link
Contributor

This is really solid! I like it! 👍

If you can add $dark-gray-900 as a hover color on the arrows, that'd be perfect!

return (
<div className="editor-arrangement-toolbar">
<button
className={ classnames( 'editor-arrangement-toolbar__control', { 'is-disabled': isFirst } ) }
Copy link
Member

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
Copy link
Member

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 {
Copy link
Member

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?

Copy link
Contributor Author

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

isSelected={ isSelected }
attributes={ block.attributes }
setAttributes={ setAttributes } />
<div className="editor-visual-editor__block-edit">
Copy link
Member

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?

Copy link
Contributor Author

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':
Copy link
Member

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.

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 have a small preference for the explicit actions but I don't mind if we change this later.

Copy link
Member

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
Copy link
Member

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 @@
/**
Copy link
Member

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.

Copy link
Contributor

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.

@youknowriad
Copy link
Contributor Author

Feedback addressed, this may be good to go?

return (
<div className="editor-block-mover">
<IconButton
className={ classnames( 'editor-block-mover__control', { 'is-disabled': isFirst } ) }
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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)

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

@mtias
Copy link
Member

mtias commented Apr 13, 2017

I'm ok with merging and iterating.

@youknowriad youknowriad merged commit 413e853 into master Apr 13, 2017
@youknowriad youknowriad deleted the add/arrangement-toolbar branch April 13, 2017 13:19
@aduth
Copy link
Member

aduth commented Apr 26, 2017

Appears that an empty editor/components/click-outside/index.js file was included with these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Framework Issues related to broader framework topics, especially as it relates to javascript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants