sendou.ink/app/components/CopyToClipboardPopover.tsx
Kalle 9e829614ed
Some checks are pending
E2E Tests / e2e (push) Waiting to run
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run
Replace react-use dependency with a few helpers
2026-06-12 22:40:50 +03:00

36 lines
986 B
TypeScript

import { Check, Clipboard } from "lucide-react";
import type * as React from "react";
import { useTranslation } from "react-i18next";
import { SendouButton } from "~/components/elements/Button";
import { SendouPopover } from "~/components/elements/Popover";
import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
interface CopyToClipboardPopoverProps {
url: string;
trigger: React.ReactNode;
}
export function CopyToClipboardPopover({
trigger,
url,
}: CopyToClipboardPopoverProps) {
const { t } = useTranslation(["common"]);
const { copyToClipboard, copySuccess } = useCopyToClipboard();
return (
<SendouPopover trigger={trigger}>
<div className="stack sm">
<input defaultValue={url} readOnly />
<SendouButton
size="miniscule"
variant="minimal"
onPress={() => copyToClipboard(url)}
icon={copySuccess ? <Check /> : <Clipboard />}
>
{t("common:actions.copyToClipboard")}
</SendouButton>
</div>
</SendouPopover>
);
}