Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

PullRequestMoreReplies.tsx

43 lines1.3 KB

1import type { ScopedThreadRef } from "@t3tools/contracts";
2import { T, useGT } from "gt-react";
3​
4import { useOpenLink } from "~/browser/useOpenLink";
5​
6import type { PullRequestReplyAvailability } from "./pullRequestDetail.logic";
7​
8export function PullRequestMoreReplies({
9 moreReplies,
10 hasMoreReplies,
11 url,
12 threadRef,
13}: PullRequestReplyAvailability & { threadRef: ScopedThreadRef | null }) {
14 const gt = useGT();
15 const openLink = useOpenLink(threadRef);
16 if (!hasMoreReplies) return null;
17 return (
18 <div className="flex flex-wrap items-baseline gap-2 py-1 text-xs text-muted-foreground">
19 <span>
20 {moreReplies > 0
21 ? gt("{count, plural, one {{formatted} more reply} other {{formatted} more replies}}", {
22 count: moreReplies,
23 formatted: moreReplies.toLocaleString(),
24 })
25 : gt("More replies")}
26 </span>
27 {url ? (
28 <a
29 href={url}
30 target="_blank"
31 rel="noopener noreferrer"
32 className="hover:text-foreground hover:underline"
33 onClick={(event) => {
34 event.preventDefault();
35 void openLink(url, { event }).catch(console.error);
36 }}
37 >
38 <T>View on host</T>
39 </a>
40 ) : null}
41 </div>
42 );