on bab2fa8 help sign in
bridge/src/components/copiable/CopiableWithTooltip.js
30 lines 720 B history raw
1import React from 'react';
2import { ReactComponent as Copy } from 'assets/copy.svg';
4import useCopiable from 'lib/useCopiable';
5import WithTooltip from 'components/WithTooltip';
6import { Icon } from '@tlon/indigo-react';
8export default function CopiableWithTooltip({
9 as: As = 'span',
10 text,
11 children,
12 className,
13 ...rest
14}) {
15 const [doCopy, didCopy] = useCopiable(text || children);
17 return (
18 <As className={className} {...rest}>
19 {children}
20 <WithTooltip content={didCopy ? 'Copied!' : 'Copy'}>
21 <Icon
22 icon="Copy"
23 style={{ height: '1em', width: '1em' }}
24 className="ml1 pointer"
25 onClick={doCopy}
26 />
27 </WithTooltip>
28 </As>
29 );