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

Set min width for ECE Google Pay button in blocks checkout #9124

Merged
merged 4 commits into from
Jul 26, 2024

Conversation

bborman22
Copy link
Contributor

@bborman22 bborman22 commented Jul 17, 2024

Fixes #

Changes proposed in this Pull Request

This was discovered during our exploratory Express Checkout Element (ECE) testing. When testing with Storefront theme with the sidebar enabled, the checkout blocks page becomes quite narrow. This narrowness combined with WC Core's grid-template-columns on the .wc-block-components-express-payment__event-buttons container lead to the spacing for the Google Pay button to be too small and automatically hidden by Stripe.

To account for this we determined the minimum width the Google Pay button needs to render (208px) and replaced the calculated minimum width on the grid-template-columns with this fixed minimum width.

This applies only to narrow checkout blocks pages (Storefront with sidebar enabled) and when more than 2 express checkout options are enabled.

Before
CSS: grid-template-columns: repeat(auto-fit, minmax(calc(33% - 10px), 1fr));
When three or more items were present in the Express Checkout (i.e. WooPay, Google Pay, and PayPal) the 33% - 10px was not wide enough for Google Pay to render leading to this display:
Screenshot 2024-07-17 at 4 01 32 PM
When breaking below the media query breakpoint the CSS becomes grid-template-columns: 1fr and renders as a single column and all buttons:
Screenshot 2024-07-17 at 4 02 13 PM

After
CSS: grid-template-columns: repeat( auto-fit, minmax( 208px, 1fr ) ) !important;
The 208px is determined through experimentation and was found to be the minimum size that still renders the Google Pay button on ECE. This now leads to a single column list rendering like this:
Screenshot 2024-07-17 at 4 06 41 PM
When breaking below the media query breakpoint, there is a point where it goes into two columns before going back to a single column:
Screenshot 2024-07-17 at 4 07 42 PM

Here is what it looks like with the sidebar disabled which I think is a more common display:
Screenshot 2024-07-17 at 4 09 57 PM

With sidebar and just two buttons:
Screenshot 2024-07-17 at 4 11 20 PM

Testing instructions

Screenshot 2024-07-26 at 10 37 23 AM

  • Have a store with the Storefront theme and a checkout blocks page with the sidebar enabled (see example screenshot above)
  • Enable both WooPay and Google Pay / Apple Pay.
  • In a browser where you will be presented with both options, add a product to cart and go to the checkout block page.
  • Without this PR applied adjust the browser window width to get smaller until the Google Pay button disappears (like in the Before image above).
  • Now with this PR applied repeat the same steps and confirm that the Google Pay button never disappears and instead bumps to a new row.

  • Run npm run changelog to add a changelog file, choose patch to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@bborman22
Copy link
Contributor Author

@pierorocca @nikkivias @alexflorisca Since you've all been taking a look at Express Checkout button rendering recently I wanted to run this approach by you all and get some opinions. The problem should be laid out well in the PR description, but in short, Google Pay through Stripe ECE requires a minimum width to render or else Stripe hides it automatically. In some scenarios (narrow checkout) the grid calculations would prevent Google Pay from rendering. Our proposed solution is to adjust this minimum column width to allow Google Pay to render when using ECE.

@ricardo No need to review this PR yet, but wanted to confirm with you all that this matches what was discussed and that this is the right way to apply it. cc @rafaelzaleski FYI.

@botwoo
Copy link
Collaborator

botwoo commented Jul 17, 2024

Test the build

Option 1. Jetpack Beta

  • Install and activate Jetpack Beta.
  • Use this build by searching for PR number 9124 or branch name fix/express-checkout-button-grid in your-test.site/wp-admin/admin.php?page=jetpack-beta&plugin=woocommerce-payments

Option 2. Jurassic Ninja - available for logged-in A12s

🚀 Launch a JN site with this branch 🚀

ℹ️ Install this Tampermonkey script to get more options.


Build info:

  • Latest commit: ca1c208
  • Build time: 2024-07-26 14:43:39 UTC

Note: the build is updated when a new commit is pushed to this PR.

Copy link
Contributor

github-actions bot commented Jul 17, 2024

Size Change: +109 B (0%)

Total Size: 1.33 MB

Filename Size Change
release/woocommerce-payments/dist/blocks-checkout-rtl.css 2.13 kB +54 B (+3%)
release/woocommerce-payments/dist/blocks-checkout.css 2.13 kB +55 B (+3%)
ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.08 kB
release/woocommerce-payments/assets/css/admin.rtl.css 1.08 kB
release/woocommerce-payments/assets/css/success.css 173 B
release/woocommerce-payments/assets/css/success.rtl.css 173 B
release/woocommerce-payments/dist/blocks-checkout.js 61.1 kB
release/woocommerce-payments/dist/bnpl-announcement-rtl.css 528 B
release/woocommerce-payments/dist/bnpl-announcement.css 529 B
release/woocommerce-payments/dist/bnpl-announcement.js 20.8 kB
release/woocommerce-payments/dist/cart-block.js 16.1 kB
release/woocommerce-payments/dist/cart.js 5.67 kB
release/woocommerce-payments/dist/checkout-rtl.css 600 B
release/woocommerce-payments/dist/checkout.css 600 B
release/woocommerce-payments/dist/checkout.js 31.7 kB
release/woocommerce-payments/dist/express-checkout-rtl.css 235 B
release/woocommerce-payments/dist/express-checkout.css 235 B
release/woocommerce-payments/dist/express-checkout.js 13.9 kB
release/woocommerce-payments/dist/index-rtl.css 39.1 kB
release/woocommerce-payments/dist/index.css 39 kB
release/woocommerce-payments/dist/index.js 296 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 1.08 kB
release/woocommerce-payments/dist/multi-currency-rtl.css 3.41 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 60.5 kB
release/woocommerce-payments/dist/multi-currency.css 3.41 kB
release/woocommerce-payments/dist/multi-currency.js 55.5 kB
release/woocommerce-payments/dist/order-rtl.css 730 B
release/woocommerce-payments/dist/order.css 730 B
release/woocommerce-payments/dist/order.js 42.7 kB
release/woocommerce-payments/dist/payment-gateways-rtl.css 1.35 kB
release/woocommerce-payments/dist/payment-gateways.css 1.35 kB
release/woocommerce-payments/dist/payment-gateways.js 39.2 kB
release/woocommerce-payments/dist/payment-request-rtl.css 235 B
release/woocommerce-payments/dist/payment-request.css 235 B
release/woocommerce-payments/dist/payment-request.js 13.5 kB
release/woocommerce-payments/dist/plugins-page-rtl.css 386 B
release/woocommerce-payments/dist/plugins-page.css 386 B
release/woocommerce-payments/dist/plugins-page.js 20.1 kB
release/woocommerce-payments/dist/product-details-rtl.css 397 B
release/woocommerce-payments/dist/product-details.css 398 B
release/woocommerce-payments/dist/product-details.js 11.3 kB
release/woocommerce-payments/dist/settings-rtl.css 11.2 kB
release/woocommerce-payments/dist/settings.css 11.1 kB
release/woocommerce-payments/dist/settings.js 223 kB
release/woocommerce-payments/dist/subscription-edit-page.js 703 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal-rtl.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 20.2 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 730 B
release/woocommerce-payments/dist/subscriptions-empty-state-rtl.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 19.3 kB
release/woocommerce-payments/dist/tokenized-payment-request-rtl.css 235 B
release/woocommerce-payments/dist/tokenized-payment-request.css 235 B
release/woocommerce-payments/dist/tokenized-payment-request.js 14.3 kB
release/woocommerce-payments/dist/tos-rtl.css 235 B
release/woocommerce-payments/dist/tos.css 235 B
release/woocommerce-payments/dist/tos.js 21.8 kB
release/woocommerce-payments/dist/woopay-direct-checkout.js 6.08 kB
release/woocommerce-payments/dist/woopay-express-button-rtl.css 235 B
release/woocommerce-payments/dist/woopay-express-button.css 235 B
release/woocommerce-payments/dist/woopay-express-button.js 23.9 kB
release/woocommerce-payments/dist/woopay-rtl.css 4.5 kB
release/woocommerce-payments/dist/woopay.css 4.47 kB
release/woocommerce-payments/dist/woopay.js 70.9 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 625 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 814 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.46 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.02 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.js 20 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.rtl.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.css 625 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.js 20 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.rtl.css 626 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-users.js 392 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-ajax.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-callables.js 584 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.css 215 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.css 721 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.js 412 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-users.js 520 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/babel.config.js 159 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.css 2.36 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.js 13.6 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.rtl.css 2.36 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.04 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-empty-state.css 294 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 408 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.59 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 301 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 746 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 574 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 414 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 543 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.4 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.78 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.84 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 545 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.52 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.2 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.7 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 507 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 358 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 428 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 782 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.09 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.26 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 391 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.04 kB

compressed-size-action

@pierorocca
Copy link
Contributor

pierorocca commented Jul 17, 2024

Looks good to me @bborman22. Awesome catch during the test exploration. Your solution looks aligned with the current design guidelines.

@danielvann777 you provided a perspective on the existing design choice to left align the lone button. We could instead center align here as we finalize this migration effort. If we were to make a change, this would be great timing if the design team thinks this change is warranted.

FYI @nikkivias

FYI the WooPay font size is being increased in a different PR/Issue. Here it's smaller than desired.

image

@ricardo
Copy link
Member

ricardo commented Jul 18, 2024

@ricardo No need to review this PR yet, but wanted to confirm with you all that this matches what was discussed and that this is the right way to apply it.

@bborman22 Yes, it matches, but for me the Google Pay button is hidden when the container width is below 232px, can you confirm if it's the same for you? See below:

ece-button-in-grid.mov

@alexflorisca
Copy link
Member

Hey @bborman22 thank for this work, but I've already got a PR up for addressing this (woocommerce/woocommerce#49304). In my testing, the button needed 240px of space so that's what I gave it. There seems to be a bit of variation on this reading the comments above, I say we go with the largest of them to be sure.

@pierorocca
Copy link
Contributor

Hey Alex does that hold up for translated buttons?

@bborman22
Copy link
Contributor Author

Sorry for the delay here, @alexflorisca given ECE will be releasing with WooPayments 8.0 on July 31st should we include this fix as a temporary solution until the WC Core fix is in? This way the buttons don't get hidden during that gap? And I agree on going with the largest of our results which seems to be 240px as you said!

@bborman22 bborman22 marked this pull request as ready for review July 26, 2024 14:40
@bborman22 bborman22 requested a review from rafaelzaleski July 26, 2024 14:52
@bborman22 bborman22 mentioned this pull request Jul 26, 2024
6 tasks
Copy link
Contributor

@rafaelzaleski rafaelzaleski left a comment

Choose a reason for hiding this comment

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

Great job! LGTM!

@bborman22 bborman22 added this pull request to the merge queue Jul 26, 2024
Merged via the queue into develop with commit 2ad61ed Jul 26, 2024
23 checks passed
@bborman22 bborman22 deleted the fix/express-checkout-button-grid branch July 26, 2024 17:36
@alexflorisca
Copy link
Member

Sure thing

@danielvann777
Copy link

@danielvann777 you provided a perspective on the existing design choice to left align the lone button. We could instead center align here as we finalize this migration effort. If we were to make a change, this would be great timing if the design team thinks this change is warranted.

Sorry for the lateness here @pierorocca. I would ask Nikki for the final say here since she probably knows all the permutations here but it does feel like a centered version would feel better in balancing the three buttons.

@nikkivias
Copy link

@pierorocca for 3 buttons, would it be okay if the first button were to be full width, while the remaining 2 split the space at the bottom? I ask "would it be ok" because this layout gives preference to first button, and I'm not sure if they can currently assign the order of buttons.

Checkout-3-buttons

@pierorocca
Copy link
Contributor

On WooPayments the most buttons that can dispaly currently is 3 so it works well as WooPay would be at the top.

If we add other buttons in the future, there's a chance that Apple or Google or other brands could be placed more favorably than another competing brand. Technically, that violates their usage guidelines. For our own brand, I'm willing to go there. To put Amazon pay more prominently than Google or Google over Apple or any other combo, that's tricky especially if we have any sort of incentive agreements or partnerships in place.

@alexflorisca
Copy link
Member

alexflorisca commented Aug 5, 2024

Again pointing out that this is pretty difficult to achieve as we don't know the number of payment extensions installed on a merchant's website, and the number of express payment methods that will be displayed. Our grid currently treats each of those equally and adds / removes grid items as payment methods are activated / deactivated. This layout may be possible with some client side logic to detect the WooPay button, place it first and make it take up two spaces in the grid instead of one. But it won't be possible to do this generically.

@danielvann777
Copy link

So I can see two solutions here: one where every button gets a similar treatment (I think that's what competitors do) or we prioritize one, Woo Payments. Regardless, we need to find an elegant solution when it scales and I'm mocking up here an idea. I've tried adding a mockup here of my logic:

Mockup of logic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants