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

Chrome: Adding the post external link component #971

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions editor/modes/text-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Textarea from 'react-autosize-textarea';
*/
import './style.scss';
import PostTitle from '../../post-title';
import PostExternalLink from '../../post-external-link';
import { getBlocks } from '../../selectors';

function TextEditor( { blocks, onChange } ) {
Expand All @@ -32,6 +33,7 @@ function TextEditor( { blocks, onChange } ) {
</div>
</header>
<div className="editor-text-editor__body">
<PostExternalLink />
<PostTitle />
<Textarea
autoComplete="off"
Expand Down
1 change: 1 addition & 0 deletions editor/modes/text-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@

/* Use padding to center text in the textarea, this allows you to click anywhere to focus it */
.editor-text-editor {
position: relative;
padding-left: 20px;
padding-right: 20px;

Expand Down
2 changes: 2 additions & 0 deletions editor/modes/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import './style.scss';
import Inserter from '../../inserter';
import VisualEditorBlockList from './block-list';
import PostTitle from '../../post-title';
import PostExternalLink from '../../post-external-link';

export default function VisualEditor() {
return (
Expand All @@ -18,6 +19,7 @@ export default function VisualEditor() {
aria-label={ __( 'Visual Editor' ) }
className="editor-visual-editor"
>
<PostExternalLink />
<PostTitle />
<VisualEditorBlockList />
<Inserter position="top right" />
Expand Down
1 change: 1 addition & 0 deletions editor/modes/visual-editor/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.editor-visual-editor {
position: relative;
margin: 0 auto;
padding: 50px 10px; /* Floating up/down arrows invisible */

Expand Down
38 changes: 38 additions & 0 deletions editor/post-external-link/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* External dependencies
*/
import { connect } from 'react-redux';

/**
* WordPress dependencies
*/
import { __ } from 'i18n';
import { IconButton } from 'components';

/**
* Internal dependencies
*/
import './style.scss';
import { getCurrentPost } from '../selectors';

function PostExternalLink( { link } ) {
if ( ! link ) {
return null;
}

return (
<IconButton
className="editor-post-external-link"
href={ link }
target="_blank"
icon="external"
title={ __( 'View Post' ) }
/>
);
}

export default connect(
( state ) => ( {
link: getCurrentPost( state ).link,
} )
)( PostExternalLink );
10 changes: 10 additions & 0 deletions editor/post-external-link/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.editor-post-external-link {
position: absolute;
top: 10px;
right: 10px;
color: $dark-gray-100;

.editor-text-editor & {
top: 47px;
}
}