-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: Let Featured Image block inherit dimensions, look like a placeholder #36517
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,137 @@ | ||
div[data-type="core/post-featured-image"] { | ||
img { | ||
max-width: 100%; | ||
height: auto; | ||
display: block; | ||
// Give the featured image placeholder the appearance of a literal image placeholder. | ||
// @todo: this CSS is similar to that of the Site Logo. That makes it an opportunity | ||
// to create a new component for placeholders meant to inherit some theme styles. | ||
.wp-block-post-featured-image.wp-block-post-featured-image { | ||
// Inherit border radius from style variations. | ||
.components-placeholder, | ||
.components-resizable-box__container { | ||
border-radius: inherit; | ||
} | ||
} | ||
|
||
.editor-styles-wrapper { | ||
.post-featured-image_placeholder { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These styles were actually dead, and didn't target anything. |
||
display: flex; | ||
flex-direction: row; | ||
// Style the placeholder. | ||
.wp-block-post-featured-image__placeholder, | ||
.components-placeholder { | ||
justify-content: center; | ||
align-items: center; | ||
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; | ||
box-shadow: none; | ||
padding: 0; | ||
|
||
// Hide the upload button, as it's also available in the media library. | ||
.components-form-file-upload { | ||
display: none; | ||
} | ||
|
||
// Position the spinner. | ||
.components-placeholder__preview { | ||
position: absolute; | ||
top: $grid-unit-05; | ||
right: $grid-unit-05; | ||
bottom: $grid-unit-05; | ||
left: $grid-unit-05; | ||
background: rgba($white, 0.8); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
// Draw the dashed outline. | ||
// By setting the dashed border to currentColor, we ensure it's visible | ||
// against any background color. | ||
color: currentColor; | ||
background: transparent; | ||
&::before { | ||
content: ""; | ||
display: block; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
border: $border-width dashed currentColor; | ||
opacity: 0.3; | ||
pointer-events: none; | ||
|
||
// Inherit border radius from style variations. | ||
border-radius: inherit; | ||
} | ||
|
||
// Style the upload button. | ||
.components-placeholder__fieldset { | ||
width: auto; | ||
} | ||
|
||
.components-button.components-button { | ||
color: inherit; | ||
padding: 0; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: $grid-unit-60; | ||
height: $grid-unit-60; | ||
border-radius: 50%; | ||
position: relative; | ||
visibility: hidden; | ||
|
||
// Animation. | ||
background: transparent; | ||
transition: all 0.1s linear; | ||
@include reduce-motion("transition"); | ||
} | ||
p { | ||
font-family: $default-font; | ||
font-size: $default-font-size; | ||
margin: 0; | ||
|
||
.components-button.components-button > svg { | ||
color: $white; | ||
} | ||
|
||
// Style the placeholder illustration. | ||
.components-placeholder__illustration { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
stroke: currentColor; | ||
stroke-dasharray: 3; | ||
opacity: 0.3; | ||
} | ||
|
||
// Show default placeholder height when not resized. | ||
min-height: 200px; | ||
} | ||
|
||
// Provide a minimum size for the placeholder when resized. | ||
// Note, this should be as small as we can afford it, and exists only | ||
// to ensure there's room for the upload button. | ||
&[style*="height"] .components-placeholder { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using this style we can override the default placeholder min-height with an explicit height as soon as one is applied to the container. |
||
min-height: $grid-unit-60; | ||
min-width: $grid-unit-60; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
// Show upload button on block selection. | ||
&.is-selected .components-button.components-button { | ||
background: var(--wp-admin-theme-color); | ||
border-color: var(--wp-admin-theme-color); | ||
border-style: solid; | ||
color: $white; | ||
opacity: 1; | ||
visibility: visible; | ||
} | ||
} | ||
|
||
div[data-type="core/post-featured-image"] { | ||
img { | ||
max-width: 100%; | ||
height: auto; | ||
display: block; | ||
} | ||
} | ||
|
||
.block-library-post-featured-image-dimension-controls { | ||
margin-bottom: $grid-unit-10; | ||
|
||
&.scale-control-is-visible { | ||
margin-bottom: $grid-unit-20; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of this code is copied verbatim from #35397, and suggests there is an opportunity to create a new component, such as
InheritingPlaceholder
(it'd need a better name), which comes with less content inside, usually just a single upload/media library button, minimal markup, and intentionally lets theme styles bleed in and affect it.It doesn't necessarily have to happen as part of this PR, but it seems worth tracking if this PR goes any further.