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

AboutVersionTitle.tsx

53 lines1.5 KB

1import { msg, T, useGT } from "gt-react";
2​
3import { APP_VERSION } from "../../branding";
4import { useCopyToClipboard } from "../../hooks/useCopyToClipboard";
5import { InlineButton } from "../ui/button";
6import { stackedThreadToast, toastManager } from "../ui/toast";
7import { SharedTooltipTrigger } from "../ui/shared-tooltip";
8​
9export function AboutVersionTitle() {
10 const gt = useGT();
11 const { copyToClipboard } = useCopyToClipboard<void>({
12 target: {
13 target: "version",
14 unavailableMessage: msg("Clipboard API is unavailable while copying version."),
15 failureMessage: msg("Failed to copy version to the clipboard."),
16 },
17 onError: (error) => {
18 toastManager.add(
19 stackedThreadToast({
20 type: "error",
21 title: gt("Could not copy version"),
22 description: error.message,
23 }),
24 );
25 },
26 });
27​
28 return (
29 <span className="inline-flex items-baseline gap-2">
30 <span>
31 <T>Version</T>
32 </span>
33 <code className="text-2xs font-medium">
34 <SharedTooltipTrigger
35 render={
36 <InlineButton
37 tone="muted"
38 aria-label={gt("Copy version {version}", { version: APP_VERSION })}
39 onClick={() => copyToClipboard(APP_VERSION, undefined)}
40 >
41 {APP_VERSION}
42 </InlineButton>
43 }
44 label={
45 <>
46 <T>Copy version</T>
47 </>
48 }
49 />
50 </code>
51 </span>
52 );