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

Plans: The font size of the pricing is smaller #93908

Closed
taipeicoder opened this issue Aug 26, 2024 · 2 comments · Fixed by #94164
Closed

Plans: The font size of the pricing is smaller #93908

taipeicoder opened this issue Aug 26, 2024 · 2 comments · Fixed by #94164
Assignees
Labels
[Pri] Low Address when resources are available. [Type] Bug When a feature is broken and / or not performing as intended [Type] Fit and Finish Issues related to the fit, finish and overall polish of WordPress.com

Comments

@taipeicoder
Copy link
Contributor

Description

See context.

Image

Image

@mmtr
Copy link
Member

mmtr commented Aug 26, 2024

Seems this one is reproducible only if the currency is set to USD (this can be changed in Store Admin):

EUR USD
Screenshot 2024-08-26 at 15 41 25 Screenshot 2024-08-26 at 15 43 23

@mmtr mmtr added [Type] Bug When a feature is broken and / or not performing as intended [Pri] Low Address when resources are available. [Type] Fit and Finish Issues related to the fit, finish and overall polish of WordPress.com labels Aug 26, 2024
@mrfoxtalbot mrfoxtalbot moved this from Needs Triage to Triaged in Automattic Prioritization: The One Board ™ Aug 26, 2024
@taipeicoder
Copy link
Contributor Author

The font size reduction is intended to handle large display prices. We currently determine display prices to be large whenever the text string exceeds six characters.

The issue is that display prices uses Intl.NumberFormat() which account for the locale.

For en-US, running the following code:

const formatter = new Intl.NumberFormat( 'en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0, minimumFractionDigits: 0 } );
console.log(formatter.formatToParts(300));

// Output
▼ (2) [{...}, {...}]
  ▶ 0: (2) {type: "currency", value: "$"}
  ▶ 1: (2) {type: "integer", value: "300"}
  ▶ [[Prototype]]: []

However, running the same code for es results in:

const formatter = new Intl.NumberFormat( 'en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0, minimumFractionDigits: 0 } );
console.log(formatter.formatToParts(300));

// Output
▼ (3) [{...}, {...}, {...}]
  ▶ 0: (2) {type: "integer", value: "300"}
  ▶ 1: (2) {type: "literal", value: " "}
  ▶ 2: (2) {type: "currency", value: "US$"}
  ▶ [[Prototype]]:[]

This additional whitespace makes the display price exceed the threshold, making it "large".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Pri] Low Address when resources are available. [Type] Bug When a feature is broken and / or not performing as intended [Type] Fit and Finish Issues related to the fit, finish and overall polish of WordPress.com
Development

Successfully merging a pull request may close this issue.

2 participants