on b7567cf help sign in
bridge/src/components/CopiableWithTooltip.js
29 lines 698 B history raw
1import React from 'react';
2import cn from 'classnames';
3import { ReactComponent as Copy } from 'assets/copy.svg';
5import useCopiable from 'lib/useCopiable';
6import WithTooltip from 'components/WithTooltip';
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={cn(className, 'nowrap')} {...rest}>
19 {children}
20 <WithTooltip content={didCopy ? 'Copied!' : 'Copy'}>
21 <Copy
22 style={{ height: '1em', width: '1em' }}
23 className="ml1 pointer"
24 onClick={doCopy}
25 />
26 </WithTooltip>
27 </As>
28 );