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

Checkout: Adjust label style to accommodate more cards #94693

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

jjchrisdiehl
Copy link
Contributor

@jjchrisdiehl jjchrisdiehl commented Sep 18, 2024

The labels in Checkout were breaking out of their bounding box on small mobile viewports (< 375px), this PR adjusts how we handle the credit card logos across viewport sizes and tries to gracefully wrap them at different device sizes.

Before After
image image

A side benefit to this is that the changes also extend to the 'Add a payment method' and 'Change payment method' forms in the Purchases section.

Proposed Changes

Left to Right

Viewport 1024px - Inactive payment method
Not very different at this viewport

Before After
image image

View port 425px - Inactive payment method
Small changes at this size, the logos begin to wrap now. The benefit becomes more obvious at certain sizes like 375px wide where the logos drop onto their own line.

Before After 375
image image image

Viewport 320px - Inactive payment method
Most visible at this size, fixes a bug where label items would overflow their bounding box by dropping cards to next line.

Before After
image image

Viewport 1024px - Active payment method

Not much change here other than standardizing the sizes of the svg logos for better alignment

Before After
image image

Viewport 320px - Active payment method
Logos will stack at this viewport size

Before After
image image

Testing Instructions

  • Test the different viewports in checkout and purchases, use the examples above for guidance
  • Try different languages to see if anything breaks
  • Try right to left languages to ensure the styles correctly reverse themselves

@jjchrisdiehl jjchrisdiehl added the [Feature] Checkout The checkout screen and process for purchases made on WordPress.com. label Sep 18, 2024
@jjchrisdiehl jjchrisdiehl self-assigned this Sep 18, 2024
@jjchrisdiehl jjchrisdiehl requested a review from a team as a code owner September 18, 2024 22:37
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 18, 2024
@matticbot
Copy link
Contributor

matticbot commented Sep 18, 2024

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~90 bytes added 📈 [gzipped])

name                          parsed_size           gzip_size
site-purchases                     +400 B  (+0.0%)      +72 B  (+0.0%)
purchases                          +400 B  (+0.0%)      +72 B  (+0.0%)
checkout                           +400 B  (+0.0%)      +74 B  (+0.0%)
jetpack-cloud-partner-portal       +344 B  (+0.0%)      +56 B  (+0.0%)
a8c-for-agencies-purchases         +344 B  (+0.1%)      +56 B  (+0.0%)
a8c-for-agencies-client            +344 B  (+0.0%)      +56 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~74 bytes added 📈 [gzipped])

name                                             parsed_size           gzip_size
async-load-calypso-my-sites-checkout-modal            +400 B  (+0.0%)      +74 B  (+0.0%)
async-load-calypso-blocks-editor-checkout-modal       +400 B  (+0.0%)      +74 B  (+0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@JessBoctor
Copy link
Collaborator

I may be doing something wrong, but when I try to test with a smaller viewport in the Chrome Inspector tools, I don't get the logos on a second line. I still see them pushed to the side. This is happening with both active and inactive payment methods.

I am using the fix/add-payment-label-mobile-layout branch on local calypso to test.

Screenshot 2024-09-19 at 08 53 46

@sirbrillig
Copy link
Member

I haven't tested this yet and it may just be an outdated screenshot, but something looks bad with the PayPal logo in the "after" screenshot here:

Screenshot 2024-09-19 at 1 01 06 PM

text-align: right;
flex-wrap: wrap;
gap: 5px;
text-align: end;
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 should resolve the PayPal logo issue. Changed to a more responsive value to handle RTL better.

}
svg {
&.credit-card__logo svg {
display: inline-block;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

More specific to avoid shrinking non-card logos (like PayPal)

&.has-background {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really needed if we set a default size for the card logos and apply some flex gap.

@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • notifications
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug fix/add-payment-label-mobile-layout on your sandbox.

@@ -126,7 +129,7 @@ const Label = styled.label< LabelProps & React.LabelHTMLAttributes< HTMLLabelEle
content: '';
border: 1px solid ${ ( props ) => props.theme.colors.borderColor };
border-radius: 100%;
top: 28px;
top: 40%;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These radios dots are rather difficult to work with since they are absolutely positioned before and after the label. It might be worth rebuilding this component in the future so we can properly align the radio > label > and logos with flex or grid.

@jjchrisdiehl
Copy link
Contributor Author

I think a better alternative to allowing the cards to wrap, is to instead allow the text to wrap in the finite number of device sizes where they begin to clash:

Card wrap Text wrap
image image

Copy link
Member

@sirbrillig sirbrillig left a comment

Choose a reason for hiding this comment

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

Works as described at all the widths and scenarios I tested. One thing that occurs to me is that we could hide the credit card logos at small widths like we do with all the other logos. But this works and looks good so I have no complaints.

@jjchrisdiehl
Copy link
Contributor Author

@sirbrillig Made a slight change to incorporate this:

Inactive Active
image image

Essentially, hide the logos when inactive (with less space to use) and then show when we click on the add method option.

This only applies below 400px wide. Everything else works as before.

@sirbrillig
Copy link
Member

I haven't tested that change but the code looks fine and it sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Checkout The checkout screen and process for purchases made on WordPress.com. [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants