-
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
Fix: Button: Replace remaining 40px default size violation [Block library] #65075
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. |
@@ -310,8 +310,7 @@ const LinkUITools = ( { setAddingBlock, focusAddBlockButton } ) => { | |||
return ( | |||
<VStack className="link-ui-tools"> | |||
<Button | |||
// TODO: Switch to `true` (40px size) if possible | |||
__next40pxDefaultSize={ false } | |||
__next40pxDefaultSize |
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.
@@ -16,8 +16,7 @@ function DeletedNavigationWarning( { onCreateNew } ) { | |||
{ | |||
button: ( | |||
<Button | |||
// TODO: Switch to `true` (40px size) if possible | |||
__next40pxDefaultSize={ false } | |||
__next40pxDefaultSize |
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 can be seen when you use navigation ref which is deleted or not present.
Also, this is kind of link which uses button component, but it has some overridden styles, so there would not be any effect on button. Still we have updated component to use default size, in future if specific styles get's removed, we have default 40px
being applied.
Before | After |
---|---|
@@ -591,8 +591,7 @@ function Navigation( { | |||
{ isResponsive && ( | |||
<> | |||
<Button | |||
// TODO: Switch to `true` (40px size) if possible | |||
__next40pxDefaultSize={ false } | |||
__next40pxDefaultSize |
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.
We're going to need to preserve this height override. I think we'll need to add an !important
here.
height: $grid-unit-40 * 2; |
Aside: @WordPress/gutenberg-components This is already the second time I'm seeing a height override like this that requires an additional !important
(first time was #65068 (comment)). I'm tempted to decrease the specificity of the rule (to &:where( .is-next-40px-default-size )
), but I think we shouldn't because:
- It could cause style regressions in existing usages.
- The 40px opt-in prop (and thus the CSS class) is temporary.
- If custom Button height like this is a legitimate design requirement, maybe it should be supported officially?
gutenberg/packages/components/src/button/style.scss
Lines 28 to 30 in 9523fb4
&.is-next-40px-default-size { | |
height: $button-size-next-default-40px; | |
} |
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.
We're going to need to preserve this height override. I think we'll need to add an !important here.
Thanks for this, would add !important
to override the 40px
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.
It's a tricky balance.
I lean on the side of not decreasing the specificity, especially since it's going to be removed soon anyway.
If custom Button height like this is a legitimate design requirement, maybe it should be supported officially?
I'm not sure that adding "one more variant" is a scalable solution.
Seeing how many heavily tweaked instances of Button
we're encountering, I would consider (as already discussed in the past) to introduce an "unstyled" variant of Button
, which would still benefit from the component's functionality (ie. tooltips, link vs button, focus styles, accessible when disabled, etc) but without any extra cosmetic changes applied (ie. no padding, margin, heighgits, etc).
Alternatively, we could expose a useButton
hook which does the same thing, and use if with vanilla <button />
elements.
@@ -19,8 +19,7 @@ export default function NavigationMenuDeleteControl( { onDelete } ) { | |||
return ( | |||
<> | |||
<Button | |||
// TODO: Switch to `true` (40px size) if possible | |||
__next40pxDefaultSize={ false } | |||
__next40pxDefaultSize |
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.
@@ -79,8 +79,7 @@ export default function ResponsiveWrapper( { | |||
<> | |||
{ ! isOpen && ( | |||
<Button | |||
// TODO: Switch to `true` (40px size) if possible | |||
__next40pxDefaultSize={ false } | |||
__next40pxDefaultSize |
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 can be seen, while you add navigation and add the overlay menu icon to mobile or always show.
Note: For this we have some overriding styles on the icon itself, so it would not have before and after change, but we can see that this change have added our 40px change, so in future if overriding styles is removed, we have default 40px of size.
Before | After |
---|---|
@@ -102,8 +101,7 @@ export default function ResponsiveWrapper( { | |||
> | |||
<div { ...dialogProps }> | |||
<Button | |||
// TODO: Switch to `true` (40px size) if possible | |||
__next40pxDefaultSize={ false } | |||
__next40pxDefaultSize |
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 can be seen, while you add navigation and add the overlay menu icon to mobile or always show, and open the menu by click on overlay icon, you can see the close icon.
Note: For this we have some overriding styles on the icon itself, so it would not have before and after change, but we can see that this change have added our 40px change, so in future if overriding styles is removed, we have default 40px of size.
Before | After |
---|---|
@@ -76,8 +76,7 @@ export default function NavigationPlaceholder( { | |||
|
|||
{ canUserCreateNavigationMenus && ( | |||
<Button | |||
// TODO: Switch to `true` (40px size) if possible | |||
__next40pxDefaultSize={ false } | |||
__next40pxDefaultSize |
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 haven't being able to identify this change visually on the site, because the main component, NavigationPlaceholder
is exported, but is not used anywhere in entire repository, Ref - https://github.com/search?q=repo%3AWordPress%2Fgutenberg%20export%20default%20function%20NavigationPlaceholder(&type=code,
It is being used here -
export default function NavigationPlaceholder( { |
@mirka, Can you please verify this.
Thank You,
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.
Yes, it doesn't seem to be used anymore 👍
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 for confirmation 👍.
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's one issue we need to fix in the Navigation block inspector, but everything else looks good. Thank you!
@@ -591,8 +591,7 @@ function Navigation( { | |||
{ isResponsive && ( | |||
<> | |||
<Button | |||
// TODO: Switch to `true` (40px size) if possible | |||
__next40pxDefaultSize={ false } | |||
__next40pxDefaultSize |
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.
We're going to need to preserve this height override. I think we'll need to add an !important
here.
height: $grid-unit-40 * 2; |
Aside: @WordPress/gutenberg-components This is already the second time I'm seeing a height override like this that requires an additional !important
(first time was #65068 (comment)). I'm tempted to decrease the specificity of the rule (to &:where( .is-next-40px-default-size )
), but I think we shouldn't because:
- It could cause style regressions in existing usages.
- The 40px opt-in prop (and thus the CSS class) is temporary.
- If custom Button height like this is a legitimate design requirement, maybe it should be supported officially?
gutenberg/packages/components/src/button/style.scss
Lines 28 to 30 in 9523fb4
&.is-next-40px-default-size { | |
height: $button-size-next-default-40px; | |
} |
@@ -76,8 +76,7 @@ export default function NavigationPlaceholder( { | |||
|
|||
{ canUserCreateNavigationMenus && ( | |||
<Button | |||
// TODO: Switch to `true` (40px size) if possible | |||
__next40pxDefaultSize={ false } | |||
__next40pxDefaultSize |
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.
Yes, it doesn't seem to be used anymore 👍
Hi @mirka, I have updated the PR with the requested changes. I have requested for re-review. Thank You, |
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, I appreciate you being proactive about adding a code comment!
…rary] (#65075) * Fix navigation-link block to use button to default 40px size * Fix navigation deleted create new menu button to use 40px default size * Fix navigation overlay menu icon button to use 40px default size * Fix the navigation menu delete button to use 40px default size button * Fix navigation placeholder start empty to use button as default 40px size * Fix responsive navigation overlay menu open button to use default 40px size * Fix navigation responsive close button to use 40px default size * Add the !important to override the overlay menu preview style Ref - WordPress/gutenberg#65075 (comment) * Refactor the comment for the !important style Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Source: WordPress/gutenberg@219be48
…rary] (#65075) * Fix navigation-link block to use button to default 40px size * Fix navigation deleted create new menu button to use 40px default size * Fix navigation overlay menu icon button to use 40px default size * Fix the navigation menu delete button to use 40px default size button * Fix navigation placeholder start empty to use button as default 40px size * Fix responsive navigation overlay menu open button to use default 40px size * Fix navigation responsive close button to use 40px default size * Add the !important to override the overlay menu preview style Ref - WordPress/gutenberg#65075 (comment) * Refactor the comment for the !important style Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Source: WordPress/gutenberg@219be48
…rary] (#65075) * Fix navigation-link block to use button to default 40px size * Fix navigation deleted create new menu button to use 40px default size * Fix navigation overlay menu icon button to use 40px default size * Fix the navigation menu delete button to use 40px default size button * Fix navigation placeholder start empty to use button as default 40px size * Fix responsive navigation overlay menu open button to use default 40px size * Fix navigation responsive close button to use 40px default size * Add the !important to override the overlay menu preview style Ref - WordPress/gutenberg#65075 (comment) * Refactor the comment for the !important style Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Source: WordPress/gutenberg@219be48
Part of - #65018
What?
core/navigation
andcore/navigation-link
.Why?
How?
__next40pxDefaultSize={ false }
to__next40pxDefaultSize
on component.Testing Instructions