| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- "use client";
- import { useState } from "react";
- /**
- * QQ's "start a chat" links (wpa.qq.com/msgrd, tencent://) fail with "无法发起
- * 临时会话" for accounts that don't accept stranger messages. So instead of
- * opening anything, this shows the number and copies it on click.
- */
- export function QqButton({ qq }: { qq: string }) {
- const [copied, setCopied] = useState(false);
- return (
- <button
- aria-label={`QQ ${qq}`}
- className="lg relative inline-flex h-10 items-center gap-2 rounded-full px-3.5 transition-[scale,translate] duration-300 ease-out @max-[270px]/hero:h-9 @max-[270px]/hero:px-3"
- data-cursor={`QQ ${qq}`}
- type="button"
- onClick={() => {
- navigator.clipboard?.writeText(qq).catch(() => {});
- setCopied(true);
- window.setTimeout(() => setCopied(false), 1600);
- }}
- >
- <span aria-hidden className="lg-caustic" />
- <svg
- aria-hidden
- className="size-4 shrink-0"
- fill="currentColor"
- viewBox="0 0 24 24"
- >
- <path d="M21.395 15.035a40 40 0 0 0-.803-2.264l-1.079-2.695c.001-.032.014-.562.014-.836C19.526 4.632 17.351 0 12 0S4.474 4.632 4.474 9.241c0 .274.013.804.014.836l-1.08 2.695a39 39 0 0 0-.802 2.264c-1.021 3.283-.69 4.643-.438 4.673.54.065 2.103-2.472 2.103-2.472 0 1.469.756 3.387 2.394 4.771-.612.188-1.363.479-1.845.835-.434.32-.379.646-.301.778.343.578 5.883.369 7.482.189 1.6.18 7.14.389 7.483-.189.078-.132.132-.458-.301-.778-.483-.356-1.233-.646-1.846-.836 1.637-1.384 2.393-3.302 2.393-4.771 0 0 1.563 2.537 2.103 2.472.251-.03.581-1.39-.438-4.673" />
- </svg>
- <span className="text-[13px] font-medium tracking-tight tabular-nums">
- {qq}
- </span>
- <span
- aria-hidden
- className="pointer-events-none absolute -top-9 left-1/2 -translate-x-1/2 rounded-full bg-ink px-2.5 py-1 text-[11px] font-medium whitespace-nowrap text-bg opacity-0 transition-opacity duration-200 data-[on]:opacity-100"
- data-on={copied ? "" : undefined}
- >
- QQ 号已复制
- </span>
- </button>
- );
- }
|