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

Show PostFeaturedImage in editor #25412

Merged
merged 3 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
add placeholder chip
  • Loading branch information
ntsekouras committed Sep 29, 2020
commit 1b181f1b530d4e0d1b3f5b7d08c685f1bc6b91a6
1 change: 1 addition & 0 deletions packages/block-library/src/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
@import "./widget-area/editor.scss";
@import "./query-loop/editor.scss";
@import "./query/editor.scss";
@import "./post-featured-image/editor.scss";

/**
* Import styles from internal editor components used by the blocks.
Expand Down
10 changes: 8 additions & 2 deletions packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
*/
import { useEntityProp } from '@wordpress/core-data';
import { useSelect } from '@wordpress/data';
import { ResponsiveWrapper } from '@wordpress/components';
import { ResponsiveWrapper, Icon } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { postFeaturedImage as icon } from '@wordpress/icons';

function PostFeaturedImageDisplay( { context: { postId, postType } } ) {
const [ featuredImage ] = useEntityProp(
Expand All @@ -19,7 +20,12 @@ function PostFeaturedImageDisplay( { context: { postId, postType } } ) {
[ featuredImage ]
);
if ( ! media ) {
return __( 'No Featured Image is set' );
return (
<div className="post-featured-image_placeholder">
<Icon icon={ icon } />
<p> { __( 'Featured Image' ) }</p>
</div>
);
}
const alt = media.alt_text || __( 'No alternative text set' );
return (
Expand Down
19 changes: 19 additions & 0 deletions packages/block-library/src/post-featured-image/editor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
div[data-type="core/post-featured-image"] {
.post-featured-image_placeholder {
display: flex;
flex-direction: row;
align-items: flex-start;
border-radius: $radius-block-ui;
background-color: $white;
box-shadow: inset 0 0 0 $border-width $gray-900;
padding: $grid-unit-15;
svg {
margin-right: $grid-unit-15;
}
p {
font-family: $default-font;
font-size: $default-font-size;
margin: 0;
}
}
}