Skip to content

Commit

Permalink
Remove sibling inserter
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Jan 29, 2018
1 parent de1c9b5 commit 308bc80
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 197 deletions.
1 change: 0 additions & 1 deletion edit-post/assets/stylesheets/_z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ $z-layers: (
'.editor-block-list__block {core/image aligned left or right}': 20,
'.freeform-toolbar': 10,
'.editor-warning': 1,
'.editor-block-list__sibling-inserter': 1,
'.components-form-toggle__input': 1,
'.editor-format-list__menu': 1,
'.editor-inserter__tabs': 1,
Expand Down
4 changes: 2 additions & 2 deletions editor/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import BlockHtml from './block-html';
import BlockContextualToolbar from './block-contextual-toolbar';
import BlockMultiControls from './multi-controls';
import BlockMobileToolbar from './block-mobile-toolbar';
import BlockListSiblingInserter from './sibling-inserter';
import BlockInsertionPoint from './insertion-point';
import {
clearSelectedBlock,
editPost,
Expand Down Expand Up @@ -481,7 +481,7 @@ export class BlockListBlock extends Component {
{ showUI && <BlockMobileToolbar uid={ block.uid } renderBlockMenu={ renderBlockMenu } /> }
</div>
{ !! error && <BlockCrashWarning /> }
<BlockListSiblingInserter uid={ block.uid } />
<BlockInsertionPoint uid={ block.uid } />
</div>
);
/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/onclick-has-role, jsx-a11y/click-events-have-key-events */
Expand Down
4 changes: 2 additions & 2 deletions editor/components/block-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { serialize } from '@wordpress/blocks';
*/
import './style.scss';
import BlockListBlock from './block';
import BlockListSiblingInserter from './sibling-inserter';
import BlockInsertionPoint from './insertion-point';
import BlockSelectionClearer from '../block-selection-clearer';
import {
getBlockUids,
Expand Down Expand Up @@ -250,7 +250,7 @@ class BlockList extends Component {

return (
<BlockSelectionClearer>
{ !! blocks.length && <BlockListSiblingInserter /> }
{ !! blocks.length && <BlockInsertionPoint /> }
{ map( blocks, ( uid ) => (
<BlockListBlock
key={ 'block-' + uid }
Expand Down
24 changes: 7 additions & 17 deletions editor/components/block-list/insertion-point.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,13 @@ import {
getBlockInsertionPoint,
isBlockInsertionPointVisible,
} from '../../store/selectors';
import {
clearSelectedBlock,
} from '../../store/actions';

/**
* Component showing the block's insertion point.
*
* @param {Object} props React props passed to the component.
* @returns {Object|false} Rendered insertion point.
*/
function BlockListInsertionPoint( { showInsertionPoint } ) {
return showInsertionPoint && (
<div className="editor-block-list__insertion-point" />
);
function BlockInsertionPoint( { showInsertionPoint } ) {
if ( ! showInsertionPoint ) {
return null;
}

return <div className="editor-block-list__insertion-point" />;
}

export default connect(
Expand All @@ -39,7 +32,4 @@ export default connect(
),
};
},
{
clearSelectedBlock,
}
)( BlockListInsertionPoint );
)( BlockInsertionPoint );
95 changes: 0 additions & 95 deletions editor/components/block-list/sibling-inserter.js

This file was deleted.

90 changes: 13 additions & 77 deletions editor/components/block-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,19 @@
}
}

.editor-block-list__block > .editor-block-list__insertion-point {
position: absolute;
bottom: -10px;
top: auto;
left: 0;
right: 0;

@include break-small {
left: $block-mover-padding-visible;
right: $block-mover-padding-visible;
}
}

.editor-block-list__block .editor-block-list__block-html-textarea {
display: block;
margin: 0;
Expand All @@ -435,83 +448,6 @@
}
}

.editor-block-list__sibling-inserter {
z-index: z-index( '.editor-block-list__sibling-inserter' );
position: relative;

&[data-insert-index="0"] {
max-width: $visual-editor-max-width + ( 2 * $block-mover-padding-visible ) - ( 2 * $block-padding );
margin: 0 auto;
@include break-small {
max-width: $visual-editor-max-width - ( 2 * $block-padding );
}
}

&:before {
content: '';
position: absolute;
left: 0;
width: 100%;
height: 28px;
transition: 0.1s height;
transform: translateY( -50% );
}

&:hover:before {
height: 44px;
}

.editor-inserter {
position: absolute;
top: 50%;
left: 50%;
transform: translate( -50%, -50% );
margin: 0;
}

.editor-inserter__toggle {
opacity: 0;
transition: opacity 0.25s ease-in-out;

&:not( :focus ) {
transition-delay: 0.3s;
}
}

&.is-forced-visible .editor-inserter__toggle,
&:hover .editor-inserter__toggle,
.editor-inserter__toggle:focus {
opacity: 1;
}

.editor-inserter__toggle.components-button {
margin: 0;
padding: 4px;
background: $white;

&:focus {
background: $light-gray-300;
}

.dashicon {
vertical-align: bottom;
}
}
}

.editor-block-list__block > .editor-block-list__sibling-inserter {
position: absolute;
bottom: 0;
top: auto;
left: 0;
right: 0;

@include break-small {
left: $block-mover-padding-visible;
right: $block-mover-padding-visible;
}
}

$sticky-bottom-offset: 20px;

.editor-block-contextual-toolbar {
Expand Down
4 changes: 1 addition & 3 deletions editor/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ export class InserterMenu extends Component {
return 1; // Move focus forward
}

// Prevent cases of focus being unexpectedly stolen up in the tree,
// notably when using VisualEditorSiblingInserter, where focus is
// moved to sibling blocks.
// Prevent cases of focus being unexpectedly stolen up in the tree.
if ( includes( ARROWS, event.keyCode ) ) {
return 0; // Don't move focus, but prevent event propagation
}
Expand Down

0 comments on commit 308bc80

Please sign in to comment.