diff --git a/src/lib/index.tsx b/src/lib/index.tsx index 50d1eb6..567b982 100644 --- a/src/lib/index.tsx +++ b/src/lib/index.tsx @@ -1,4 +1,4 @@ -import React, { MouseEvent } from "react"; +import React, { MouseEvent, CSSProperties, ReactNode, useState, useEffect } from "react"; type theme = "dark" | "light"; @@ -23,11 +23,11 @@ const copyToClipboard = (str: string) => { } }; -const containerBaseStyles: React.CSSProperties = { +const containerBaseStyles: CSSProperties = { position: "relative", }; -const tooltipBaseStyles = (theme: string): React.CSSProperties => ({ +const tooltipBaseStyles = (theme: string): CSSProperties => ({ bottom: "26px", maxWidth: "fit-content", position: "absolute", @@ -48,7 +48,7 @@ const tooltipBaseStyles = (theme: string): React.CSSProperties => ({ transition: "all 0.2s ease-in-out", }); -const toolTipVisibleStyles: React.CSSProperties = { +const toolTipVisibleStyles: CSSProperties = { opacity: 1, transform: "none", visibility: "visible", @@ -66,15 +66,15 @@ const CopyMailTo = ({ }: { email: string; theme?: theme; - children?: React.ReactNode; + children?: ReactNode; defaultTooltip?: string; copiedTooltip?: string; - containerStyles?: React.CSSProperties; - tooltipStyles?: React.CSSProperties; - anchorStyles?: React.CSSProperties; + containerStyles?: CSSProperties; + tooltipStyles?: CSSProperties; + anchorStyles?: CSSProperties; }): JSX.Element => { - const [showCopied, setShowCopied] = React.useState(false); - const [showTooltip, setShowTooltip] = React.useState(false); + const [showCopied, setShowCopied] = useState(false); + const [showTooltip, setShowTooltip] = useState(false); const copyEmail = (e: MouseEvent) => { e.preventDefault(); @@ -87,7 +87,7 @@ const CopyMailTo = ({ setShowTooltip(prevTooltipState => !prevTooltipState); }; - React.useEffect(() => { + useEffect(() => { let intervalId: number; if (showCopied) { intervalId = window.setTimeout(() => {