({
text,
label,
height,
isFaded,
secondary,
onCopy,
}: {
text: string;
label: string;
height?: number;
isFaded?: boolean;
secondary?: ReactNode;
onCopy: () => void;
})
| 12 | * every client the same size, and long text fades out at the cut. |
| 13 | */ |
| 14 | export 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 | }; |
nothing calls this directly
no test coverage detected