-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Cover: Update min-height control. #62742
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
id={ inputId } | ||
isResetValueOnUnitChange | ||
min={ min } | ||
onChange={ handleOnChange } | ||
onUnitChange={ onUnitChange } | ||
__unstableInputWidth="80px" | ||
__unstableInputWidth="calc(50% - 4px)" |
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.
Those 4px make up half the 8px gap that sits between width/height in the image block. There's a better way to do this, but is it this PR? I can also just type in 120px.
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.
I think that 8px may be incorrect 🙈
According to #46734 the gap between columns should be 16px. This is the case in the background size inputs:
Ideally we avoid a hard-coded value, just in case the inspector width changes in the future.
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.
Probably, there is a difference in the gap values between the two, so in the future it will be necessary to unify the gap rules.
ToolsPanel
has a gap value of 8px
(Source):
On the other hand, the FocalPointPicker
component has a gap value of 16px
(Source):
Which one should we unify it to? I would lean towards standardizing on 8px
.
By the way, width/height in the image block, grid-column: span 1
is applied:
gutenberg/packages/block-editor/src/components/dimensions-tool/width-height-tool.js
Lines 15 to 17 in 0384b0e
const SingleColumnToolsPanelItem = styled( ToolsPanelItem )` | |
grid-column: span 1; | |
`; |
Therefore, I think the following approach is also possible:
Details
diff --git a/packages/block-library/src/cover/edit/inspector-controls.js b/packages/block-library/src/cover/edit/inspector-controls.js
index 39dd425c62..65c32fd526 100644
--- a/packages/block-library/src/cover/edit/inspector-controls.js
+++ b/packages/block-library/src/cover/edit/inspector-controls.js
@@ -79,7 +79,6 @@ function CoverHeightInput( {
min={ min }
onChange={ handleOnChange }
onUnitChange={ onUnitChange }
- __unstableInputWidth="calc(50% - 4px)"
units={ units }
value={ computedValue }
size="__unstable-large"
@@ -314,6 +313,7 @@ export default function CoverInspectorControls( {
} ) }
isShownByDefault
panelId={ clientId }
+ style={ { gridColumn: 'span 1' } }
>
<CoverHeightInput
value={
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.
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.
I noticed that there is a style for a single column of the dimension panel:
Since the min-height control is also part of the dimension panel, we should be able to make the following changes to this PR:
diff --git a/packages/block-library/src/cover/edit/inspector-controls.js b/packages/block-library/src/cover/edit/inspector-controls.js
index 39dd425c62..80110d5158 100644
--- a/packages/block-library/src/cover/edit/inspector-controls.js
+++ b/packages/block-library/src/cover/edit/inspector-controls.js
@@ -79,7 +79,6 @@ function CoverHeightInput( {
min={ min }
onChange={ handleOnChange }
onUnitChange={ onUnitChange }
- __unstableInputWidth="calc(50% - 4px)"
units={ units }
value={ computedValue }
size="__unstable-large"
@@ -300,6 +299,7 @@ export default function CoverInspectorControls( {
) }
<InspectorControls group="dimensions">
<ToolsPanelItem
+ className="single-column"
hasValue={ () => !! minHeight }
label={ __( 'Minimum height' ) }
onDeselect={ () =>
The width value is not hard-coded, so when the ToolsPanel
gap changes from 8px
to 16px
, we don't need to update the min-height control's style.
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.
Size Change: +131 B (+0.01%) Total Size: 1.76 MB
ℹ️ View Unchanged
|
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.
LGTM!
I think E2E tests will fail, but that's another issue in the core, see the link below.
WordPress/wordpress-develop#6875 (comment)
https://wordpress.slack.com/archives/C02QB2JS7/p1719209877579299
I'm not sure whether to force merge this PR or not, but let's wait a bit.
Thank you for the review and the context. I think the ship has sailed for this to be a backport, though, so there's no rush on force merging. |
@jasmussen I had created PR to implement range slider for height control of cover block. Is this still relevant? please let me know. |
@akasunil Sorry, I missed that. I think that's still relevant, yes. I think if you can include the title change from this PR, perhaps I can close mine in favor of yours? |
Yes, I have updated title too. Screenshot is old one, ill update it. |
Closing this one in favor of #62509. |
What?
The Cover block has a min-height control using legacy input size, and a label, "Minimum height of cover", redundant since it's only ever showin inside the inspector for the cover block:
This PR updates the input to be the new default size, and larger unit selector, and changes the label to read "Minimum height":
For comparison, here's the image width/height controls:
Testing Instructions
Insert a cover block, test the min-height inspector control.