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 3] #65110

Merged
merged 7 commits into from
Sep 9, 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.

Copy link

github-actions bot commented Sep 6, 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 <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: mirka <[email protected]>

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

@@ -32,16 +32,14 @@ export function ConvertToLinksModal( { onClick, onClose, disabled } ) {
</p>
<div className="wp-block-page-list-modal-buttons">
<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 page-list block and try to convert page-list to navigationLinks

Before After
page-list-1-before page-list-1-after

variant="tertiary"
onClick={ onClose }
>
{ __( 'Cancel' ) }
</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, while you add page-list block and try to convert page-list to navigationLinks

Before After
page-list-1-before page-list-1-after

@@ -342,8 +342,7 @@ export default function PageListEdit( {
<PanelBody title={ __( 'Edit this menu' ) }>
<p>{ convertDescription }</p>
<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 page-list block and check the inspector panels, when convertToLinks option is true.

Before After
page-list-2-before page-list-2-after

@@ -84,8 +84,7 @@ const CommentsForm = ( { postId, postType } ) => {
if ( 'closed' === commentStatus ) {
const actions = [
<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 core/post-comments-form block, and you have comments disabled.

Before After
Comments-form-before Commentss-form-after

@@ -308,8 +308,7 @@ export default function PostFeaturedImageEdit( {
mediaLibraryButton={ ( { open } ) => {
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 you add core/post-featured-image block.

Note: This has some styles that have higher specificity and specific to this upload button on this block, hence before and after is same, but we can see our change is applied in inspector controls.

Before After
featured-image-before featured-image-after

Copy link
Contributor

Choose a reason for hiding this comment

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

As @hbhalodia said, noting that the __next40pxDefaultSize prop here doesn't have an impact because of the style overrides applied to the placeholder and the button components in the post featured image block.

These style overrides should be removed, if possible — but it's not in the scope of this PR. We can keep changes as they are.

@@ -627,8 +627,7 @@ export default function LogoEdit( {
render={ ( { open } ) => (
<div className="block-library-site-logo__inspector-upload-container">
<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 core/site-logo block, and check the inspector controls to upload the logo.

Note: This has some styles that have higher specificity and specific to this button on this block, hence before and after is same, but we can see our change is applied in inspector controls.

Before After
site-logo-before site-logo-after

Copy link
Contributor

Choose a reason for hiding this comment

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

We have style overrides in this case as well.

For the context of this PR, I think the current code changes are enough.


Still, I'd love to remove all of those overrides if possible, and just use a standard Button variant — although the situation is trickier than it looks. There are three possible UIs shown to the user:

Therefore, we'd need to make sure that we could offer a good, consistent UI in all three cases even without those overrides. Something we could do in a follow-up (cc @WordPress/gutenberg-design )/

Also, I noticed that the dropdown comes from the MediaReplaceFlow component. That dropdown is using a ToolbarButton as its trigger, showing that it was only meant to be rendered in a toolbar — while here it's being used in the editor sidebar (cc @WordPress/gutenberg-components @ntsekouras @youknowriad ).

@@ -674,8 +673,7 @@ export default function LogoEdit( {
mediaLibraryButton={ ( { open } ) => {
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 you add core/site-logo block, check for upload button.

Note: This has some styles that have higher specificity and specific to this upload button on this block, hence before and after is same, but we can see our change is applied in inspector controls.

Before After
site-logo-2-before site-logo-2-after

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above. There are again a lot of style overrides, which ideally shouldn't be there at all.

The code change here is good for the scope of this PR

@@ -81,8 +81,7 @@ const SocialLinkURLPopover = ( {
/>
</div>
<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 core/social-link block, and add the link. You can check for the apply button.

Before After
social-link-before social-link-after

Copy link
Contributor

Choose a reason for hiding this comment

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

We should update the URLInput to a 40px height too — @mirka , do you know if that's feasible as of now? Or should we keep the TODO comment and revisit later?

Copy link
Member

Choose a reason for hiding this comment

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

Mmm, this is kind of dependent on #64709, so I guess we can revert to TODO for now. I'll do something about it if the Button migrations get completed before the URLInput issue is addressed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I would update this to TODO state.

@akasunil akasunil added the [Type] Code Quality Issues or PRs that relate to code quality label Sep 6, 2024
@ciampo ciampo requested a review from a team September 6, 2024 11:28
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 for working on this!

Most of the changes LGTM to me for the scope of this PR. The only pending item is #65110 (comment)

@hbhalodia
Copy link
Contributor Author

Thank you for working on this!

Most of the changes LGTM to me for the scope of this PR. The only pending item is #65110 (comment)

Hi @ciampo @mirka, the PR is updated with the feedbacks.

Thank You,

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.

Changes LGTM given the scope of this PR.

Thank you, @hbhalodia 🙏

@ciampo ciampo merged commit 168d3c5 into WordPress:trunk Sep 9, 2024
62 checks passed
@github-actions github-actions bot added this to the Gutenberg 19.3 milestone Sep 9, 2024
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