Skip to content

Commit cdfcbad

Browse files
committed
instead of mailto:xxx, click the email address should copy the email to clipboard
1 parent d305ca1 commit cdfcbad

File tree

1 file changed

+69
-1
lines changed

1 file changed

+69
-1
lines changed

src/pages/index.tsx

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
44
import Layout from "@theme/Layout";
55
import HomepageFeatures from "@site/src/components/HomepageFeatures";
66
import Heading from "@theme/Heading";
7+
import { useState } from "react";
78

89
import styles from "./index.module.css";
910
import "@radix-ui/themes/styles.css";
@@ -459,6 +460,18 @@ function Team() {
459460
}
460461

461462
function Contact() {
463+
const [copied, setCopied] = useState(false);
464+
465+
const handleEmailClick = async () => {
466+
try {
467+
await navigator.clipboard.writeText('contact@codepod.io');
468+
setCopied(true);
469+
setTimeout(() => setCopied(false), 2000); // Reset after 2 seconds
470+
} catch (err) {
471+
console.error('Failed to copy email: ', err);
472+
}
473+
};
474+
462475
return (
463476
<div
464477
// className="container"
@@ -478,7 +491,62 @@ function Contact() {
478491
>
479492
For discussion or issue reporting, please open an issue or discussion in
480493
our GitHub repo. For general contact, please contact us at{" "}
481-
<a href="mailto:contact@codepod.io">contact@codepod.io</a>.
494+
<span
495+
onClick={handleEmailClick}
496+
style={{
497+
color: "#6366F1",
498+
cursor: "pointer",
499+
textDecoration: "none",
500+
position: "relative",
501+
display: "inline-flex",
502+
alignItems: "center",
503+
gap: "0.25rem",
504+
transition: "opacity 0.2s, text-decoration 0.2s",
505+
opacity: 0.8,
506+
}}
507+
onMouseEnter={(e) => {
508+
e.currentTarget.style.opacity = "1";
509+
e.currentTarget.style.textDecoration = "underline";
510+
}}
511+
onMouseLeave={(e) => {
512+
e.currentTarget.style.opacity = "0.8";
513+
e.currentTarget.style.textDecoration = "none";
514+
}}
515+
>
516+
contact@codepod.io
517+
<svg
518+
width="14"
519+
height="14"
520+
viewBox="0 0 24 24"
521+
fill="none"
522+
stroke="currentColor"
523+
strokeWidth="2"
524+
strokeLinecap="round"
525+
strokeLinejoin="round"
526+
>
527+
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
528+
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
529+
</svg>
530+
{copied && (
531+
<span
532+
style={{
533+
position: "absolute",
534+
top: "-2rem",
535+
left: "50%",
536+
transform: "translateX(-50%)",
537+
backgroundColor: "#10B981",
538+
color: "white",
539+
padding: "0.25rem 0.5rem",
540+
borderRadius: "0.25rem",
541+
fontSize: "0.875rem",
542+
whiteSpace: "nowrap",
543+
zIndex: 10,
544+
}}
545+
>
546+
Copied to clipboard!
547+
</span>
548+
)}
549+
</span>
482550
</div>
483551
</div>
484552
);

0 commit comments

Comments
 (0)