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

Move "continue writing" next to inserter and show on hover. #1553

Merged
merged 4 commits into from
Jun 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 42 additions & 11 deletions editor/modes/visual-editor/block-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import { throttle, reduce, noop } from 'lodash';
import { __ } from 'i18n';
import { Component } from 'element';
import { serialize, getDefaultBlock, createBlock } from 'blocks';
import { Dashicon } from 'components';
import { ENTER } from 'utils/keycodes';

/**
* Internal dependencies
*/
import VisualEditorBlock from './block';
import Inserter from '../../inserter';
import {
getBlockUids,
getBlockInsertionPoint,
Expand Down Expand Up @@ -191,8 +193,19 @@ class VisualEditorBlockList extends Component {
this.props.onInsertBlock( newBlock );
}

insertBlock( name ) {
const newBlock = createBlock( name );
this.props.onInsertBlock( newBlock );
}

render() {
const { blocks, showInsertionPoint, insertionPoint, multiSelectedBlockUids } = this.props;
const {
blocks,
showInsertionPoint,
insertionPoint,
multiSelectedBlockUids,
} = this.props;

const insertionPointIndex = blocks.indexOf( insertionPoint );
const blocksWithInsertionPoint = showInsertionPoint
? [
Expand Down Expand Up @@ -224,16 +237,34 @@ class VisualEditorBlockList extends Component {
/>
);
} ) }

<input
type="text"
readOnly
className="editor-visual-editor__placeholder"
value={ ! blocks.length ? __( 'Write your story' ) : __( 'Continue writing…' ) }
onFocus={ ! blocks.length ? this.appendDefaultBlock : noop }
onClick={ !! blocks.length ? this.appendDefaultBlock : noop }
onKeyDown={ !! blocks.length ? this.onPlaceholderKeyDown : noop }
/>
{ ! blocks.length &&
<input
type="text"
readOnly
className="editor-visual-editor__placeholder"
value={ __( 'Write your story' ) }
onFocus={ this.appendDefaultBlock }
onClick={ noop }
onKeyDown={ noop }
/>
}
<div className="editor-visual-editor__continue-writing">
<Inserter position="top right" />
<button
className="editor-inserter__block"
onClick={ () => this.insertBlock( 'core/text' ) }
>
<Dashicon icon="text" />
{ __( 'Text' ) }
</button>
<button
className="editor-inserter__block"
onClick={ () => this.insertBlock( 'core/image' ) }
>
<Dashicon icon="format-image" />
{ __( 'Image' ) }
</button>
</div>
</div>
);
}
Expand Down
2 changes: 0 additions & 2 deletions editor/modes/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { CHAR_A } from 'utils/keycodes';
* Internal dependencies
*/
import './style.scss';
import Inserter from '../../inserter';
import VisualEditorBlockList from './block-list';
import PostTitle from '../../post-title';
import { getBlockUids } from '../../selectors';
Expand Down Expand Up @@ -80,7 +79,6 @@ class VisualEditor extends Component {
>
<PostTitle />
<VisualEditorBlockList ref={ this.bindBlocksContainer } />
<Inserter position="top right" />
</div>
);
/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/onclick-has-role, jsx-a11y/click-events-have-key-events */
Expand Down
18 changes: 18 additions & 0 deletions editor/modes/visual-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,21 @@ $sticky-bottom-offset: 20px;
outline: 1px solid $light-gray-500;
}
}

.editor-visual-editor__continue-writing {
display: flex;
align-items: baseline;

.editor-inserter__block {
opacity: 0;
transition: opacity 150ms;
margin: 0 10px;
width: auto;
font-family: $default-font;
font-size: $default-font-size;
}
&:hover .editor-inserter__block,
&:focus .editor-inserter__block {
opacity: 1;
}
}