-
Notifications
You must be signed in to change notification settings - Fork 2k
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: Simplify code for rendering line item sublabel #80987
Checkout: Simplify code for rendering line item sublabel #80987
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~166 bytes removed 📉 [gzipped])
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 (~154 bytes removed 📉 [gzipped])
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. Generated by performance advisor bot at iscalypsofastyet.com. |
One thing I want to check before putting this up for review: does this change how the sublabel renders in RTL languages? or languages with word orders significantly different from English? |
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/8826688 Thank you @sirbrillig for including a screenshot in the description! This is really helpful for our translators. |
Translation for this Pull Request has now been finished. |
Line items in checkout are rendered by the
CheckoutLineItem
component (previouslyWPLineItem
). They consist of several parts:In this list the item sublabel is rendered in the following way:
getSublabel()
function is called to generate the general text.translate()
function, the general text is combined with other text after a colon, like the billing interval.This is a slightly strange use of a translated string since its primary purpose is layout (eg:
%(premiumLabel)s %(sublabel)s: %(interval)s
contains nothing really to translate). It also creates a fair amount of complexity when reading or trying to alter the sublabel since it is combined in so many different ways. This has led to confusion when devs are attempting to fix bugs or add new subtext. It's also inflexible since it means that the general text must be a string only.Proposed Changes
In this PR we rename
getSublabel()
to turn it into a React component instead.This change allows us to render it combined with other information using HTML for layout and makes its behavior more explicit.
Testing Instructions
This PR should not change how line items are rendered, so testing involves adding various products to your shopping cart and verifying that they render the same way in checkout as before this PR.