Skip to content
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

Merged
merged 9 commits into from
Sep 6, 2024

Conversation

hbhalodia
Copy link
Contributor

Part of - #65018

What?

Why?

  • To make the consistent button across Gutenberg, and we would have a lint rule added once fixed, all the button usage.

How?

  • Change from __next40pxDefaultSize={ false } to __next40pxDefaultSize on component.

Testing Instructions

  • Add the blocks on the page/post and check for the buttons defined.
  • Screenshot is added for individual changed files.

@hbhalodia hbhalodia requested a review from ajitbohra as a code owner September 5, 2024 05:31
Copy link

github-actions bot commented Sep 5, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

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
Copy link
Contributor Author

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-link block and while you add the link.

Before After
navigation-link-before navigation-link-after

@@ -16,8 +16,7 @@ function DeletedNavigationWarning( { onCreateNew } ) {
{
button: (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
Copy link
Contributor Author

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
navigation-deleted-before navigation-deleted-after

@@ -591,8 +591,7 @@ function Navigation( {
{ isResponsive && (
<>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be seen on the inspector controls, when we add navigation block and we try to set overlay menu icon, refer to below screenshots.

Before After
navigation-overlay-before navigation-overlay-after

Copy link
Member

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.


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?

&.is-next-40px-default-size {
height: $button-size-next-default-40px;
}

Copy link
Contributor Author

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.

Copy link
Contributor

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
Copy link
Contributor Author

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 adding the navigation menu, going to inspector controls advanced tab, and check for Delete Menu button.

Before After
navigation-delete-before navigation-delete-after

@@ -79,8 +79,7 @@ export default function ResponsiveWrapper( {
<>
{ ! isOpen && (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
Copy link
Contributor Author

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
navigation-responsive-overlay-before navigation-responsive-after

@@ -102,8 +101,7 @@ export default function ResponsiveWrapper( {
>
<div { ...dialogProps }>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
Copy link
Contributor Author

@hbhalodia hbhalodia Sep 5, 2024

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
Resposnsive-close-before Responsive-close-after

@@ -76,8 +76,7 @@ export default function NavigationPlaceholder( {

{ canUserCreateNavigationMenus && (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
Copy link
Contributor Author

@hbhalodia hbhalodia Sep 5, 2024

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,

Copy link
Member

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 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirmation 👍.

@tyxla tyxla requested a review from a team September 5, 2024 12:31
@tyxla tyxla added the [Type] Code Quality Issues or PRs that relate to code quality label Sep 5, 2024
Copy link
Member

@mirka mirka left a 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
Copy link
Member

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.


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?

&.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
Copy link
Member

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 👍

@hbhalodia
Copy link
Contributor Author

Hi @mirka, I have updated the PR with the requested changes. I have requested for re-review.

Thank You,

@hbhalodia hbhalodia requested a review from mirka September 6, 2024 05:42
Copy link
Member

@mirka mirka left a 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!

@mirka mirka merged commit 219be48 into WordPress:trunk Sep 6, 2024
62 checks passed
@github-actions github-actions bot added this to the Gutenberg 19.3 milestone Sep 6, 2024
peterwilsoncc pushed a commit to peterwilsoncc/gutenberg-build that referenced this pull request Sep 11, 2024
…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
peterwilsoncc pushed a commit to peterwilsoncc/gutenberg-build that referenced this pull request Sep 12, 2024
…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
peterwilsoncc pushed a commit to peterwilsoncc/gutenberg-build that referenced this pull request Sep 13, 2024
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants