chore: hide contact info behind eye toggle instead of MD5
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
---
|
||||
import { contactIntents, contactMethods } from "@/lib/data";
|
||||
import ContactReveal from "@/components/ContactReveal";
|
||||
import type { Lang } from "@/types/i18n";
|
||||
|
||||
interface Props {
|
||||
@@ -40,18 +41,15 @@ const isZh = lang === "zh";
|
||||
|
||||
<ul class="mt-6 space-y-3 text-sm">
|
||||
{
|
||||
contactMethods.map((method) => (
|
||||
<li class="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between border-b border-border/70 pb-3 last:border-none last:pb-0">
|
||||
<span class="font-semibold text-foreground">
|
||||
{method.label[lang]}
|
||||
</span>
|
||||
<span class="text-muted-foreground break-all font-mono text-xs">
|
||||
{method.value}
|
||||
</span>
|
||||
<span class="inline-flex items-center rounded-md bg-muted px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground">
|
||||
MD5
|
||||
</span>
|
||||
</li>
|
||||
contactMethods.map((method, index) => (
|
||||
<ContactReveal
|
||||
client:load
|
||||
key={index}
|
||||
label={method.label[lang]}
|
||||
value={method.value}
|
||||
href={method.href}
|
||||
isZh={isZh}
|
||||
/>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
|
||||
47
src/components/ContactReveal.tsx
Normal file
47
src/components/ContactReveal.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import { useState } from "react";
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
|
||||
interface ContactRevealProps {
|
||||
label: string;
|
||||
value: string;
|
||||
href?: string;
|
||||
isZh?: boolean;
|
||||
}
|
||||
|
||||
export default function ContactReveal({ label, value, href, isZh }: ContactRevealProps) {
|
||||
const [revealed, setRevealed] = useState(false);
|
||||
const masked = "******";
|
||||
|
||||
return (
|
||||
<li className="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between border-b border-border/70 pb-3 last:border-none last:pb-0">
|
||||
<span className="font-semibold text-foreground">{label}</span>
|
||||
<span className="flex items-center gap-2">
|
||||
{revealed ? (
|
||||
href ? (
|
||||
<a
|
||||
href={href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-primary hover:text-primary/80 break-all text-sm"
|
||||
>
|
||||
{value}
|
||||
</a>
|
||||
) : (
|
||||
<span className="text-foreground break-all text-sm">{value}</span>
|
||||
)
|
||||
) : (
|
||||
<span className="text-muted-foreground tracking-widest text-sm">{masked}</span>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setRevealed((prev) => !prev)}
|
||||
className="inline-flex items-center justify-center rounded-md p-1 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors"
|
||||
aria-label={revealed ? (isZh ? "隐藏" : "Hide") : (isZh ? "显示" : "Reveal")}
|
||||
title={revealed ? (isZh ? "点击隐藏" : "Click to hide") : (isZh ? "点击显示" : "Click to reveal")}
|
||||
>
|
||||
{revealed ? <EyeOff size={16} /> : <Eye size={16} />}
|
||||
</button>
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
@@ -151,18 +151,20 @@ export const translations = {
|
||||
methods: [
|
||||
{
|
||||
label: "Email",
|
||||
value: "32df4a784e33b3964f4c06f6c6aeeecd",
|
||||
value: "zhaoguiyang18@outlook.com",
|
||||
icon: "mail",
|
||||
link: "mailto:zhaoguiyang18@outlook.com",
|
||||
},
|
||||
{
|
||||
label: "WeChat",
|
||||
value: "1b2f7b05fca4d2b892e7fa7741d077ee",
|
||||
value: "Joey_Zhao_dev",
|
||||
icon: "wechat",
|
||||
},
|
||||
{
|
||||
label: "Telegram",
|
||||
value: "592dff213bb5e79a511c34a37f7edbb5",
|
||||
value: "joey_zgy",
|
||||
icon: "send",
|
||||
link: "https://t.me/joey_zgy",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -379,18 +381,20 @@ export const translations = {
|
||||
methods: [
|
||||
{
|
||||
label: "邮箱",
|
||||
value: "32df4a784e33b3964f4c06f6c6aeeecd",
|
||||
value: "zhaoguiyang18@outlook.com",
|
||||
icon: "mail",
|
||||
link: "mailto:zhaoguiyang18@outlook.com",
|
||||
},
|
||||
{
|
||||
label: "微信",
|
||||
value: "1b2f7b05fca4d2b892e7fa7741d077ee",
|
||||
value: "Joey_Zhao_dev",
|
||||
icon: "wechat",
|
||||
},
|
||||
{
|
||||
label: "Telegram",
|
||||
value: "592dff213bb5e79a511c34a37f7edbb5",
|
||||
value: "joey_zgy",
|
||||
icon: "send",
|
||||
link: "https://t.me/joey_zgy",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -39,14 +39,14 @@ export const contactIntents: ContactIntent[] = [
|
||||
export const contactMethods: ContactMethod[] = [
|
||||
{
|
||||
label: { en: "Email (Secondary)", zh: "邮箱(备用)" },
|
||||
value: "32df4a784e33b3964f4c06f6c6aeeecd",
|
||||
value: "zhaoguiyang18@outlook.com",
|
||||
},
|
||||
{
|
||||
label: { en: "WeChat", zh: "微信" },
|
||||
value: "1b2f7b05fca4d2b892e7fa7741d077ee",
|
||||
value: "Joey_Zhao_dev",
|
||||
},
|
||||
{
|
||||
label: { en: "Telegram", zh: "Telegram" },
|
||||
value: "592dff213bb5e79a511c34a37f7edbb5",
|
||||
value: "joey_zgy",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -4,7 +4,7 @@ export const personalInfo: PersonalInfo = {
|
||||
name: "Joey Z.",
|
||||
location: "Chengdu, China",
|
||||
avatar: "https://avatars.githubusercontent.com/u/24975063?v=4",
|
||||
email: "32df4a784e33b3964f4c06f6c6aeeecd",
|
||||
email: "zhaoguiyang18@outlook.com",
|
||||
github: "https://github.com/zguiyang",
|
||||
linkedin: "",
|
||||
website: "https://zhaoguiyang.com",
|
||||
|
||||
Reference in New Issue
Block a user