|
@@ -1,24 +1,34 @@
|
|
|
import React, { useState } from "react";
|
|
|
+import styled from "styled-components";
|
|
|
import useCopying from "./useCopying";
|
|
|
import CopyingTooltip from "./CopyingTooltip";
|
|
|
|
|
|
+const Container = styled.div`
|
|
|
+ position: relative;
|
|
|
+ display: inline-flex;
|
|
|
+ justify-content: center;
|
|
|
+`
|
|
|
+
|
|
|
+const UnderlinedSpan = styled.span`
|
|
|
+ border-bottom: 1px dashed #bbb;
|
|
|
+`
|
|
|
+
|
|
|
export default ({ text }) => {
|
|
|
const [textareaChild, copyText] = useCopying(text);
|
|
|
const [hovered, setHovered] = useState(false);
|
|
|
const [copied, setCopied] = useState(false);
|
|
|
|
|
|
return (
|
|
|
- <div className="click-to-copy">
|
|
|
- <span
|
|
|
- className="click-to-copy__text"
|
|
|
+ <Container>
|
|
|
+ <UnderlinedSpan
|
|
|
onClick={() => {copyText(); setCopied(true)}}
|
|
|
onMouseOver={() => {setCopied(false); setHovered(true)}}
|
|
|
onMouseOut={() => setHovered(false)}
|
|
|
>
|
|
|
{text}
|
|
|
- </span>
|
|
|
+ </UnderlinedSpan>
|
|
|
<CopyingTooltip hovered={hovered} copied={copied}/>
|
|
|
{textareaChild}
|
|
|
- </div>
|
|
|
+ </Container>
|
|
|
)
|
|
|
}
|