MCPcopy Create free account
hub / github.com/dailydotdev/apps / CopyBlock

Function CopyBlock

packages/shared/src/components/CopyBlock.tsx:14–64  ·  view source on GitHub ↗
({
  text,
  label,
  height,
  isFaded,
  secondary,
  onCopy,
}: {
  text: string;
  label: string;
  height?: number;
  isFaded?: boolean;
  secondary?: ReactNode;
  onCopy: () => void;
})

Source from the content-addressed store, hash-verified

12 * every client the same size, and long text fades out at the cut.
13 */
14export const CopyBlock = ({
15 text,
16 label,
17 height,
18 isFaded,
19 secondary,
20 onCopy,
21}: {
22 text: string;
23 label: string;
24 height?: number;
25 isFaded?: boolean;
26 secondary?: ReactNode;
27 onCopy: () => void;
28}): ReactElement => {
29 const [isCopying, copy] = useCopyLink(() => text);
30
31 return (
32 <div className="flex flex-col gap-2">
33 <div className="rounded-16 border border-border-subtlest-tertiary bg-surface-float">
34 <pre
35 className={classNames(
36 'whitespace-pre-wrap break-words p-4 font-mono text-text-secondary typo-footnote',
37 isFaded ? 'overflow-hidden' : 'overflow-y-auto',
38 )}
39 style={{
40 height,
41 maskImage: isFaded ? PROMPT_FADE : undefined,
42 WebkitMaskImage: isFaded ? PROMPT_FADE : undefined,
43 }}
44 >
45 {text}
46 </pre>
47 </div>
48 <div className="flex gap-2">
49 <Button
50 className="min-w-0 flex-1"
51 variant={ButtonVariant.Primary}
52 icon={isCopying ? <VIcon /> : <CopyIcon />}
53 onClick={() => {
54 copy();
55 onCopy();
56 }}
57 >
58 {isCopying ? 'Copied' : label}
59 </Button>
60 {secondary}
61 </div>
62 </div>
63 );
64};

Callers

nothing calls this directly

Calls 3

useCopyLinkFunction · 0.90
copyFunction · 0.85
onCopyFunction · 0.50

Tested by

no test coverage detected