[progress][meter] De-duplicate formatValue function#3805
Conversation
commit: |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR de-duplicates the formatValue function that was identically implemented in both the Progress and Meter components by extracting it to a shared utility module. This refactoring reduces bundle size by 68 bytes without affecting functionality or readability, supporting the ongoing effort to optimize Base UI's bundle size (issue #3688).
Changes:
- Extracted the
formatValuefunction toutils/formatNumber.tsas a shared utility - Updated ProgressRoot and MeterRoot to import the shared function instead of maintaining local copies
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/react/src/utils/formatNumber.ts |
Added the shared formatValue function that handles value formatting with optional locale and format options |
packages/react/src/progress/root/ProgressRoot.tsx |
Removed local formatValue function and imported the shared version from utils |
packages/react/src/meter/root/MeterRoot.tsx |
Removed local formatValue function and imported the shared version from utils |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile SummaryDeduplicates the
Confidence Score: 5/5
Important Files Changed
|
Greptile's behavior is changing!From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section. This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR". |
| }); | ||
| } | ||
|
|
||
| export function formatValue( |
There was a problem hiding this comment.
Nitpick: Given that this is now a more global util, I feel like formatNumberValue might be a more precise name for it. 🤔
WDYT?
There was a problem hiding this comment.
Yes, makes sense. I'll update and merge
…base-ui into deduplicate-formatvalue
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
I was going through this issue #3688 and this comment #3709 (comment), changes in this PR reduced size by 68B without hurting readability. Felt it as quick win