Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Add a Remove Image option to the Featured Category block (#5719)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcafferkey authored Feb 7, 2022
1 parent 271f04d commit cf78ba9
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions assets/js/blocks/featured-category/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { folderStarred } from '@woocommerce/icons';
import { Icon } from '@wordpress/icons';
import ProductCategoryControl from '@woocommerce/editor-components/product-category-control';
import ErrorPlaceholder from '@woocommerce/editor-components/error-placeholder';
import TextToolbarButton from '@woocommerce/editor-components/text-toolbar-button';

/**
* Internal dependencies
Expand Down Expand Up @@ -90,18 +91,29 @@ const FeaturedCategory = ( {
setAttributes( { contentAlign: nextAlign } );
} }
/>
<MediaReplaceFlow
mediaId={ mediaId }
mediaURL={ mediaSrc }
accept="image/*"
onSelect={ ( media ) => {
setAttributes( {
mediaId: media.id,
mediaSrc: media.url,
} );
} }
allowedTypes={ [ 'image' ] }
/>
<ToolbarGroup>
<MediaReplaceFlow
mediaId={ mediaId }
mediaURL={ mediaSrc }
accept="image/*"
onSelect={ ( media ) => {
setAttributes( {
mediaId: media.id,
mediaSrc: media.url,
} );
} }
allowedTypes={ [ 'image' ] }
/>
{ mediaId && mediaSrc ? (
<TextToolbarButton
onClick={ () =>
setAttributes( { mediaId: 0, mediaSrc: '' } )
}
>
{ __( 'Remove', 'woo-gutenberg-products-block' ) }
</TextToolbarButton>
) : null }
</ToolbarGroup>
<ToolbarGroup
controls={ [
{
Expand Down

0 comments on commit cf78ba9

Please sign in to comment.