-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Feature/price formatting #4061
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
Feature/price formatting #4061
Conversation
pkarw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks that's pretty cool feature
I've checked https://bundlephobia.com/result?p=currencyformatter.js@2.2.0
... and seemingly we can get potentially the same effect with https://www.npmjs.com/package/currency.js
The thing is 1.12 is all about bundle size optimizations so I'm just wondering that maybe you could try out something smaller than currencyformatter.js (?)
|
@pkarw I wanted to write the same comment as you did. There is |
|
|
||
| const formatValue = (value, locale) => { | ||
| const price = Math.abs(parseFloat(value)) | ||
| const formatter = new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your changes, looks much better but... why not just changing this line? I mean... I think it's totally enough to move just these two options minimumFractionDigits and maximumFractionDigits to the config file and you don't anything else... ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because as said #3553, they also wanted to be able to change the separators.
|
@EndPositive you have an error during the build - I'm pretty sure it's because of config file - it's not valid json, please change null's to the default separators |
…tive/vue-storefront into feature/price-formatting
|
@andrzejewsky Thanks for the heads up. I changed the config file. |
|
@EndPositive thanks! |
Related Issues
closes #3553
Short Description and Why It's Useful
This pr adds the module currencyformatter.js. You are now able to change the following attributes in config:
currencySign: custom currency sign.currencyDecimal: custom char used to display the decimal separator.currencyGroup: custom char used to display the decimal separator.currencyPattern: custom numeric format string. This replaces the priceFormat attribute as you are able to switch sign and value position using this attribute. E.g.#,##0.00!and!#,##0.00. Furthermore, using this pattern, you can specify how many digits the fractional part of the price should have (#,###!for no digits).When these values are set to
null, the locale default will be taken. When one of these are set, the locale will be overwritten. They can be used individually or together.Which Environment This Relates To
developbranch and want to merge it back todevelopreleasebranch and want to merge it back toreleasehotfixormasterbranch and want to merge it back tohotfixUpgrade Notes and Changelog
Contribution and Currently Important Rules Acceptance