on cedd040 help sign in
bridge/src/components/CopiableWithTooltip.js
28 lines 655 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';
7export default function CopiableWithTooltip({
8 as: As = 'span',
9 text,
10 children,
11 className,
12 ...rest
13}) {
14 const [doCopy, didCopy] = useCopiable(text || children);
16 return (
17 <As className={className} {...rest}>
18 {children}
19 <WithTooltip content={didCopy ? 'Copied!' : 'Copy'}>
20 <Copy
21 style={{ height: '1em', width: '1em' }}
22 className="ml1 pointer"
23 onClick={doCopy}
24 />
25 </WithTooltip>
26 </As>
27 );