Skip to content

Commit 88c723a

Browse files
feat(tracker): rework date display on tracker's list
Also propagate Intl allocation optimizations from the previous commit & adjust icon size for images to avoid shifting
1 parent c319c09 commit 88c723a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/routes/tracker/[org]/[repo]/+page.svelte

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
| Awaited<NonNullable<typeof data.prs>>[number]
1818
| Awaited<NonNullable<typeof data.discussions>>[number];
1919
20+
const daysAgoFormatter = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
21+
const shortDateFormatter = new Intl.DateTimeFormat("en", { dateStyle: "medium" });
22+
2023
/**
2124
* Checks whether a date is more recent than a month.
2225
*
@@ -35,7 +38,7 @@
3538
*/
3639
function daysAgo(date: Date) {
3740
const days = Math.floor((Date.now() - date.getTime()) / 1000 / 60 / 60 / 24);
38-
return new Intl.RelativeTimeFormat("en", { numeric: "auto" }).format(-days, "day");
41+
return daysAgoFormatter.format(-days, "day");
3942
}
4043
4144
/**
@@ -84,7 +87,8 @@
8487
<!-- prettier-ignore -->
8588
{#snippet listItem(item: Item, link: string)}
8689
{@const lastUpdate = new Date(item.updated_at)}
87-
{@const isUpdated = !areSameDay(lastUpdate, new Date(item.created_at))}
90+
{@const createdAt = new Date(item.created_at)}
91+
{@const isUpdated = !areSameDay(lastUpdate, createdAt)}
8892

8993
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
9094
<a href={link} class="flex items-center gap-6 rounded-md px-4 py-3 transition-colors hover:bg-neutral-100 dark:hover:bg-neutral-800">
@@ -114,15 +118,11 @@
114118
<MarkdownRenderer markdown={item.title} inline class="text-foreground" />
115119
<span class="text-muted-foreground">#{item.number}</span>
116120
</span>
117-
<span class="text-right">
118-
{#if isNew(lastUpdate)}
119-
{daysAgo(lastUpdate)} •
121+
<span class="text-right text-nowrap">
122+
{#if isUpdated && isNew(lastUpdate)}
123+
<span class="italic font-semibold">updated {daysAgo(lastUpdate)}</span>
120124
{/if}
121-
<span class={{ italic: isUpdated }}>
122-
{new Intl.DateTimeFormat("en", {
123-
dateStyle: "medium"
124-
}).format(lastUpdate)}
125-
</span>
125+
<span>{shortDateFormatter.format(createdAt)}</span>
126126
</span>
127127
</div>
128128
<MarkdownRenderer
@@ -154,7 +154,7 @@
154154
>
155155
{#snippet img({ alt })}
156156
<div>
157-
<Image class="inline-block h-lh" />
157+
<Image class="inline-block h-[.9lh]" />
158158
{alt}
159159
</div>
160160
{/snippet}

0 commit comments

Comments
 (0)