Skip to content

automatically provide localised Date for SSR in RelativeTime - #4305

Merged
keithamus merged 6 commits into
mainfrom
automatically-provide-localised-date-for-ssr-in-relativetime
Mar 19, 2024
Merged

automatically provide localised Date for SSR in RelativeTime#4305
keithamus merged 6 commits into
mainfrom
automatically-provide-localised-date-for-ssr-in-relativetime

Conversation

@keithamus

@keithamuskeithamus commented Feb 26, 2024

Copy link
Copy Markdown
Contributor

Closes#4361

Changelog

New

<RelativeTime/> now renders dates in SSR.

Changed

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@changeset-bot

changeset-botBot commented Feb 26, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ff29e49

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
@primer/reactPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
github-actionsBottemporarily deployed to storybook-preview-4305 February 26, 2024 12:47 Inactive
@keithamus
keithamusforce-pushed the automatically-provide-localised-date-for-ssr-in-relativetime branch 2 times, most recently from db5e8a1 to 79e23a9CompareMarch 6, 2024 12:02
@keithamus
keithamusforce-pushed the automatically-provide-localised-date-for-ssr-in-relativetime branch from 79e23a9 to 5eaee82CompareMarch 6, 2024 12:03
@keithamus
keithamus marked this pull request as ready for review March 6, 2024 12:06
@keithamus
keithamus requested review from a team and broccolinisoupMarch 6, 2024 12:06
@github-actions

github-actionsBot commented Mar 6, 2024

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
packages/react/dist/browser.esm.js87.54 KB (+0.14% 🔺)
packages/react/dist/browser.umd.js87.81 KB (+0.07% 🔺)

Comment threadpackages/react/src/RelativeTime/RelativeTime.tsx Outdated
const localeOptions: Intl.DateTimeFormatOptions = {month: 'short', day: 'numeric', year: 'numeric'}
function RelativeTime({date, ...props}: RelativeTimeProps) {
return (
<RelativeTimeComponent {...props} date={date}>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I pass datetime instead of date, like <RelativeTime datetime="2024-03-10T16:30:00-08:00" /> in a sample app, it doesn't render any date in SSR. Seems like the props return undefined. Is there anything I am missing here? 🤔

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed this and added tests to confirm.

@camertroncamertron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to write a test that confirms the date is localized correctly in non English-speaking locales?

@keithamus

Copy link
Copy Markdown
ContributorAuthor

Is it possible to write a test that confirms the date is localized correctly in non English-speaking locales?

It won't be as the aim is to ensure it is localised to a fixed locale, so as not to impact caching.

@keithamus
keithamus added this pull request to the merge queueMar 19, 2024
Merged via the queue into main with commit 37c4770Mar 19, 2024
@keithamus
keithamus deleted the automatically-provide-localised-date-for-ssr-in-relativetime branch March 19, 2024 18:42
@primerprimerBot mentioned this pull request Mar 19, 2024
lukasoppermann pushed a commit that referenced this pull request Apr 16, 2024
* automatically provide localised Date for SSR in RelativeTime
* changeset
* fix and add tests
* format
* fix types
Sign up for freeto 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.

RelativeTime should render some kind of date in SSR

3 participants

@keithamus@camertron@broccolinisoup