refactor: cleanup ecash nuts embed

closes #718
This commit is contained in:
2024-04-12 11:56:10 +01:00
parent 2f76dd9b10
commit f601e88b8f
4 changed files with 79 additions and 86 deletions

View File

@ -9,15 +9,16 @@ export interface CopyProps {
text: string;
maxSize?: number;
className?: string;
showText?: boolean;
}
export default function Copy({ text, maxSize = 32, className }: CopyProps) {
export default function Copy({ text, maxSize = 32, className, showText }: CopyProps) {
const { copy, copied } = useCopy();
const sliceLength = maxSize / 2;
const trimmed = text.length > maxSize ? `${text.slice(0, sliceLength)}...${text.slice(-sliceLength)}` : text;
return (
<div className={classNames("copy flex pointer g8 items-center", className)} onClick={() => copy(text)}>
<span className="copy-body">{trimmed}</span>
{(showText ?? true) && <span className="copy-body">{trimmed}</span>}
<span className="icon" style={{ color: copied ? "var(--success)" : "var(--highlight)" }}>
{copied ? <Icon name="check" size={14} /> : <Icon name="copy-solid" size={14} />}
</span>