jetpack icon indicating copy to clipboard operation
jetpack copied to clipboard

Update/payment buttons layout

Open dsas opened this issue 3 years ago • 4 comments

Fixes #25927

Changes proposed in this Pull Request:

Add grid layout options to Payment Buttons, making the design just as configurable as Core Buttons. Specifically this brings the following controls:

  • Justification
  • Orientation
  • Block spacing

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?

Jetpack product discussion

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

Testing instructions:

  • Create a JN / wpcom site with a paid plan
  • Insert some Payment Blocks, go through the stripe connection etc
  • Publish the post and open it in a new window
  • Use JP beta to switch your site to this branch / apply this patch to your sandbox
  • Open the published post in a new window and compare the two - they should look identical
  • Open the published post in the editor, it should load as normal - no errors
  • Twiddle with the new options: the preview should update accordingly and after saving so should the published post.
Before After
image image

dsas avatar Sep 09 '22 13:09 dsas

Thank you for your PR!

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

  • :white_check_mark: Include a description of your PR changes.
  • :warning: All commits were linted before commit.
  • :white_check_mark: Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • :white_check_mark: Add testing instructions.
  • :white_check_mark: Specify whether this PR includes any changes to data or privacy.
  • :white_check_mark: 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 :robot:


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Then, add the "[Status] Needs Team review" label and ask someone from your team review the code. Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: October 4, 2022.
  • Scheduled code freeze: September 27, 2022.

github-actions[bot] avatar Sep 09 '22 13:09 github-actions[bot]

Payment Button width controls work, but the button widths are not calculated in the same way are core button widths are. For a visual difference. I have a Payment Buttons block with an 11px blockGap and three buttons at 50%, 25%, 25% and have set-up a core Buttons block in the same way. It looks like this: image

~~Core button widths are sized to exclude block spacing, that is a width of 50% is actually 50% - the blockGap. Buttons widths are always in percents in a multiple of 25, so it can hardcode a certain number of calculations.~~

~~Payment buttons allow widths of any number in percents, pixels and ems. So a slightly different approach to upstream is in order. It's less complicated than appears at first glance, as unless you using % based block widths, you get exactly what you ask for.~~

~~recurring-payments buttons have some JS which sets styles based upon --jetpack-payment-buttons-gap (0.5em) rather than the actual block gap in use when using percentage based widths. I just need to adapt this to get the selected blockGap.~~

I'd misunderstood that.

Core button widths are sized to exclude block spacing, but assume block spacing is --wp--style--block-gap (1.5 rem) falling back to 0.5ems. It doesn't use the currently set blockGap. Buttons widths are always in percents in a multiple of 25, so it can hardcode a certain number of calculations, which only works when the blockGap is not set, or is smaller than the above.

Payment buttons allow widths of any number in percents, pixels and ems, so adopting hardcoded calculations for specific button widths isn't as simple as in core/buttons.

recurring-payments buttons has some JS which is used with percentage based widths to set styles based upon --jetpack-payment-buttons-gap (0.5em) rather than based upon the theme, or configured blockGap.

Visual differences between core/buttons and payment-buttons are solely due to the different gap used. PBs use --jetpack-payment-buttons-gap (0.5em) while core/buttons uses 1.5rem. I'm not planning on solving the difference here to bring them in-line or to use the configured blockGap because:

  • Changing the --jetpack-payment-buttons-gap to match core/buttons will change how already existing created payment buttons look
  • Accounting for the configured blockGap is horrendously complicated, and ought to be solved in core first/simultaneously

dsas avatar Sep 09 '22 13:09 dsas

Are you an Automattician? You can now test your Pull Request on WordPress.com. On your sandbox, run bin/jetpack-downloader test jetpack update/payment-buttons-layout to get started. More details: p9dueE-5Nn-p2

github-actions[bot] avatar Sep 15 '22 08:09 github-actions[bot]

One thing to note is that for people on wpcom who have payment-buttons but who don't have the right plan to use them, the blocks will not display correctly when viewing on the front-end.

image

This is because the block won't be registered with PHP and so the __experimentalLayout support will not be available when rendering in php.

I think this behaviour is ok, but I'm definitely open to challenge on it

dsas avatar Sep 16 '22 14:09 dsas

Please update the title! 🙂

Copons avatar Sep 30 '22 15:09 Copons