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

Try to improve featured image style and accessibility #3829

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
41 changes: 29 additions & 12 deletions editor/components/post-featured-image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import { getCurrentPostType, getEditedPostAttribute } from '../../selectors';
import { editPost } from '../../actions';

//used when labels from post tyoe were not yet loaded or when they are not present.
const DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Set featured image' );
const DEFAULT_REMOVE_FEATURE_IMAGE_LABEL = __( 'Remove featured image' );
const DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'No image selected' );
const DEFAULT_ADD_FEATURE_IMAGE_LABEL = __( 'Add Image' );
const DEFAULT_REMOVE_FEATURE_IMAGE_LABEL = __( 'Remove Image' );
const DEFAULT_REPLACE_FEATURE_IMAGE_LABEL = __( 'Replace Image' );

function PostFeaturedImage( { featuredImageId, onUpdateImage, onRemoveImage, media, postType } ) {
const postLabel = get( postType, 'data.labels', {} );
Expand All @@ -30,7 +32,7 @@ function PostFeaturedImage( { featuredImageId, onUpdateImage, onRemoveImage, med
{ !! featuredImageId &&
<MediaUploadButton
title={ postLabel.set_featured_image }
buttonProps={ { className: 'button-link editor-post-featured-image__preview' } }
buttonProps={ { className: 'editor-post-featured-image__preview' } }
onSelect={ onUpdateImage }
type="image"
>
Expand All @@ -46,22 +48,37 @@ function PostFeaturedImage( { featuredImageId, onUpdateImage, onRemoveImage, med
</MediaUploadButton>
}
{ !! featuredImageId && media && ! media.isLoading &&
<p className="editor-post-featured-image__howto">
{ __( 'Click the image to edit or update' ) }
</p>
}
{ ! featuredImageId &&
<MediaUploadButton
title={ postLabel.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL }
buttonProps={ { className: 'editor-post-featured-image__toggle button-link' } }
title={ postLabel.set_featured_image }
buttonProps={ { className: 'button' } }
onSelect={ onUpdateImage }
type="image"
>
{ postLabel.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL }
{ postLabel.set_featured_image || DEFAULT_REPLACE_FEATURE_IMAGE_LABEL }
</MediaUploadButton>
}
{ ! featuredImageId &&
<div>
<MediaUploadButton
title={ postLabel.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL }
buttonProps={ { className: 'editor-post-featured-image__toggle' } }
onSelect={ onUpdateImage }
type="image"
>
{ postLabel.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL }
</MediaUploadButton>
<MediaUploadButton
title={ postLabel.set_featured_image || DEFAULT_ADD_FEATURE_IMAGE_LABEL }
buttonProps={ { className: 'button' } }
onSelect={ onUpdateImage }
type="image"
>
{ postLabel.set_featured_image || DEFAULT_ADD_FEATURE_IMAGE_LABEL }
</MediaUploadButton>
</div>
}
{ !! featuredImageId &&
<Button className="editor-post-featured-image__toggle button-link" onClick={ onRemoveImage }>
<Button className="button" onClick={ onRemoveImage }>
{ postLabel.remove_featured_image || DEFAULT_REMOVE_FEATURE_IMAGE_LABEL }
</Button>
}
Expand Down
27 changes: 14 additions & 13 deletions editor/components/post-featured-image/style.scss
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
.editor-post-featured-image {
padding: 10px 0 0;
padding: 0;

.spinner {
margin: 0;
}
}

.editor-post-featured-image__toggle {
text-decoration: underline;
color: $blue-wordpress;

&:focus {
box-shadow: none;
outline: none;
}

&:hover {
color: $blue-medium-500;
.button {
margin: 0 8px 8px 0;
}
}

.editor-post-featured-image__toggle,
.editor-post-featured-image__preview {
display: block;
width: 100%;
margin-bottom: 1em;
padding: 0;
}

.editor-post-featured-image__toggle {
border: 1px dashed $light-gray-900;
background-color: $light-gray-300;
line-height: 20px;
padding: $item-spacing 0;
text-align: center;
}

.editor-post-featured-image__howto {
Expand Down