diff --git a/packages/block-editor/src/hooks/background.js b/packages/block-editor/src/hooks/background.js index 4554c150a1529a..4c2849eb8cef2b 100644 --- a/packages/block-editor/src/hooks/background.js +++ b/packages/block-editor/src/hooks/background.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + /** * WordPress dependencies */ @@ -5,7 +10,6 @@ import { isBlobURL } from '@wordpress/blob'; import { getBlockSupport } from '@wordpress/blocks'; import { __experimentalToolsPanelItem as ToolsPanelItem, - Button, DropZone, FlexItem, MenuItem, @@ -25,8 +29,6 @@ import { getFilename } from '@wordpress/url'; */ import InspectorControls from '../components/inspector-controls'; import MediaReplaceFlow from '../components/media-replace-flow'; -import MediaUpload from '../components/media-upload'; -import MediaUploadCheck from '../components/media-upload/check'; import useSetting from '../components/use-setting'; import { cleanEmptyObject } from './utils'; import { store as blockEditorStore } from '../store'; @@ -103,7 +105,12 @@ function InspectorImagePreview( { label, filename, url: imgUrl } ) { { imgUrl && ( @@ -123,11 +130,13 @@ function InspectorImagePreview( { label, filename, url: imgUrl } ) { { imgLabel } - { sprintf( - /* translators: %s: file name */ - __( 'Selected image: %s' ), - filename - ) } + { filename + ? sprintf( + /* translators: %s: file name */ + __( 'Selected image: %s' ), + filename + ) + : __( 'No image selected' ) } @@ -243,55 +252,29 @@ function BackgroundImagePanelItem( props ) { panelId={ clientId } >
- { !! url && ( - - } - variant="secondary" - > - resetBackgroundImage( props ) } - > - { __( 'Reset ' ) } - - - ) } - { ! url && ( - - ( -
- - -
- ) } + -
- ) } + } + variant="secondary" + > + resetBackgroundImage( props ) }> + { __( 'Reset ' ) } + + +
); diff --git a/packages/block-editor/src/hooks/background.scss b/packages/block-editor/src/hooks/background.scss index a42679bfe27226..a81b6acfce2de7 100644 --- a/packages/block-editor/src/hooks/background.scss +++ b/packages/block-editor/src/hooks/background.scss @@ -1,14 +1,11 @@ -.block-editor-hooks__background__inspector-upload-container { +.block-editor-hooks__background__inspector-media-replace-container { position: relative; // Since there is no option to skip rendering the drag'n'drop icon in drop // zone, we hide it for now. .components-drop-zone__content-icon { display: none; } -} -.block-editor-hooks__background__inspector-upload-container, -.block-editor-hooks__background__inspector-media-replace-container { button.components-button { color: $gray-900; box-shadow: inset 0 0 0 $border-width $gray-300; @@ -34,9 +31,7 @@ text-align: start; text-align-last: center; } -} -.block-editor-hooks__background__inspector-media-replace-container { .components-dropdown { display: block; } @@ -50,6 +45,10 @@ width: 20px; height: 20px; flex: none; + + &.has-image { + background: #fff; // No diagonal line for non-empty background image. A background color is in use to account for partially transparent images. + } } .block-editor-hooks__background__inspector-image-indicator {