-
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
Remove the name and element props from the TypographyPanel component #47908
Remove the name and element props from the TypographyPanel component #47908
Conversation
* | ||
* @return {Object} Merge of settings and supports. | ||
*/ | ||
export function overrideSettingsWithSupports( settings, supports ) { |
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.
The idea is that ultimately this function is going to allow us to merge "block.json" supports with "theme.json" settings "like" object.
} | ||
|
||
function useHasTextDecorationControl( name, element ) { | ||
const supports = useSupportedStyles( name, element ); | ||
return supports.includes( 'textDecoration' ); |
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.
Notice that the previous implementation of text transform didn't take into consideration the "setting" value that comes from theme.json. I think this is an inconsistency and probably something that was "forgotten". So in that sense, the current PR changes the behavior a bit but I believe it's better anyway.
@@ -52,52 +39,38 @@ export function useHasTypographyPanel( name, element, settings ) { | |||
); | |||
} | |||
|
|||
function useHasFontSizeControl( name, element, settings ) { | |||
const supports = useSupportedStyles( name, element ); |
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.
Now this function is only called once for the "TypographyPanel" rendering, there might be a small perf improvement here (very hard to measure). I believe this addresses one of the points raised by @jorgefilipecosta in the original PR.
@@ -48,33 +52,59 @@ function TypographyInspectorControl( { children } ) { | |||
); | |||
} | |||
|
|||
function useBLockSettings( name ) { |
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.
While right now, this function is "adhoc" in the "typography" hook. I believe this can be one big unique function that "builds" this object per block and make it available for all hooks... in the BlockEditContext
or something like that.
baa5460
to
6b61f3d
Compare
Flaky tests detected in 21802dc. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4182078371
|
Size Change: +131 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
6b61f3d
to
df46199
Compare
df46199
to
732e14e
Compare
5688236
to
15317d7
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.
LGTM 👍
}; | ||
} | ||
|
||
if ( ! supports.includes( 'lineHeight' ) ) { |
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.
Minor: All the rules from now on could be replaced with a single forEach loop:
[ 'lineHeight', 'fontStyle', ....].forEach(...)
Builds on top of #47356
What?
This continues the work to bring clarity to our code base and define a clear mental model for Global Styles UI and Block Inspector.
In this particular PR, I'm removing the "block name" and "element" props from the TypographyPanel component (Style UI component) in favor of the existing "settings" prop. In other words, The mental model becomes as such:
For an inspector control:
For the global styles panel:
Why?
All the reasoning and specifications for this work is in the following discussion #37064
Testing Instructions
Make sure to test that the style style panels are shown in block inspectors and global styles UI between this branch and trunk.