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

feat(components/core): allow currencyDisplay to be specified for SkyNumericOptions #2817

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Blackbaud-MitchellThomas
Copy link

@Blackbaud-MitchellThomas Blackbaud-MitchellThomas commented Oct 10, 2024

Internally, the SkyNumericPipe and SkyNumericService use Intl to format number as currency. When the language locale specified, such as en-CA, does not naturally line up with the ISO4217 currency code's locale, such as USD, the default behavior is to format the currency using an unambiguous currency symbol, US$.

In certain scenarios, this more verbose display is not desired. The current default inside skyux is to use the 'symbol' notation, which drives this behavior. However, Intl provides an alternative display setting, 'narrowSymbol', which would only display $ in this scenario.

Currently, consumers are not able to choose this option.

The scope of this PR is to expose currencyDisplay directly on SkyNumberOptions to give consumers the ability to choose this alternate display option.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#narrowsymbol

Copy link

nx-cloud bot commented Oct 10, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit d87be91. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@Blackbaud-MitchellThomas Blackbaud-MitchellThomas changed the title Allow currencyDisplay to be specified for SkyNumericOptions feat-Allow currencyDisplay to be specified for SkyNumericOptions Oct 10, 2024
@Blackbaud-MitchellThomas Blackbaud-MitchellThomas changed the title feat-Allow currencyDisplay to be specified for SkyNumericOptions feat: Allow currencyDisplay to be specified for SkyNumericOptions Oct 10, 2024
@Blackbaud-MitchellThomas Blackbaud-MitchellThomas changed the title feat: Allow currencyDisplay to be specified for SkyNumericOptions feat: allow currencyDisplay to be specified for SkyNumericOptions Oct 10, 2024
@Blackbaud-MitchellThomas Blackbaud-MitchellThomas marked this pull request as ready for review October 10, 2024 16:57
@@ -32,7 +32,7 @@ export class SkyNumberFormatUtility {
style: SkyIntlNumberFormatStyle,
digits?: string | null,
currency: string | null = null,
currencyAsSymbol = false,
currencyDisplay: 'code' | 'symbol' | 'narrowSymbol' | 'name' = 'symbol',

Choose a reason for hiding this comment

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

The previous default of false would have set the currencyDisplay to code. Can we update this default to match the previous behavior?

Choose a reason for hiding this comment

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

I'm a bit surprised this isn't failing any unit tests. The percent pipe does not send a default for currencyAsSymbol which would have resulted in code under the current code. But with this - the percent pipe would now end up with symbol if I'm reading everything correctly. I would like to maintain the current defaults if possible (where the percent pipe uses code and the numeric service defaults to symbol.

Choose a reason for hiding this comment

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

The reason all the tests show it working as expected is because currency display options don't impact the percent pipe. But I can see the benefit in drawing the consistency a bit tighter in the code. I'll make a couple of tweaks.

@Blackbaud-TrevorBurch Blackbaud-TrevorBurch added the risk level (author): 2 This change has a slight chance of introducing a bug label Oct 15, 2024
@Blackbaud-TrevorBurch Blackbaud-TrevorBurch changed the title feat: allow currencyDisplay to be specified for SkyNumericOptions feat(components/core): allow currencyDisplay to be specified for SkyNumericOptions Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
risk level (author): 2 This change has a slight chance of introducing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants