Add RelativeDate component with auto-updating functionality#306
Open
T-kesh wants to merge 2 commits intoamina69:mainfrom
Open
Add RelativeDate component with auto-updating functionality#306T-kesh wants to merge 2 commits intoamina69:mainfrom
T-kesh wants to merge 2 commits intoamina69:mainfrom
Conversation
|
@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! 🚀 |
Owner
|
@T-kesh pipeline failed |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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