|
@@ -1,7 +1,6 @@
|
|
|
import React, { useState } from "react";
|
|
|
import styled from "styled-components";
|
|
|
import useCopying from "./useCopying";
|
|
|
-import CopyingTooltip from "./CopyingTooltip";
|
|
|
|
|
|
const Container = styled.div`
|
|
|
position: relative;
|
|
@@ -13,6 +12,20 @@ const UnderlinedSpan = styled.span`
|
|
|
border-bottom: 1px dashed #bbb;
|
|
|
`
|
|
|
|
|
|
+const ToolTip = styled.span`
|
|
|
+ background-color: black;
|
|
|
+ color: white;
|
|
|
+ text-align: center;
|
|
|
+ padding: 2px 8px;
|
|
|
+ border-radius: 8px;
|
|
|
+ position: absolute;
|
|
|
+ z-index: 1;
|
|
|
+ top: -115%;
|
|
|
+ white-space: nowrap;
|
|
|
+ transition: opacity 0.25s;
|
|
|
+ opacity: ${({ show }) => show ? 0.75 : 0};
|
|
|
+`
|
|
|
+
|
|
|
export default ({ text }) => {
|
|
|
const [textareaChild, copyText] = useCopying(text);
|
|
|
const [hovered, setHovered] = useState(false);
|
|
@@ -27,7 +40,9 @@ export default ({ text }) => {
|
|
|
>
|
|
|
{text}
|
|
|
</UnderlinedSpan>
|
|
|
- <CopyingTooltip hovered={hovered} copied={copied}/>
|
|
|
+ <ToolTip show={hovered}>
|
|
|
+ {copied ? "Copied!" : "Click to Copy"}
|
|
|
+ </ToolTip>
|
|
|
{textareaChild}
|
|
|
</Container>
|
|
|
)
|