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

Inserter: Add a visual placeholder at the position where the block is going to be inserted #835

Merged
merged 4 commits into from
May 23, 2017

Conversation

youknowriad
Copy link
Contributor

@youknowriad youknowriad commented May 18, 2017

closes #833

This is not completely functional, because each time we click the inserter, the block is unselected which is not the desired behaviour and should be fixed by #827

Anyway, this is adding the placeholder at the end of the editor right now.

@youknowriad youknowriad added [Type] Task Issues or PRs that have been broken down into an individual action to take [Feature] Inserter The main way to insert blocks using the + button in the editing interface labels May 18, 2017
@youknowriad youknowriad self-assigned this May 18, 2017
};
}

export function setBlockToInsert( slug, after ) {
Copy link
Member

@mtias mtias May 18, 2017

Choose a reason for hiding this comment

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

I scratched my head a little bit on what this name implied :)

Copy link
Contributor Author

@youknowriad youknowriad May 18, 2017

Choose a reason for hiding this comment

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

Please give me a better name. I know naming in this PR particularly is really bad. Naming this state is not easy :P. I scratched my head to find these names.

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 setBlockInsertionPoint or something like that.

Copy link
Member

Choose a reason for hiding this comment

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

Why do we need an "insert block" and a "set block to insert" action?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we hover the inserter block, we need to show the placeholder right after the selected block. I guess we don't really need the exact slug of the block to be inserted, right now, we just need to know that we're going to insert a block but I thought this information could be useful in the state.

Copy link
Member

Choose a reason for hiding this comment

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

If we are only talking about the temporary blue line, I think we should call that setInsertionPoint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's do that and remove the "slug" completely from the state.

editor/state.js Outdated
@@ -279,6 +279,22 @@ export function hoveredBlock( state = null, action ) {
}

/**
* Reducer returning the block slug to be inserter.
Copy link
Member

Choose a reason for hiding this comment

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

type: "inserted"

@@ -229,6 +232,7 @@ export default connect(
block: getBlock( state, ownProps.uid ),
isSelected: isBlockSelected( state, ownProps.uid ),
isHovered: isBlockHovered( state, ownProps.uid ),
isInsertionPoint: isBlockBeforeInsertPoint( state, 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.

I believe we should create a new element at the block insertion point, otherwise the insertion point will be determined by the specificities of the block-before-insertion-point. Example: if the block is a wide image, the blue line will be full width.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point

@jasmussen
Copy link
Contributor

I love this. Thank you for working on it. Can't wait for the blue line to also work after the block that's currently focused.

@youknowriad
Copy link
Contributor Author

@jasmussen I rebased since the other ticket got merged so it should already work

@jasmussen
Copy link
Contributor

Nice, yes, works now!

Does the element exist in the flow of the dom or is it overlaid? If the former, it'd be nice if the line itself actually got a little margin. It's okay that it has to push things around a bit. Is this possible or very difficult?

@youknowriad
Copy link
Contributor Author

Does the element exist in the flow of the dom or is it overlaid? If the former, it'd be nice if the line itself actually got a little margin. It's okay that it has to push things around a bit. Is this possible or very difficult?

It's an element that exits in the dom. I think it shouldn't push things around though (It's absolute positioned to avoid this), because if you use the inserter at the bottom of the editor, you'll notice a jump in the inserter when you hover a block to insert.

@jasmussen
Copy link
Contributor

👍 👍

I can work with that.

Can we push the blue line down a bit though? Like another 4 or 6 pixels (or whatever it takes)?

Currently looks like this:

screen shot 2017-05-19 at 11 07 52

Can it look more like this?

screen shot 2017-05-19 at 11 07 52

@youknowriad
Copy link
Contributor Author

If there's no objection I'm keen to merge this soon

@jasmussen
Copy link
Contributor

If there are no code concerns, visually it's in a good place! 👍

undefined,
( state ) => {
return {
selectedBlock: getSelectedBlock( state ),
Copy link
Member

Choose a reason for hiding this comment

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

It seems to me that the inserter should have no knowledge of what block is selected. The inserter, in a way, only cares about inserting a block and dispatching the "show insertion point". Once we process the insert action the app would know the selected block internally and handle that aspect. What are your thoughts there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you suggesting we trigger the insertBlock action here without specifying the position where we'll insert the block (see after argument in onInsertBlock)?

I guess this is possible, but this complexifies the blocks.order reducer a lot, because we'll need to be aware of the insertedBlock sub-reducer value inside the blocks.order reducer to find the right position. Which means we can't use combineReducers utility.

I think we shouldn't introduce this complexity in the state and instead have all the required information to process the insert in the INSERT action.

@youknowriad
Copy link
Contributor Author

Merging, I'll address any concern separately.

@youknowriad youknowriad merged commit 3b2d42f into master May 23, 2017
@youknowriad youknowriad deleted the add/insertion-point branch May 23, 2017 09:37
@afercia
Copy link
Contributor

afercia commented May 24, 2017

If I'm not wrong, this PR removed also the hover/focus style on the inserter menu items that used border: 1px solid $dark-gray-500; and there's no explicit mention of this change here on in the related issue. As a result, the focus style on the inserter menu items is now based just on a subtle color change and so it's not sufficient for accessibility.

@jasmussen
Copy link
Contributor

As a result, the focus style on the inserter menu items is now based just on a subtle color change and so it's not sufficient for accessibility.

I will open a separate ticket with designs for hover and focus styles for our various UI components. then we can apply this across the UI from a single source of best practices.

@youknowriad
Copy link
Contributor Author

@afercia I made this change because it's explicitly shown as is the mockups of the issue. Let's fix this separately though

@afercia
Copy link
Contributor

afercia commented May 24, 2017

Sure. Maybe the screenshots were just a bit outdated/unrelated. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Inserter The main way to insert blocks using the + button in the editing interface [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.

Simplify insertion flow
4 participants