mirror of
https://github.com/outline/outline.git
synced 2026-11-23 06:11:04 +03:00
* chore: Remove unused lint disable directives Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Replace TODO type suppressions with typed code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Remove obsolete workaround comments in tests and MediaDimension Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Remove Tippy compatibility props from Tooltip Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Decouple DropdownMenu props from Tooltip and clarify sharing styles Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Remove stale retention TODOs from cleanup tasks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Register relations synchronously and clarify workaround comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Replace Notion import TODOs with descriptive comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH --------- Co-authored-by: Claude <noreply@anthropic.com>
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import { LinkIcon } from "outline-icons";
|
|
import * as React from "react";
|
|
import { toast } from "sonner";
|
|
import CopyToClipboard from "~/components/CopyToClipboard";
|
|
import NudeButton from "~/components/NudeButton";
|
|
import Tooltip from "~/components/Tooltip";
|
|
|
|
type Props = {
|
|
/** The value to be copied */
|
|
value: string;
|
|
/** The message to show when the value is copied */
|
|
success: string;
|
|
/** The tooltip message */
|
|
tooltip: string;
|
|
/** An optional icon */
|
|
icon?: React.ReactNode;
|
|
};
|
|
|
|
/**
|
|
* A button that copies a value to the clipboard when clicked and shows a
|
|
* single icon.
|
|
*/
|
|
export function CopyButton({
|
|
value,
|
|
success,
|
|
tooltip,
|
|
icon = <LinkIcon size={20} />,
|
|
}: Props) {
|
|
const timeout = React.useRef<ReturnType<typeof setTimeout> | undefined>(
|
|
undefined
|
|
);
|
|
|
|
const handleCopied = React.useCallback(() => {
|
|
timeout.current = setTimeout(() => {
|
|
toast.message(success);
|
|
}, 100);
|
|
|
|
return () => {
|
|
if (timeout.current) {
|
|
clearTimeout(timeout.current);
|
|
}
|
|
};
|
|
}, [success]);
|
|
|
|
return (
|
|
<Tooltip content={tooltip}>
|
|
<CopyToClipboard text={value} onCopy={handleCopied}>
|
|
<NudeButton type="button">{icon}</NudeButton>
|
|
</CopyToClipboard>
|
|
</Tooltip>
|
|
);
|
|
}
|