Skip to content

Commit

Permalink
Block editor: nav mode: move class (#30181)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored Mar 24, 2021
1 parent 229aaea commit 8d029c6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
15 changes: 13 additions & 2 deletions packages/block-editor/src/components/block-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,23 @@ export default function BlockList( { className, __experimentalLayout } ) {
useScrollSelectionIntoView( ref );

const isLargeViewport = useViewportMatch( 'medium' );
const { isTyping, isOutlineMode, isFocusMode } = useSelect( ( select ) => {
const { isTyping: _isTyping, getSettings } = select( blockEditorStore );
const {
isTyping,
isOutlineMode,
isFocusMode,
isNavigationMode,
} = useSelect( ( select ) => {
const {
isTyping: _isTyping,
getSettings,
isNavigationMode: _isNavigationMode,
} = select( blockEditorStore );
const { outlineMode, focusMode } = getSettings();
return {
isTyping: _isTyping(),
isOutlineMode: outlineMode,
isFocusMode: focusMode,
isNavigationMode: _isNavigationMode(),
};
}, [] );

Expand All @@ -55,6 +65,7 @@ export default function BlockList( { className, __experimentalLayout } ) {
'is-typing': isTyping,
'is-outline-mode': isOutlineMode,
'is-focus-mode': isFocusMode && isLargeViewport,
'is-navigate-mode': isNavigationMode,
}
) }
>
Expand Down
18 changes: 9 additions & 9 deletions packages/block-editor/src/components/block-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@
.block-editor-block-list__layout {
position: relative;

// Select tool/navigation mode shows the default cursor until an additional click edits.
&.is-navigate-mode {
cursor: default;
}

// The primary indicator of selection in text is the native selection marker.
// When selecting multiple blocks, we provide an additional selection indicator.
.is-navigate-mode & .block-editor-block-list__block.is-selected,
.is-navigate-mode & .block-editor-block-list__block.is-hovered,
&.is-navigate-mode .block-editor-block-list__block.is-selected,
&.is-navigate-mode .block-editor-block-list__block.is-hovered,
.block-editor-block-list__block.is-highlighted,
.block-editor-block-list__block.is-multi-selected {

Expand Down Expand Up @@ -83,13 +88,13 @@
}
}

.is-navigate-mode & .block-editor-block-list__block.is-hovered:not(.is-selected)::after {
&.is-navigate-mode .block-editor-block-list__block.is-hovered:not(.is-selected)::after {
box-shadow: 0 0 0 1px $gray-600;
}

.block-editor-block-list__block.is-highlighted::after,
.block-editor-block-list__block.is-multi-selected::after,
.is-navigate-mode & .block-editor-block-list__block.is-selected::after,
&.is-navigate-mode .block-editor-block-list__block.is-selected::after,
& .is-block-moving-mode.block-editor-block-list__block.has-child-selected {
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
outline: var(--wp-admin-border-width-focus) solid transparent;
Expand Down Expand Up @@ -264,11 +269,6 @@
box-shadow: 0 0 0 1px var(--wp-admin-theme-color);
}

// Select tool/navigation mode shows the default cursor until an additional click edits.
.is-navigate-mode & {
cursor: default;
}

// Clear floats.
&[data-clear="true"] {
float: none;
Expand Down
10 changes: 1 addition & 9 deletions packages/block-editor/src/components/writing-flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import { find, reverse, first, last } from 'lodash';
import classnames from 'classnames';

/**
* WordPress dependencies
Expand Down Expand Up @@ -156,7 +155,6 @@ function selector( select ) {
getLastMultiSelectedBlockClientId,
hasMultiSelection,
getBlockOrder,
isNavigationMode,
isSelectionEnabled,
getBlockSelectionStart,
isMultiSelecting,
Expand All @@ -182,7 +180,6 @@ function selector( select ) {
hasMultiSelection: hasMultiSelection(),
firstBlock: first( blocks ),
lastBlock: last( blocks ),
isNavigationMode: isNavigationMode(),
isSelectionEnabled: isSelectionEnabled(),
blockSelectionStart: getBlockSelectionStart(),
isMultiSelecting: isMultiSelecting(),
Expand Down Expand Up @@ -226,7 +223,6 @@ export default function WritingFlow( { children } ) {
hasMultiSelection,
firstBlock,
lastBlock,
isNavigationMode,
isSelectionEnabled,
blockSelectionStart,
isMultiSelecting,
Expand Down Expand Up @@ -535,10 +531,6 @@ export default function WritingFlow( { children } ) {
};
}, [] );

const className = classnames( 'block-editor-writing-flow', {
'is-navigate-mode': isNavigationMode,
} );

// Disable reason: Wrapper itself is non-interactive, but must capture
// bubbling events from children to determine focus transition intents.
/* eslint-disable jsx-a11y/no-static-element-interactions */
Expand Down Expand Up @@ -568,7 +560,7 @@ export default function WritingFlow( { children } ) {
/>
<div
ref={ container }
className={ className }
className="block-editor-writing-flow"
onKeyDown={ onKeyDown }
onMouseDown={ onMouseDown }
>
Expand Down

0 comments on commit 8d029c6

Please sign in to comment.