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 violations [Block Editor 2] #65308

Merged
merged 3 commits into from
Sep 26, 2024

Conversation

dhruvang21
Copy link
Contributor

Part of - #65018

What?

Issue - #65018, To use default to 40px for the button.

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

Screenshot is added for individual changed files.

Copy link

github-actions bot commented Sep 13, 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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @Dhruvang2001.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: Dhruvang2001.

Co-authored-by: dhruvang21 <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: hbhalodia <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Sep 13, 2024
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @dhruvang21! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@hbhalodia
Copy link
Contributor

Hi @dhruvang21, Can you please add before/after screenshots for the changes?

This would help us to check the change visually.

Thank You,

@@ -38,8 +38,7 @@ export default function Pagination( {
className="block-editor-patterns__grid-pagination-previous"
>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
Copy link
Contributor Author

@dhruvang21 dhruvang21 Sep 13, 2024

Choose a reason for hiding this comment

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

Before Before-paging
After after-paging

Copy link
Contributor

@ciampo ciampo Sep 24, 2024

Choose a reason for hiding this comment

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

These buttons currently have style overrides that are unnecessary and can be replaced with the compact size

  1. Let's remove the __next40pxDefaultSize on all 4 buttons in this file and add `size="compact"
  2. Let's also remove the size="default" prop on the last button (replaced by size="compact")
  3. We can, therefore, remove these overrides, which are now unnecessary

Finally, as an extra step, I noticed that there are more style overrides for when the "show icon labels" preference is enabled. Those style overrides use the internal components-button classname, which is private. We can make the following changes to improve the code:

  • add className="block-editor-patterns__grid-pagination-button" to all 4 instances of Button in the file
  • tweak the CSS selector in the style overrides:
diff --git a/packages/block-editor/src/components/block-patterns-paging/style.scss b/packages/block-editor/src/components/block-patterns-paging/style.scss
index f5f34d8212..b903334460 100644
--- a/packages/block-editor/src/components/block-patterns-paging/style.scss
+++ b/packages/block-editor/src/components/block-patterns-paging/style.scss
@@ -23,8 +23,7 @@
 }
 
 .show-icon-labels {
-	.block-editor-patterns__grid-pagination {
-		.components-button {
+	.block-editor-patterns__grid-pagination-button {
 			width: auto;
 			// Hide the button icons when labels are set to display...
 			span {

@mirka mirka added the [Type] Code Quality Issues or PRs that relate to code quality label Sep 13, 2024
@mirka mirka requested a review from a team September 13, 2024 09:58
Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

Thank you @dhruvang21 for working on this, and sorry for the delay in reviewing your PR.

For future work, it would greatly help if you could add screenshots (or a comment to why to you couldn't produce a screenshot).

I recommend you rebase (or merge trunk into) this PR, so that it's up to date with the upstream repository.

I also left some comments that would need to be addressed before we can move forward.

Thank you again, and let me know in case anything isn't clear.

@@ -27,8 +27,7 @@ function BlockNavigationDropdownToggle( {
} ) {
return (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
Copy link
Contributor

Choose a reason for hiding this comment

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

Noting that this Button is used in a deprecated component, and therefore we should be ok to make this change without the need to really test much about it.

@@ -18,8 +18,7 @@ import { VIEWMODES } from './constants';
const Actions = ( { onBlockPatternSelect } ) => (
<div className="block-editor-block-pattern-setup__actions">
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
Copy link
Contributor

Choose a reason for hiding this comment

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

This component also doesn't seem to be used anymore — however, I managed to find a screenshot of that the UI would look like when rendered in the browser:

Screenshot 2024-09-24 at 13 03 13

Judging from the screenshot, I think that we're good with the changes to this button

@@ -38,8 +38,7 @@ export default function Pagination( {
className="block-editor-patterns__grid-pagination-previous"
>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
Copy link
Contributor

@ciampo ciampo Sep 24, 2024

Choose a reason for hiding this comment

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

These buttons currently have style overrides that are unnecessary and can be replaced with the compact size

  1. Let's remove the __next40pxDefaultSize on all 4 buttons in this file and add `size="compact"
  2. Let's also remove the size="default" prop on the last button (replaced by size="compact")
  3. We can, therefore, remove these overrides, which are now unnecessary

Finally, as an extra step, I noticed that there are more style overrides for when the "show icon labels" preference is enabled. Those style overrides use the internal components-button classname, which is private. We can make the following changes to improve the code:

  • add className="block-editor-patterns__grid-pagination-button" to all 4 instances of Button in the file
  • tweak the CSS selector in the style overrides:
diff --git a/packages/block-editor/src/components/block-patterns-paging/style.scss b/packages/block-editor/src/components/block-patterns-paging/style.scss
index f5f34d8212..b903334460 100644
--- a/packages/block-editor/src/components/block-patterns-paging/style.scss
+++ b/packages/block-editor/src/components/block-patterns-paging/style.scss
@@ -23,8 +23,7 @@
 }
 
 .show-icon-labels {
-	.block-editor-patterns__grid-pagination {
-		.components-button {
+	.block-editor-patterns__grid-pagination-button {
 			width: auto;
 			// Hide the button icons when labels are set to display...
 			span {

@@ -59,8 +59,7 @@ function BlockQuickNavigationItem( { clientId, onSelect } ) {

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

Choose a reason for hiding this comment

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

Looking good

Screenshot 2024-09-24 at 14 27 19

Copy link
Contributor

Choose a reason for hiding this comment

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

This file was removed in #65204 (comment), and therefore these changes are not necessary anymore.

In any case, they would have not caused any meaningful differences because those buttons' styles were heavily overridden 😓

@dhruvang21
Copy link
Contributor Author

ciampo

Hi @ciampo,

Thanks for adding the screenshots! To be honest, I tried to locate the buttons but wasn't successful. I’ll make the necessary changes as per your instructions in the next commit.

Thanks again!

Copy link
Contributor

Choose a reason for hiding this comment

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

These style overrides can be also removed

@ciampo
Copy link
Contributor

ciampo commented Sep 25, 2024

@Dhruvang2001 I believe that this is the last comment left to address, before being able to merge. Almost there!

Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

Excellent! Thank you again for the collaboration, @Dhruvang2001 🙏

@ciampo ciampo merged commit d0bcf79 into WordPress:trunk Sep 26, 2024
60 checks passed
@github-actions github-actions bot added this to the Gutenberg 19.4 milestone Sep 26, 2024
@dhruvang21
Copy link
Contributor Author

Excellent! Thank you again for the collaboration, @Dhruvang2001 🙏

You're very welcome! It's been great collaborating with you as well. Looking forward to more in the future! 🙌

@mirka mirka added the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Oct 1, 2024
@noisysocks noisysocks added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported to WP Core Pull request that has been successfully merged into WP Core First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants