Skip to content

Forms: use Badge component for badges in Forms #44347

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

Merged
merged 7 commits into from
Jul 22, 2025

Conversation

simison
Copy link
Member

@simison simison commented Jul 17, 2025

Uses Badge component from the new Automattic UI library. Badge is the same as core-badge.

Tried to apply sensible badge colours everywhere but not sure if I got it right. 😅 @edanzer can you help review?

Grey neutral for items which are fine to ignore if they aren't planning to set up. Green for things that are setup correctly, and yellow for ones which need attention since they're half-setup.

Before

Screenshot 2025-07-17 at 13 02 09

After

image

Proposed changes:

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Go to '..'

@simison simison requested a review from a team July 17, 2025 10:01
Copy link
Contributor

github-actions bot commented Jul 17, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the update/forms-use-badge-component branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/forms-use-badge-component
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/forms-use-badge-component

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Block] Contact Form Form block (also see Contact Form label) [Feature] Contact Form labels Jul 17, 2025
Copy link
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@simison simison requested a review from ilonagl July 17, 2025 10:04
Copy link

jp-launch-control bot commented Jul 17, 2025

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

@ilonagl
Copy link

ilonagl commented Jul 21, 2025

LGTM!

ilonagl
ilonagl previously approved these changes Jul 21, 2025
@simison simison force-pushed the update/forms-use-badge-component branch from e29cd63 to c300974 Compare July 21, 2025 10:54
@edanzer edanzer force-pushed the update/forms-use-badge-component branch from 34b20ff to 60a7c05 Compare July 22, 2025 02:10
@@ -1,4 +1,5 @@
.integration-card {
--wp-admin-theme-color: #000;
Copy link
Contributor

@edanzer edanzer Jul 22, 2025

Choose a reason for hiding this comment

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

So when testing, I found a weird issue the the "Plugin needs install" button was gray (like the screenshots in the PR description) when on the central integrations dashboard... but blueish when on the integrations modal in the block editor.

new-badge-colors-before

After some digging, the reason is that the badge color is based on a variable --wp-admin-theme-color, which for some reason has different values on a normal admin page (#000000) vs the block editor (#007cba).

This is for badges with intent = info.

I thought about changing the intent for these to "default", which is consistently gray in both places, but then we lose the badge icon. In the component library, when the badge has 'default', the icon is dropped.

As a demo, I pushed this small change which overrides the --wp-admin-theme-color in the editor, but I actually don't think this is a good idea. Overriding this will produce other kinds of potential inconsistency.

In any case, with this change, the color is gray as expected. Also note sales force is the same gray color, also with icon, because I updated it's intent to be info as well. Whatever intent we use, we should likely use the same intent for the 'Plugin needs install' and Salesforce 'Enter organization ID' badges.

badge-colors-after

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, even in earlier designs, the gray style badges didn't have icons. So I updated these back to the 'default' variant, which is always gray. And that allowed me to remove the 'bad' css override above.

The final looks like this in the editor:
final-modal-badges-and-mobile

And like this in the dashboard:
dashboard-with-badges

Those both look great IMO.

@edanzer edanzer force-pushed the update/forms-use-badge-component branch from 60a7c05 to 9ad8740 Compare July 22, 2025 03:56
<Badge intent="warning" className="integration-card__setup-badge">
{ __( 'Needs connection', 'jetpack-forms' ) }
</Badge>
) ) }
Copy link
Contributor

Choose a reason for hiding this comment

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

I rebased this on top of some other work to change the order of the badges on mobile.

The main difference after addressing merge conflicts is we had to keep the class names like integration-card__connected-badge so that we could continue to apply the flex order changes on desktop vs mobile.

Likewise, in the CSS we kept the rules applying the order for those classes.

@edanzer edanzer merged commit c31f928 into trunk Jul 22, 2025
85 checks passed
@edanzer edanzer deleted the update/forms-use-badge-component branch July 22, 2025 04:32
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants