25 lines
684 B
JavaScript
25 lines
684 B
JavaScript
import React from 'react';
|
|
|
|
function ContactButton({ buttonText, email }) {
|
|
const [copied, setCopied] = React.useState(false);
|
|
|
|
const handleClick = () => {
|
|
navigator.clipboard.writeText(email);
|
|
setCopied(true);
|
|
setTimeout(() => {
|
|
setCopied(false);
|
|
}, 2000);
|
|
};
|
|
|
|
return (
|
|
<button
|
|
type="button"
|
|
className="px-20 mt-8 mx-5 py-2 text-white border rounded focus:outline-none border-white transition duration-300 ease-in-out hover:border-blue-500 transition duration-300 ease-in-out"
|
|
onClick={handleClick}
|
|
>
|
|
{copied ? 'Email copied to your clipboard.' : !copied && buttonText}
|
|
</button>
|
|
);
|
|
}
|
|
|
|
export default ContactButton; |