-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use
RelativeTime
instead of TimeAgo
- Loading branch information
Showing
16 changed files
with
441 additions
and
345 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react' | ||
import {type RelativeTimeOptions, useRelativeTime} from '../hooks/useRelativeTime' | ||
|
||
export interface RelativeTimeProps extends RelativeTimeOptions { | ||
time: string | Date | ||
} | ||
|
||
export function RelativeTime({time, ...options}: RelativeTimeProps) { | ||
const timestamp = time instanceof Date ? time : new Date(time) | ||
const timeAgo = useRelativeTime(timestamp, options) | ||
|
||
return ( | ||
<time dateTime={timestamp.toISOString()} title={timeAgo}> | ||
{timeAgo} | ||
</time> | ||
) | ||
} |
This file contains 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
18 changes: 0 additions & 18 deletions
18
packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/utils/TimeAgo.tsx
This file was deleted.
Oops, something went wrong.
This file contains 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
18 changes: 0 additions & 18 deletions
18
packages/sanity/src/core/form/inputs/ReferenceInput/utils/TimeAgo.tsx
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.