1import type { RefObject } from "react";
2import { anchoredToastManager } from "./toast";
3
4export const ANCHORED_COPY_TOAST_TIMEOUT_MS = 1000;
5
6export function showAnchoredCopySuccessToast(ref: RefObject<HTMLButtonElement | null>) {
7 if (!ref.current) return;
8 anchoredToastManager.add({
9 data: {
10 tooltipStyle: true,
11 },
12 positionerProps: {
13 anchor: ref.current,
14 },
15 timeout: ANCHORED_COPY_TOAST_TIMEOUT_MS,
16 title: "Copied!",
17 });
18}
19
20export function showAnchoredCopyErrorToast(ref: RefObject<HTMLButtonElement | null>, error: Error) {
21 if (!ref.current) return;
22 anchoredToastManager.add({
23 data: {
24 tooltipStyle: true,
25 },
26 positionerProps: {
27 anchor: ref.current,
28 },
29 timeout: ANCHORED_COPY_TOAST_TIMEOUT_MS,
30 title: "Failed to copy",
31 description: error.message,
32 });
33}