hero.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import Link from "next/link";
  2. import { AvatarFlip } from "./avatar-flip";
  3. import { HeroTitle } from "./hero-title";
  4. import { QqButton } from "./qq-button";
  5. import { siteConfig } from "@/config/site";
  6. import { localePath, type Locale } from "@/lib/i18n";
  7. import { getMessages } from "@/messages";
  8. // The number-only QQ pill read oddly next to the round icons; kept in the code
  9. // but hidden for now — flip this to bring it back.
  10. const SHOW_QQ = false;
  11. // Icons are drawn at 16×16. QQ isn't here: it renders through <QqButton />,
  12. // which shows the number instead of trying to start a chat.
  13. const socials = [
  14. {
  15. label: "email",
  16. href: siteConfig.links.email,
  17. viewBox: "0 0 16 16",
  18. path: "M1.5 3h13c.8 0 1.5.7 1.5 1.5v7c0 .8-.7 1.5-1.5 1.5h-13C.7 13 0 12.3 0 11.5v-7C0 3.7.7 3 1.5 3Zm.3 1.6L8 8.8l6.2-4.2H1.8Zm12.6 1.5L8.4 10.2a.8.8 0 0 1-.8 0L1.6 6.1v5.3h12.8V6.1Z",
  19. },
  20. ];
  21. export function HeroCard({
  22. avatarUrl,
  23. dogUrl,
  24. lang,
  25. }: {
  26. avatarUrl?: string;
  27. dogUrl?: string;
  28. lang: Locale;
  29. }) {
  30. const t = getMessages(lang);
  31. const name = (label: string) => (label === "email" ? t.common.email : label);
  32. return (
  33. <div
  34. className="relative flex h-full flex-col p-5 [container:hero/inline-size] md:[container:hero/size] sm:p-6"
  35. data-hero
  36. >
  37. <div className="flex items-center gap-3.5">
  38. <AvatarFlip avatarUrl={avatarUrl} dogUrl={dogUrl} />
  39. <div className="leading-tight">
  40. <p className="text-[15px] font-semibold tracking-[-0.01em]">
  41. {t.hero.name}
  42. </p>
  43. <p className="mt-0.5 flex items-center gap-1 text-[13px] text-muted">
  44. <svg
  45. aria-hidden
  46. className="size-3"
  47. fill="currentColor"
  48. viewBox="0 0 12 12"
  49. >
  50. <path d="M10.9 1.1a.5.5 0 0 0-.53-.12L1.3 4.5a.5.5 0 0 0 .02.94l3.6 1.1 1.1 3.6a.5.5 0 0 0 .94.02l3.52-9.07a.5.5 0 0 0-.12-.53Z" />
  51. </svg>
  52. {t.common.location}
  53. </p>
  54. </div>
  55. </div>
  56. {/* The byline holds the top and the links the bottom; any spare height
  57. is shared evenly above and below the statement, so it sits centred
  58. between them however its lines fall (the bio wraps differently from
  59. one platform's text face to another). Below 768px the card is as tall
  60. as its content and nothing is spare. */}
  61. <div className="mt-auto pt-5 min-[480px]:pt-6">
  62. <HeroTitle />
  63. <p className="mt-4 max-w-[32em] text-[16px] leading-[1.5] text-pretty text-muted zh:leading-[1.65] @max-[270px]/hero:text-[15px] min-[480px]:text-[17px] md:mt-5 md:text-[clamp(16px,3.5cqi,21px)]">
  64. {t.hero.bio}
  65. </p>
  66. </div>
  67. <nav
  68. aria-label={t.hero.socials}
  69. className="dock mt-6 flex items-center gap-2 md:mt-auto md:pt-6"
  70. >
  71. {SHOW_QQ && <QqButton qq={siteConfig.qq} />}
  72. {socials.map((s) => (
  73. <a
  74. key={s.label}
  75. aria-label={name(s.label)}
  76. className="lg grid size-10 place-items-center rounded-full transition-[scale,translate] duration-300 ease-out @max-[270px]/hero:size-9"
  77. data-cursor={name(s.label)}
  78. href={s.href}
  79. rel="noopener noreferrer"
  80. target={s.href.startsWith("http") ? "_blank" : undefined}
  81. >
  82. <span aria-hidden className="lg-caustic" />
  83. <svg
  84. aria-hidden
  85. className="size-4"
  86. fill="currentColor"
  87. viewBox={s.viewBox}
  88. >
  89. <path d={s.path} />
  90. </svg>
  91. </a>
  92. ))}
  93. <Link
  94. className="lg ml-1 inline-flex h-10 items-center gap-2 rounded-full px-4 text-[13px] font-medium transition-[scale] duration-300 hover:scale-[1.04] @max-[270px]/hero:h-9 @max-[270px]/hero:px-3.5"
  95. data-cursor={t.hero.blogCursor}
  96. href={localePath(lang, "/blog")}
  97. >
  98. <span aria-hidden className="lg-caustic" />
  99. {t.hero.blog}
  100. </Link>
  101. </nav>
  102. </div>
  103. );
  104. }