import React from "react"; import clsx from "clsx"; import { ChangingTextElement, ChangingTextElementRef, } from "./changing-text-element"; import { LandingCopySuccessIcon } from "./icons/landing-copy-success"; const installText = "bash <(curl -sSL https://get.openpanel.co/)"; const copiedText = "copied to clipboard!"; export const LandingCopyCommandButton = ({ className, }: { className?: string; }) => { const changingTextRef = React.useRef(null); const copyTimeoutRef = React.useRef(null); const [copied, setCopied] = React.useState(false); const [fadedOut, setFadedOut] = React.useState(false); const onCopy = () => { if (changingTextRef.current) { if (copyTimeoutRef.current) clearTimeout(copyTimeoutRef.current); setCopied(false); changingTextRef.current.start(); // copy to clipboard navigator.clipboard.writeText(installText); copyTimeoutRef.current = setTimeout(() => { setFadedOut(true); setTimeout(() => { changingTextRef.current?.reset(); setFadedOut(false); }, 300); }, 3000); } }; return ( ); };