import "./Copy.css"; import Icon from "Icons/Icon"; import { useCopy } from "useCopy"; export interface CopyProps { text: string; maxSize?: number; className?: string; } export default function Copy({ text, maxSize = 32, className }: CopyProps) { const { copy, copied } = useCopy(); const sliceLength = maxSize / 2; const trimmed = text.length > maxSize ? `${text.slice(0, sliceLength)}...${text.slice(-sliceLength)}` : text; return (
copy(text)}> {trimmed} {copied ? : }
); }