Skip to content

Commit 40852ae

Browse files
committed
feat: make contact info interactive - email mailto, wechat click-to-copy, GitHub link
1 parent 6c8dd4c commit 40852ae

1 file changed

Lines changed: 37 additions & 3 deletions

File tree

src/components/Footer.astro

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@ const prefix = locale === "en" ? "/en" : "";
3636
<div>
3737
<h4 class="text-xs font-semibold text-text-muted uppercase tracking-wider mb-2.5 sm:mb-3">{locale === "en" ? "Contact" : "联系作者"}</h4>
3838
<ul class="space-y-2 text-sm">
39-
<li><a href="mailto:contact@yanglibin.info" class="text-text-dim hover:text-accent-light transition-colors no-underline">contact@yanglibin.info</a></li>
40-
<li><span class="text-text-dim">WeChat: YLB0109</span></li>
41-
<li><a href="https://github.com/yanglbme" target="_blank" rel="noopener" class="text-text-dim hover:text-accent-light transition-colors no-underline">github.com/yanglbme</a></li>
39+
<li><a href="mailto:contact@yanglibin.info" class="text-text-dim hover:text-accent-light transition-colors no-underline">{locale === "en" ? "Email" : "邮箱"}</a></li>
40+
<li><button id="wechat-btn" class="text-text-dim hover:text-accent-light transition-colors no-underline bg-transparent border-0 p-0 cursor-pointer font-inherit">{locale === "en" ? "WeChat" : "微信"}</button></li>
41+
<li><a href="https://github.com/yanglbme" target="_blank" rel="noopener" class="text-text-dim hover:text-accent-light transition-colors no-underline">GitHub</a></li>
4242
</ul>
43+
<!-- WeChat ID tooltip -->
44+
<div id="wechat-tooltip" class="hidden mt-2 bg-bg-card border border-border rounded-lg px-3 py-2 text-sm shadow-[0_4px_20px_rgba(0,0,0,0.15)]">
45+
<span class="text-text-dim">{locale === "en" ? "WeChat ID" : "微信号"}: <span class="text-accent-light font-mono font-semibold select-all">YLB0109</span></span>
46+
<span id="wechat-copy-hint" class="text-xs text-green ml-2 hidden">已复制</span>
47+
</div>
4348
</div>
4449
<!-- More -->
4550
<div>
@@ -77,4 +82,33 @@ const prefix = locale === "en" ? "/en" : "";
7782
</footer>
7883
<script>
7984
document.getElementById("footer-year").textContent = new Date().getFullYear();
85+
86+
// WeChat ID tooltip
87+
const wechatBtn = document.getElementById("wechat-btn");
88+
const wechatTooltip = document.getElementById("wechat-tooltip");
89+
const wechatCopyHint = document.getElementById("wechat-copy-hint");
90+
91+
if (wechatBtn && wechatTooltip) {
92+
wechatBtn.addEventListener("click", function (e) {
93+
e.preventDefault();
94+
// Toggle tooltip
95+
wechatTooltip.classList.toggle("hidden");
96+
if (!wechatTooltip.classList.contains("hidden")) {
97+
// Copy to clipboard
98+
navigator.clipboard.writeText("YLB0109").then(function () {
99+
wechatCopyHint.classList.remove("hidden");
100+
setTimeout(function () {
101+
wechatCopyHint.classList.add("hidden");
102+
}, 2000);
103+
});
104+
}
105+
});
106+
107+
// Close tooltip when clicking outside
108+
document.addEventListener("click", function (e) {
109+
if (!wechatTooltip.classList.contains("hidden") && !wechatTooltip.contains(e.target) && e.target !== wechatBtn) {
110+
wechatTooltip.classList.add("hidden");
111+
}
112+
});
113+
}
80114
</script>

0 commit comments

Comments
 (0)