-
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
ToolsPanel: Update typography panel layout #35911
Conversation
Size Change: +46 B (0%) Total Size: 1.08 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.
export default function LetterSpacingControl( { | ||
value, | ||
onChange, | ||
withMaxWidth = true, |
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 imagine this kind of thing will be a common need and I'm not sure that exposing a new prop like withMaxWidth
is a pattern we want to adopt widely. Would it be safer (i.e. more conservative) for now to simply expose __unstableInputWidth
and pass that down to UnitControl
? Then a consumer can override it with a falsy value.
withMaxWidth = true, | |
__unstableInputWidth = '60px', |
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.
Thanks @mirka, I wasn't sure about passing through the unstable prop. I do like that approach better so have pushed the suggested change.
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.
This works as advertised for me - got same results as Staci in block settings and global styles
This makes the letter-spacing control span a single layout and allow the field to stretch full width within that column.
ed7e6f2
to
9fd5385
Compare
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.
A bit late to the party, but I left a couple of comments that may require a follow-up PR :)
* @param {Object} props Component props. | ||
* @param {string} props.value Currently selected letter-spacing. | ||
* @param {Function} props.onChange Handles change in letter-spacing selection. | ||
* @param {boolean} props.__unstableInputWidth Input width to pass through to inner UnitControl. |
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.
By looking at https://github.com/WordPress/gutenberg/blob/0160b7f1ccdc806a64eb111b36b4fd9c328ad49a/packages/components/src/input-control/types.ts, it seems like this prop should be of type string | number | undefined
(and not boolean
) — is this on purpose?
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've created follow-up PR to address this: #36367.
To correct the boolean
type here but still override the default I needed to use null
. For backwards compatibility, we need to provide a default width so setting the __unstableWidth
prop to undefined
doesn't work when wishing to restore full width to the control under the Typography ToolsPanel
.
@@ -45,6 +45,7 @@ export function LetterSpacingEdit( props ) { | |||
<LetterSpacingControl | |||
value={ style?.typography?.letterSpacing } | |||
onChange={ onChange } | |||
__unstableInputWidth={ false } |
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.
Similarly, I'm not sure if passing false
is correct here?
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've switched this to null
instead to override the default width required for backwards compatibility purposes.
Depends on:
Related:
Description
The
ToolsPanel
originally relied upon providing a hardcodedsingle-column
class name to allow tools panel items to have an easy and consistent means of applying styles to span a single column.The
single-column
class will be removed as part of #35621 which updates theToolsPanel
to use theGrid
component to handle its layout internally.This PR updates the Typography panel styles to handle this. It also tweaks the block editor's letter spacing control to allow opting out of the
max-width
so that it fills a column in theToolsPanel
as per other controls.How has this been tested?
Screenshots
Types of changes
Enhancement. Bug fix.
Checklist:
*.native.js
files for terms that need renaming or removal).