Skip to content

Commit

Permalink
Add new block indicator should show in place of empty block instead o…
Browse files Browse the repository at this point in the history
…f below it (#16272)

Show "ADD BLOCK HERE" item above block when a block is empty
  • Loading branch information
marecar3 authored Jun 25, 2019
1 parent 64a8a7c commit 56de120
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
23 changes: 15 additions & 8 deletions packages/block-editor/src/components/block-list/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class BlockList extends Component {
super( ...arguments );

this.renderItem = this.renderItem.bind( this );
this.renderAddBlockSeparator = this.renderAddBlockSeparator.bind( this );
this.shouldFlatListPreventAutomaticScroll = this.shouldFlatListPreventAutomaticScroll.bind( this );
this.renderDefaultBlockAppender = this.renderDefaultBlockAppender.bind( this );
this.onBlockTypeSelected = this.onBlockTypeSelected.bind( this );
Expand Down Expand Up @@ -213,8 +214,10 @@ export class BlockList extends Component {
}

renderItem( { item: clientId } ) {
const shouldReverseContent = this.isReplaceable( this.props.selectedBlock );

return (
<ReadableContentView>
<ReadableContentView reversed={ shouldReverseContent }>
<BlockListBlock
key={ clientId }
showTitle={ false }
Expand All @@ -224,17 +227,21 @@ export class BlockList extends Component {
borderStyle={ this.blockHolderBorderStyle() }
focusedBorderColor={ styles.blockHolderFocused.borderColor }
/>
{ this.state.blockTypePickerVisible && this.props.isBlockSelected( clientId ) && (
<View style={ styles.containerStyleAddHere } >
<View style={ styles.lineStyleAddHere }></View>
<Text style={ styles.labelStyleAddHere } >{ __( 'ADD BLOCK HERE' ) }</Text>
<View style={ styles.lineStyleAddHere }></View>
</View>
) }
{ this.state.blockTypePickerVisible && this.props.isBlockSelected( clientId ) && this.renderAddBlockSeparator() }
</ReadableContentView>
);
}

renderAddBlockSeparator() {
return (
<View style={ styles.containerStyleAddHere } >
<View style={ styles.lineStyleAddHere }></View>
<Text style={ styles.labelStyleAddHere } >{ __( 'ADD BLOCK HERE' ) }</Text>
<View style={ styles.lineStyleAddHere }></View>
</View>
);
}

renderHTML() {
return (
<HTMLTextInput { ...this.props } parentHeight={ this.props.rootViewHeight } />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { View, Dimensions } from 'react-native';
*/
import styles from './style.scss';

const ReadableContentView = ( { children } ) => (
const ReadableContentView = ( { reversed, children } ) => (
<View style={ styles.container } >
<View style={ styles.centeredContent } >
<View style={ reversed ? styles.reversedCenteredContent : styles.centeredContent } >
{ children }
</View>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@
width: 100%;
max-width: 580;
}

.reversedCenteredContent {
flex-direction: column-reverse;
width: 100%;
max-width: 580;
}

0 comments on commit 56de120

Please sign in to comment.