Skip to content

Fix: Button Replace remaining 40px default size violations [Block Editor 2]#65308

Merged
ciampo merged 3 commits into
WordPress:trunkfrom
dhruvang21:bugfix/issue-65018
Sep 26, 2024
Merged

Fix: Button Replace remaining 40px default size violations [Block Editor 2]#65308
ciampo merged 3 commits into
WordPress:trunkfrom
dhruvang21:bugfix/issue-65018

Conversation

@dhruvang21

Copy link
Copy Markdown
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.

@github-actions

github-actions Bot commented Sep 13, 2024

Copy link
Copy Markdown

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 <dhruvang21@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>

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
@github-actions

Copy link
Copy Markdown

👋 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
Copy Markdown
Contributor

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

This would help us to check the change visually.

Thank You,

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

@dhruvang21 dhruvang21 Sep 13, 2024

Copy link
Copy Markdown
Contributor Author

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

@ciampo ciampo Sep 24, 2024

Copy link
Copy Markdown
Contributor

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

@ciampo ciampo left a comment

Copy link
Copy Markdown
Contributor

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.

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

Copy link
Copy Markdown
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.

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

Copy link
Copy Markdown
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

Comment thread packages/block-editor/src/components/block-pattern-setup/setup-toolbar.js Outdated
Comment thread packages/block-editor/src/components/block-pattern-setup/setup-toolbar.js Outdated
Comment thread packages/block-editor/src/components/block-pattern-setup/setup-toolbar.js Outdated
Comment thread packages/block-editor/src/components/block-pattern-setup/setup-toolbar.js Outdated
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize

@ciampo ciampo Sep 24, 2024

Copy link
Copy Markdown
Contributor

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 {

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

ciampo commented Sep 25, 2024

Copy link
Copy Markdown
Contributor

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

@ciampo ciampo left a comment

Copy link
Copy Markdown
Contributor

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
@github-actions github-actions Bot added this to the Gutenberg 19.4 milestone Sep 26, 2024
@dhruvang21

Copy link
Copy Markdown
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! 🙌

@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 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