-
Notifications
You must be signed in to change notification settings - Fork 5
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: add count up #1642
Merged
Merged
feat: add count up #1642
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5f33b40
feat: add count up
Nick-1979 7c856fe
refactor: rename var
Nick-1979 ac46aba
refactor: use decimal directly
Nick-1979 6dcfe4b
chore: add count up to extension mode
Nick-1979 4ab1e6f
chore: remove unused
Nick-1979 9726aa6
fix: change when selected currency is a crypto (#1643)
Nick-1979 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,12 @@ function countLeadingZerosInFraction (numStr: string) { | |
return 0; | ||
} | ||
|
||
export function countDecimalPlaces (n: number) { | ||
const match = n.toString().match(/\.(\d+)/); | ||
|
||
return match ? match[1].length : 0; | ||
} | ||
Comment on lines
+53
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add type safety and handle edge cases. The function implementation could be improved with better type safety and edge case handling: -export function countDecimalPlaces (n: number) {
+export function countDecimalPlaces (n: number): number {
+ if (!Number.isFinite(n)) {
+ return 0;
+ }
+
+ // Handle scientific notation
+ const str = n.toString().toLowerCase();
+ if (str.includes('e')) {
+ const [_, exp] = str.split('e');
+ return Math.max(0, -Number(exp));
+ }
+
const match = n.toString().match(/\.(\d+)/);
return match ? match[1].length : 0;
} Also consider adding JSDoc documentation to describe the function's purpose and behavior: /**
* Counts the number of decimal places in a given number.
* @param n - The number to analyze
* @returns The count of decimal places (0 for integers, NaN, or Infinity)
* @example
* countDecimalPlaces(1.23) // returns 2
* countDecimalPlaces(1) // returns 0
* countDecimalPlaces(1e-10) // returns 10
*/ |
||
|
||
export function fixFloatingPoint (_number: number | string, decimalDigit = FLOATING_POINT_DIGIT, commify?: boolean, dynamicDecimal?: boolean): string { | ||
const MAX_DECIMAL_POINTS = 6; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
💡 Codebase verification
Based on the gathered information, I can now provide the final response regarding the accessibility concerns of the CountUp component.
Add accessibility attributes to CountUp implementation
The current CountUp implementation lacks proper accessibility considerations. While the codebase shows awareness of reduced motion preferences in other components, the numeric animation needs similar treatment. Please update the implementation to:
prefersReducedMotion
check fromuseAnimateOnce.ts
This will ensure:
🔗 Analysis chain
Verify accessibility impact
Please ensure that the CountUp animation:
Let me check the content of these files to understand the existing accessibility implementations.
Let me check if there are any existing ARIA attributes or accessibility considerations in the FormatPrice component, and also check the react-countup package usage.
Let me check the TotalBalancePieChart component to see how CountUp is implemented there, and also verify the package.json for the react-countup version and any related accessibility packages.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 170
Script:
Length of output: 4728
Script:
Length of output: 307
Script:
Length of output: 11484