Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Amount] Improve formatting capabilities and fix edge cases

Đang mở
#595 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu bằng cách xác định component Amount và cách sử dụng Intl.NumberFormat của nó, sau đó kiểm tra các prop currencyDisplay hiện có và các luồng định dạng. Công việc hoàn tất khi các tùy chọn notation, narrowSymbol và signDisplay được hỗ trợ, việc tạo formatter được ghi nhớ hoặc kết hợp, và các giá trị ngắn được định dạng chính xác.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

component triage

Summary

Improvements to the Amount component to enhance formatting capabilities, fix edge cases, and follow component conventions.

Improvements

2. Add notation prop

No way to get compact formatting like $1.2M or $13K. Intl.NumberFormat supports notation: 'compact' natively. This is useful for dashboards and summary views.

3. Add narrowSymbol to currencyDisplay

Intl.NumberFormat supports 'narrowSymbol' (e.g., $ instead of US$ in non-US locales), but the currencyDisplay prop only allows 'symbol' | 'code' | 'name'.

4. Add signDisplay prop

Intl.NumberFormat supports signDisplay ('auto', 'always', 'exceptZero', 'never') for controlling +/- sign display — useful for showing gains/losses.

5. Memoize formatter instances

getCurrencyDecimals() and isValidCurrency() each create a new Intl.NumberFormat instance on every render. These should be memoized or combined into a single formatter creation.

6. Fix string slicing edge case for short strings

value.slice(0, -decimals) + '.' + value.slice(-decimals) breaks for strings shorter than the decimal count (e.g., value="5" with USD → ".5" instead of "0.05").

Moved to Cross-Cutting Issues

The following items have been moved to cross-cutting issues that address them across all components:

  • Forward HTML attributes (#674)
  • TypeScript strictness (#675)
Ngôn ngữ chính
TypeScript
Star
70
Fork
13
Merge trung bình
4 ngày 6 giờ
Pull request đã merge (30 ngày)
10

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của raystack/apsara

Tất cả issue của raystack/apsara

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.