Commit 4998df4
authored
fix(description-card): handle negative diff in relative date & use SPA navigation for links (#264)
* fix(description-card): handle negative diff in relative date format
When updatedAt is slightly in the future relative to now (e.g., due to
server clock differences after redirect from edit page), Math.floor of
a small negative number produces -1, which displayed as '-1 days ago'.
Fix: treat any negative diffDays as 'Today'.
Also adds tests for renderField covering text, badge, date, money,
link, and address field types.
* Format files
* fix(description-card): use react-router Link for internal navigation
Replace <a href> with react-router <Link to> in LinkFieldRenderer (for
internal links) and ReferenceFieldRenderer to enable SPA navigation
instead of full page reloads. External links (meta.external: true) still
use <a target="_blank">.
Also adds reference field tests and improves link field test coverage.
* feat(description-card): show minutes/hours in relative date & support future dates
- Replace 'Today' with granular 'X minutes ago' / 'X hours ago'
- Add future date support: 'In X minutes', 'In X hours', 'Tomorrow', etc.
- Add 'Just now' for diffs under 1 minute (past and future)
- Add comprehensive tests for all relative date thresholds
- Add table-formatted doc comment for formatDate function
* feat(description-card): add i18n support for relative date labels
- Add i18n.ts with en/ja translations for all relative date strings
- Use useDescriptionCardT hook in DateFieldRenderer
- formatDate accepts optional t function, falls back to English
- Fix circular dependency in tests by reordering imports
- Add AppShell context wrapper to DescriptionCard tests
* chore: add changeset for description-card fixes1 parent 70fb128 commit 4998df4
5 files changed
Lines changed: 721 additions & 18 deletions
File tree
- .changeset
- packages/core/src/components/description-card
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| |||
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| 40 | + | |
36 | 41 | | |
37 | 42 | | |
38 | 43 | | |
| |||
0 commit comments