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

Add props for buttons in editor 2 #65083

Merged
merged 3 commits into from
Sep 12, 2024

Conversation

AKSHAT2802
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 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: AKSHAT2802 <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: tyxla <[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 5, 2024
Copy link

github-actions bot commented Sep 5, 2024

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @AKSHAT2802! 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.

@AKSHAT2802 AKSHAT2802 changed the title Add __next40pxDefaultSize for editor 2 files Add props for buttons in editor 2 #65068 Sep 5, 2024
@AKSHAT2802 AKSHAT2802 changed the title Add props for buttons in editor 2 #65068 Add props for buttons in editor 2 Sep 5, 2024
@@ -100,8 +100,7 @@ export default function PostFormat() {
{ suggestion && suggestion.id !== postFormat && (
<p className="editor-post-format__suggestion">
<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.

Before After
post format before Post Format 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 @mirka mentioned in another PR, variant="link" Button components have their height set to auto, and therefore the __next40pxDefaultSize doesn't make any difference

variant="tertiary"
href={ unlockUrl }
>
{ __( 'Take over' ) }
</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.

Before After
post lock before Post lock after

@@ -25,8 +25,7 @@ const PostFormatSuggestion = ( {
onUpdatePostFormat,
} ) => (
<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.

Before After
Meybe post format before Maybe Post format after

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -155,8 +155,7 @@ export default function PostFormatPanel() {
<Spinner />
) : (
<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.

Before After
Maybe Upload Media before Maybe Upload media after

@mirka mirka requested a review from a team September 5, 2024 21:04
@mirka mirka added the [Type] Code Quality Issues or PRs that relate to code quality label Sep 5, 2024
@@ -36,8 +36,7 @@ function PostLastRevision() {
return (
<PostLastRevisionCheck>
<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.

I wasn't able to find how to test this instance in the editor — it looks like the PostLastRevision component is not used anymore since #62323 (cc @ntsekouras ) but we're still exporting it.

In any case, I can see that there are some style overrides in place that tweak the height, and so passing the __next40pxDefaultSize prop shouldn't affect the look of this button.

For the scope of this PR, I think that we can leave things as they are.

As a future improvement, we should avoid overriding button (and panel) styles. If we feel like we're tweaking Button beyond its purpose, we should consider not using Button at all (cc @mirka )

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, this component is not used any more in favor of PrivatePostLastRevision component. There was some discussions whether to remove it here and we ended up keeping it for existing consumers.

Copy link
Member

Choose a reason for hiding this comment

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

I think it still makes sense to remove the overrides if possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed — it would be good to do that as a follow up to this PR.

Copy link
Member

Choose a reason for hiding this comment

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

A follow-up PR sounds good 👍

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!

Apart from #65083 (comment), we will also need to update test snapshots

@ciampo ciampo requested a review from a team September 6, 2024 11:35
@AKSHAT2802 AKSHAT2802 force-pushed the fix/button-size-violation-editor-2 branch from 561c6ff to 3187318 Compare September 11, 2024 20:10
@ciampo
Copy link
Contributor

ciampo commented Sep 11, 2024

Code changes are looking good, but we'll need to update snapshots in order to have passing unit tests

@AKSHAT2802
Copy link
Contributor Author

Code changes are looking good, but we'll need to update snapshots in order to have passing unit tests

Hii @ciampo, I have updated test snapshots for the PR.

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍 ✅

Thanks for working on it @AKSHAT2802 🙌

@tyxla tyxla merged commit a18d831 into WordPress:trunk Sep 12, 2024
63 checks passed
@github-actions github-actions bot added this to the Gutenberg 19.3 milestone Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

5 participants