ToolsPanel: Update typography panel layout#35911
Conversation
|
Size Change: +46 B (0%) Total Size: 1.08 MB
ℹ️ View Unchanged
|
| export default function LetterSpacingControl( { | ||
| value, | ||
| onChange, | ||
| withMaxWidth = true, |
There was a problem hiding this comment.
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.
Thanks @mirka, I wasn't sure about passing through the unstable prop. I do like that approach better so have pushed the suggested change.
glendaviesnz
left a comment
There was a problem hiding this comment.
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
ciampo
left a comment
There was a problem hiding this comment.
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.
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.
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.
| <LetterSpacingControl | ||
| value={ style?.typography?.letterSpacing } | ||
| onChange={ onChange } | ||
| __unstableInputWidth={ false } |
There was a problem hiding this comment.
Similarly, I'm not sure if passing false is correct here?
There was a problem hiding this comment.
I've switched this to null instead to override the default width required for backwards compatibility purposes.


Depends on:
Related:
Description
The
ToolsPaneloriginally relied upon providing a hardcodedsingle-columnclass name to allow tools panel items to have an easy and consistent means of applying styles to span a single column.The
single-columnclass will be removed as part of #35621 which updates theToolsPanelto use theGridcomponent 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-widthso that it fills a column in theToolsPanelas per other controls.How has this been tested?
Screenshots
Types of changes
Enhancement. Bug fix.
Checklist:
*.native.jsfiles for terms that need renaming or removal).