-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(i18n): use Intl APIs for TimeAgo
component
#4990
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
Full Reportsanity
sanity/desk
@sanity/diff
@sanity/block-tools
@sanity/portable-text-editor
@sanity/mutator
@sanity/cli
@sanity/schema/_internal
@sanity/util/paths
sanity/router
@sanity/util/legacyDateFormat
@sanity/schema
sanity/cli
@sanity/vision
@sanity/util/fs
sanity/_internal
@sanity/util/content
@sanity/types
|
Component Testing Report Updated Oct 16, 2023 9:22 PM (UTC)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is solid, lgtm!
@@ -51,22 +51,22 @@ describe('useTimeAgo', () => { | |||
expect(result.current).toBe('Jun 3, 2022') | |||
}) | |||
|
|||
it('outputs eg "3w" if less than a month apart', () => { | |||
it('outputs eg "3 wks" if less than a month apart', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this replace the "3w" short format with the slightly longer "3 wks" all over? Since these are used in confined areas of the UI, will this risk running into issues with text no longer fitting the space it's given?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does! @mikolajdobrucki approved this from the design side, but we should still have a look around and see if anything breaks - but we can easily change this after merging if problematic.
56d0638
to
cd7acf7
Compare
Description
Note: review this commit by commit to more easily understand things.
intlCache
. We will need to instantiate several different instances of the Intl APIs with differing options, and this is a semi-costly operation. The cache ensures we reuse instances where possible.useIntlListFormat
hook utilize said cache to prove it works (also, why not)useTimeAgo
hook to allow for both past and future dates (X days ago, in Y hours)useTimeAgo
hook use i18n primitivesuseTimeAgo
and theTimeAgo
component touseRelativeTime
andRelativeTime
, respectively. This is done because it more closely aligns with theIntl.RelativeTimeFormat
API, as well as indicating that it can now show dates in the future as well.Closes SDX-677