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

Add descriptive text and a link to embed documentation in embed blocks #16101

Merged
merged 4 commits into from
Jun 12, 2019
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
4 changes: 4 additions & 0 deletions packages/block-library/src/embed/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
.components-placeholder__error {
word-break: break-word;
}

.components-placeholder__learn-more {
margin-top: 1em;
}
}

.block-library-embed__interactive-overlay {
Expand Down
14 changes: 12 additions & 2 deletions packages/block-library/src/embed/embed-placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
* WordPress dependencies
*/
import { __, _x } from '@wordpress/i18n';
import { Button, Placeholder } from '@wordpress/components';
import { Button, Placeholder, ExternalLink } from '@wordpress/components';
import { BlockIcon } from '@wordpress/block-editor';

const EmbedPlaceholder = ( props ) => {
const { icon, label, value, onSubmit, onChange, cannotEmbed, fallback, tryAgain } = props;
return (
<Placeholder icon={ <BlockIcon icon={ icon } showColors /> } label={ label } className="wp-block-embed">
<Placeholder
icon={ <BlockIcon icon={ icon } showColors /> }
label={ label }
className="wp-block-embed"
instructions={ __( 'Paste a link to the content you want to display on your site.' ) }
>
<form onSubmit={ onSubmit }>
<input
type="url"
Expand All @@ -29,6 +34,11 @@ const EmbedPlaceholder = ( props ) => {
</p>
}
</form>
<div className="components-placeholder__learn-more">
<ExternalLink href={ __( 'https://wordpress.org/support/article/embeds/' ) }>
{ __( 'Learn more about embeds' ) }
</ExternalLink>
</div>
</Placeholder>
);
};
Expand Down
36 changes: 36 additions & 0 deletions packages/block-library/src/embed/test/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ exports[`core/embed block edit matches snapshot 1`] = `
</span>
Embed URL
</div>
<div
class="components-placeholder__instructions"
>
Paste a link to the content you want to display on your site.
</div>
<div
class="components-placeholder__fieldset"
>
Expand All @@ -45,6 +50,37 @@ exports[`core/embed block edit matches snapshot 1`] = `
Embed
</button>
</form>
<div
class="components-placeholder__learn-more"
>
<a
class="components-external-link"
href="https://wordpress.org/support/article/embeds/"
rel="external noreferrer noopener"
target="_blank"
>
Learn more about embeds
<span
class="screen-reader-text"
>
(opens in a new tab)
</span>
<svg
aria-hidden="true"
class="dashicon dashicons-external components-external-link__icon"
focusable="false"
height="20"
role="img"
viewBox="0 0 20 20"
width="20"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9 3h8v8l-2-1V6.92l-5.6 5.59-1.41-1.41L14.08 5H10zm3 12v-3l2-2v7H3V6h8L9 8H5v7h7z"
/>
</svg>
</a>
</div>
</div>
</div>
`;