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

anchoredCopyToast.ts

19 lines523 Bytes

1import type { RefObject } from "react";
2import { msg } from "gt-react";
3​
4import { m } from "~/i18n/messages";
5import { anchoredToastManager } from "./toast";
6​
7export const ANCHORED_COPY_TOAST_TIMEOUT_MS = 1000;
8​
9export function showAnchoredCopyErrorToast(ref: RefObject<HTMLButtonElement | null>, error: Error) {
10 if (!ref.current) return;
11 anchoredToastManager.add({
12 type: "error",
13 positionerProps: {
14 anchor: ref.current,
15 },
16 title: m(msg("Failed to copy")),
17 description: error.message,
18 });