Skip to content

Add RelativeDate component with auto-updating functionality#306

Open
T-kesh wants to merge 2 commits intoamina69:mainfrom
T-kesh:main
Open

Add RelativeDate component with auto-updating functionality#306
T-kesh wants to merge 2 commits intoamina69:mainfrom
T-kesh:main

Conversation

@T-kesh
Copy link
Copy Markdown
Contributor

@T-kesh T-kesh commented Mar 30, 2026

This PR introduces the RelativeDate shared primitive component, a reusable React component that displays dates in relative, human-readable format (e.g., "2 hours ago") with automatic updates every 60 seconds. The component accepts both Date objects and ISO string dates as input, leverages date-fns's formatDistanceToNow utility for consistent formatting, and displays the absolute date on hover via the title attribute for accessibility. The implementation includes proper lifecycle management with automatic interval cleanup on unmount to prevent memory leaks. The component is fully tested with 8 comprehensive unit tests covering correct initial rendering with both input types, title attribute functionality, interval setup and cleanup, and consistent behavior across different date formats. This primitive is ready for use throughout the application wherever relative timestamps are needed.
close #286

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 30, 2026

@T-kesh Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@amina69
Copy link
Copy Markdown
Owner

amina69 commented Mar 30, 2026

@T-kesh pipeline failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Frontend · Shared primitives] Create shared RelativeTime component

2 participants