Skip to content

Commit

Permalink
Add back the legacy placeholder.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmussen committed Aug 17, 2022
1 parent 306d178 commit 814fa5f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
6 changes: 6 additions & 0 deletions packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ import { image as icon } from '@wordpress/icons';
*/
import Image from './image';

// Much of this description is duplicated from MediaPlaceholder.
const placeholder = ( content ) => {
return (
<Placeholder
className="block-editor-media-placeholder"
withIllustration={ true }
icon={ icon }
label={ __( 'Image' ) }
instructions={ __(
'Upload an image file, pick one from your media library, or add one with a URL.'
) }
>
{ content }
</Placeholder>
Expand Down
22 changes: 10 additions & 12 deletions packages/block-library/src/image/editor.scss
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
// Provide special styling for the placeholder.
// @todo: this particular minimal style of placeholder could be componentized further.
.wp-block-image.wp-block-image {
// Show custom Placeholder style on-select.
// Show Placeholder style on-select.
&.is-selected .components-placeholder {
// Block UI appearance.
color: $gray-900;
background-color: $white;
box-shadow: inset 0 0 0 $border-width $gray-900;
border: none;
justify-content: center;
align-items: center;

// @todo: this should eventually be overridden by a custom border-radius set in the inspector.
border-radius: $radius-block-ui;

.components-placeholder__fieldset {
gap: $grid-unit-15;
}

.components-button {
margin: 0;
}

> svg {
opacity: 0;
visibility: hidden;
}
}

// Remove the transition while we still have a legacy placeholder style.
// Otherwise the content jumps between the 1px placeholder border, and any inherited custom
// parent border that may get applied when you deselect.
.components-placeholder__label,
.components-placeholder__instructions,
.components-button {
transition: none;
}
}


Expand Down
10 changes: 8 additions & 2 deletions packages/components/src/placeholder/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,20 @@

// Show placeholder buttons on block selection.
// Note that these can't be display: none; or visibility: hidden;, as that breaks the writing flow.
.components-placeholder__label,
.components-placeholder__instructions,
.components-button {
opacity: 0;
transition: opacity 0.1s linear;
@include reduce-motion("transition");
}

.is-selected > & .components-button {
opacity: 1;
.is-selected > & {
.components-placeholder__label,
.components-placeholder__instructions,
.components-button {
opacity: 1;
}
}

// By painting the borders here, we enable them to be replaced by the Border control.
Expand Down

0 comments on commit 814fa5f

Please sign in to comment.