feat: 路由转场+详情页+自定义滚动条+常显网格线+邮箱修复
- 新增 FullscreenTransitionProvider + RouteTransitionOverlay: cover(0.8s b1 遮罩 wipe) → push → reveal 状态机(原 73475/34841 移植), Work 卡片与详情页链接全部走 startNavigation(同路径点击回顶部) - 新增 app/work/[slug] 详情页:content/workArticles.ts 从原站 6 个详情页 1:1 提取(MDX 文章+Metadata+iframe 预览+Links),/2026 锁定时渲染解锁屏 - 新增 CustomScrollbar:桌面右缘 SVG 轨道+拖拽 thumb(188 轨道/min20)、 点击跳转、2s 自动隐藏;移动端底部进度环回顶按钮(原 72443 移植) - BackgroundGrid 重写为原版算法(3 行十字/12px 缺口/12 列内分数纵线, 主页 loading 时隐藏其余时间常显);层叠改为原版结构:canvas z-auto 最前 → grid z-20 → DOM 内容,移除各 section 的 z-30 - 修复 BGM:持久化开启时首次手势自动恢复播放(autoplay 策略被拒后 pointerdown/keydown/touchstart 重试),enabled 闭包改用 ref - 页脚邮箱改为 chenchun@virtheart.com
This commit is contained in:
+21
-7
@@ -4,9 +4,12 @@ import "./globals.css";
|
|||||||
import SmoothScroller from "@/components/dom/SmoothScroller";
|
import SmoothScroller from "@/components/dom/SmoothScroller";
|
||||||
import Header from "@/components/dom/Header";
|
import Header from "@/components/dom/Header";
|
||||||
import BackgroundGrid from "@/components/dom/BackgroundGrid";
|
import BackgroundGrid from "@/components/dom/BackgroundGrid";
|
||||||
|
import CustomScrollbar from "@/components/dom/CustomScrollbar";
|
||||||
import LoadingOverlay from "@/components/dom/LoadingOverlay";
|
import LoadingOverlay from "@/components/dom/LoadingOverlay";
|
||||||
import { HeroScene } from "@/components/canvas/HeroScene";
|
import { HeroScene } from "@/components/canvas/HeroScene";
|
||||||
import { PasscodeAccessProvider } from "@/components/dom/PasscodeAccess";
|
import { PasscodeAccessProvider } from "@/components/dom/PasscodeAccess";
|
||||||
|
import { FullscreenTransitionProvider } from "@/lib/routeTransition";
|
||||||
|
import RouteTransitionOverlay from "@/components/dom/RouteTransitionOverlay";
|
||||||
import { getPasscodeAccessServer } from "@/lib/passcodeServer";
|
import { getPasscodeAccessServer } from "@/lib/passcodeServer";
|
||||||
|
|
||||||
const tiktokSans = localFont({
|
const tiktokSans = localFont({
|
||||||
@@ -39,15 +42,26 @@ export default async function RootLayout({
|
|||||||
}>) {
|
}>) {
|
||||||
const initialAccess = await getPasscodeAccessServer();
|
const initialAccess = await getPasscodeAccessServer();
|
||||||
return (
|
return (
|
||||||
<html lang="en" className={`${tiktokSans.variable} ${geistMono.variable} ${departureMono.variable}`}>
|
<html
|
||||||
|
lang="en"
|
||||||
|
className={`${tiktokSans.variable} ${geistMono.variable} ${departureMono.variable}`}
|
||||||
|
>
|
||||||
<body className="min-h-screen relative">
|
<body className="min-h-screen relative">
|
||||||
<PasscodeAccessProvider initialAccess={initialAccess}>
|
<PasscodeAccessProvider initialAccess={initialAccess}>
|
||||||
<BackgroundGrid />
|
<FullscreenTransitionProvider>
|
||||||
<HeroScene />
|
{/* Original stacking (1:1): the WebGL canvas host is a plain `fixed`
|
||||||
<SmoothScroller />
|
z-auto element first in the body; the grid overlay (z-20) comes
|
||||||
<Header />
|
AFTER it in DOM order so it paints above the canvas, exactly like
|
||||||
{children}
|
the original's main > canvas + z-20 grid sibling. */}
|
||||||
<LoadingOverlay />
|
<HeroScene />
|
||||||
|
<BackgroundGrid />
|
||||||
|
<SmoothScroller />
|
||||||
|
<Header />
|
||||||
|
{children}
|
||||||
|
<CustomScrollbar />
|
||||||
|
<RouteTransitionOverlay />
|
||||||
|
<LoadingOverlay />
|
||||||
|
</FullscreenTransitionProvider>
|
||||||
</PasscodeAccessProvider>
|
</PasscodeAccessProvider>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+3
-3
@@ -24,7 +24,7 @@ export default function Home() {
|
|||||||
data-section="banner"
|
data-section="banner"
|
||||||
className="grid grid-cols-12 grid-rows-[auto_1fr] px-4 lg:px-14 py-18 lg:py-24 w-full h-dvh lg:h-screen"
|
className="grid grid-cols-12 grid-rows-[auto_1fr] px-4 lg:px-14 py-18 lg:py-24 w-full h-dvh lg:h-screen"
|
||||||
>
|
>
|
||||||
<div className="flex flex-col order-2 lg:order-1 lg:grid lg:grid-cols-12 col-span-12 font-mono text-base relative z-30">
|
<div className="flex flex-col order-2 lg:order-1 lg:grid lg:grid-cols-12 col-span-12 font-mono text-base">
|
||||||
<span className="hidden lg:block lg:col-span-3 xl:col-span-2 lg:col-start-1 xl:col-start-1 p-2 font-sans font-medium text-[4svw] sm:text-2xl lg:text-3xl leading-tight">
|
<span className="hidden lg:block lg:col-span-3 xl:col-span-2 lg:col-start-1 xl:col-start-1 p-2 font-sans font-medium text-[4svw] sm:text-2xl lg:text-3xl leading-tight">
|
||||||
<ScrambleReveal text="Design &" startDelayMs={300} letterDelayMs={10} />
|
<ScrambleReveal text="Design &" startDelayMs={300} letterDelayMs={10} />
|
||||||
<br />
|
<br />
|
||||||
@@ -39,7 +39,7 @@ export default function Home() {
|
|||||||
<PasscodeRevealText className="col-span-12 lg:col-span-6 xl:col-span-4 lg:col-start-7 xl:col-start-9 mt-auto lg:mt-0 p-2" />
|
<PasscodeRevealText className="col-span-12 lg:col-span-6 xl:col-span-4 lg:col-start-7 xl:col-start-9 mt-auto lg:mt-0 p-2" />
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="flex flex-col self-end order-1 lg:order-2 col-span-12 px-2 font-bold text-[7.2svw] lg:text-[6svw] 2xl:text-[5svw] xl:text-[5.6svw] uppercase leading-none relative z-30"
|
className="flex flex-col self-end order-1 lg:order-2 col-span-12 px-2 font-bold text-[7.2svw] lg:text-[6svw] 2xl:text-[5svw] xl:text-[5.6svw] uppercase leading-none"
|
||||||
style={{ fontVariationSettings: '"wdth" 120' }}
|
style={{ fontVariationSettings: '"wdth" 120' }}
|
||||||
>
|
>
|
||||||
<ScrambleReveal text="I bring" startDelayMs={300} />
|
<ScrambleReveal text="I bring" startDelayMs={300} />
|
||||||
@@ -49,7 +49,7 @@ export default function Home() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Signature / About Section */}
|
{/* Signature / About Section */}
|
||||||
<div className="grid grid-cols-12 px-4 lg:px-14 py-18 lg:py-24 lg:pb-28 w-full relative z-30">
|
<div className="grid grid-cols-12 px-4 lg:px-14 py-18 lg:py-24 lg:pb-28 w-full">
|
||||||
<AboutMedia />
|
<AboutMedia />
|
||||||
<div className="flex flex-col justify-start items-start gap-6 col-span-12 sm:col-span-7 lg:col-span-8 sm:col-start-6 lg:col-start-5 text-base lg:text-xl leading-none">
|
<div className="flex flex-col justify-start items-start gap-6 col-span-12 sm:col-span-7 lg:col-span-8 sm:col-start-6 lg:col-start-5 text-base lg:text-xl leading-none">
|
||||||
<p
|
<p
|
||||||
|
|||||||
@@ -0,0 +1,270 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Work detail pages — /work/[slug] rendering the original MDX article
|
||||||
|
* markup 1:1 (from https://haoqi.design/reunimos et al.):
|
||||||
|
*
|
||||||
|
* <div class="fixed inset-0 w-full h-full">
|
||||||
|
* <div class="w-full h-full overflow-y-auto overscroll-contain no-scrollbar">
|
||||||
|
* <article data-mdx-article class="mx-auto px-6 py-18 lg:py-24 w-full
|
||||||
|
* max-w-[880px] text-l1">
|
||||||
|
* <header class="pt-[10vh]"> h1 + date + hr + year </header>
|
||||||
|
* <div class="[&_p+p]:mt-3 …"> blocks </div>
|
||||||
|
* </article>
|
||||||
|
*
|
||||||
|
* Content comes from content/workArticles.ts (extracted from the live
|
||||||
|
* pages). Passcode-protected scopes (/2026) render the unlock screen when
|
||||||
|
* locked, exactly like the original.
|
||||||
|
*/
|
||||||
|
import { Suspense, useMemo } from "react";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
import {
|
||||||
|
WORK_ARTICLES,
|
||||||
|
type ArticleBlock,
|
||||||
|
type InlineSeg,
|
||||||
|
} from "@/content/workArticles";
|
||||||
|
import { usePasscodeAllowed } from "@/components/dom/PasscodeAccess";
|
||||||
|
import { useRouteTransitionController } from "@/lib/routeTransition";
|
||||||
|
import { PasscodeUnlockScreen } from "@/components/dom/PasscodeUnlockScreen";
|
||||||
|
import { buildPasscodeUnlockHref, primaryPasscodePath, scopeToPath } from "@/lib/passcode";
|
||||||
|
import CustomScrollbar from "@/components/dom/CustomScrollbar";
|
||||||
|
|
||||||
|
const PROSE_CLASS =
|
||||||
|
"[&_p+p]:mt-3 [&_p]:mb-0 text-l2 [&_p]:text-sm [&_p]:text-l1 [&_p]:leading-relaxed lg:[&_p]:text-base";
|
||||||
|
|
||||||
|
function Inline({ segs }: { segs: InlineSeg[] }) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{segs.map((s, i) =>
|
||||||
|
s.t === "link" ? (
|
||||||
|
<a
|
||||||
|
key={i}
|
||||||
|
href={s.href}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="inline text-l1 underline underline-offset-[0.08em] decoration-solid decoration-(--label-3) transition-[text-decoration-color] duration-150 ease-out lg:[@media(hover:hover)]:hover:decoration-(--label-1)"
|
||||||
|
>
|
||||||
|
{s.v}
|
||||||
|
</a>
|
||||||
|
) : (
|
||||||
|
<span key={i}>{s.v}</span>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Block({ block }: { block: ArticleBlock }) {
|
||||||
|
switch (block.type) {
|
||||||
|
case "p":
|
||||||
|
return (
|
||||||
|
<p>
|
||||||
|
<Inline segs={block.segs} />
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
case "h2":
|
||||||
|
return <h2 className="mt-8 font-bold text-xl! text-l1">{block.text}</h2>;
|
||||||
|
case "h3":
|
||||||
|
return <h3 className="mt-6 font-bold text-lg! text-l1">{block.text}</h3>;
|
||||||
|
case "img":
|
||||||
|
// eslint-disable-next-line @next/next/no-img-element -- original uses plain img with cursor-zoom-in
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
src={block.src}
|
||||||
|
alt=""
|
||||||
|
crossOrigin="anonymous"
|
||||||
|
loading="lazy"
|
||||||
|
decoding="async"
|
||||||
|
className="block w-full h-auto cursor-zoom-in select-none border border-line bg-[rgba(var(--label-d),0.05)]"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
case "hr":
|
||||||
|
return <hr className="my-8 h-px w-full border-0 bg-line" />;
|
||||||
|
case "list":
|
||||||
|
return block.ordered ? (
|
||||||
|
<ol className="list-decimal my-0 pl-5 space-y-0">
|
||||||
|
{block.items.map((li, i) => (
|
||||||
|
<li key={i} className="text-l1 leading-relaxed">
|
||||||
|
<Inline segs={li} />
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ol>
|
||||||
|
) : (
|
||||||
|
<ul className="list-disc my-0 pl-5 space-y-0">
|
||||||
|
{block.items.map((li, i) => (
|
||||||
|
<li key={i} className="text-l1 leading-relaxed">
|
||||||
|
<Inline segs={li} />
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
);
|
||||||
|
case "quote":
|
||||||
|
return (
|
||||||
|
<blockquote className="border-l-4 border-(--selection-bg) pl-4 text-l2">
|
||||||
|
{block.items.map((q, i) => (
|
||||||
|
<p key={i} className="text-l2">
|
||||||
|
{q}
|
||||||
|
</p>
|
||||||
|
))}
|
||||||
|
</blockquote>
|
||||||
|
);
|
||||||
|
case "code":
|
||||||
|
return (
|
||||||
|
<pre className="my-4 overflow-x-auto rounded bg-[rgba(var(--label-d),0.08)] p-3 font-mono text-[0.9em] text-l1">
|
||||||
|
<code>{block.text}</code>
|
||||||
|
</pre>
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Article({ slug }: { slug: string }) {
|
||||||
|
const article = WORK_ARTICLES[slug];
|
||||||
|
if (!article) {
|
||||||
|
return (
|
||||||
|
<div className="fixed inset-0 w-full h-full">
|
||||||
|
<div className="w-full h-full overflow-y-auto overscroll-contain no-scrollbar">
|
||||||
|
<article className="mx-auto px-6 py-18 lg:py-24 w-full max-w-[880px] text-l1">
|
||||||
|
<header className="pt-[10vh]">
|
||||||
|
<h1 className="font-bold text-3xl! text-l1 lg:text-5xl! leading-tight tracking-tight">
|
||||||
|
404
|
||||||
|
</h1>
|
||||||
|
<p className="mt-1 text-l2! text-sm! lg:text-base! leading-relaxed">
|
||||||
|
No article for this work yet.
|
||||||
|
</p>
|
||||||
|
<div className="mt-2 border-line border-b" />
|
||||||
|
<p className="pt-3 text-l2! text-sm! lg:text-base! leading-relaxed">
|
||||||
|
<Link className="underline underline-offset-4" href="/">
|
||||||
|
← Home
|
||||||
|
</Link>
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className="fixed inset-0 w-full h-full">
|
||||||
|
<div className="w-full h-full overflow-y-auto overscroll-contain no-scrollbar">
|
||||||
|
<article
|
||||||
|
data-mdx-article="true"
|
||||||
|
className="mx-auto px-6 py-18 lg:py-24 w-full max-w-[880px] text-l1"
|
||||||
|
>
|
||||||
|
<header className="pt-[10vh]">
|
||||||
|
<h1 className="font-bold text-3xl! text-l1 lg:text-5xl! leading-tight tracking-tight" style={{ fontVariationSettings: '"wdth" 120' }}>
|
||||||
|
{article.title}
|
||||||
|
</h1>
|
||||||
|
<p className="mt-1 tabular-nums text-l2! text-sm! lg:text-base! leading-relaxed">
|
||||||
|
{article.date}
|
||||||
|
</p>
|
||||||
|
<div className="mt-2 border-line border-b" />
|
||||||
|
<p className="pt-3 text-l2! text-sm! lg:text-base! leading-relaxed">
|
||||||
|
{article.year}
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
<div className={PROSE_CLASS}>
|
||||||
|
{article.blocks.map((b, i) => (
|
||||||
|
<Block key={i} block={b} />
|
||||||
|
))}
|
||||||
|
{article.iframe && (
|
||||||
|
<iframe
|
||||||
|
width="840"
|
||||||
|
height="600"
|
||||||
|
src={article.iframe.src}
|
||||||
|
title={article.iframe.title}
|
||||||
|
allowFullScreen
|
||||||
|
className="mt-8 w-full border-0"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{article.meta && (
|
||||||
|
<footer
|
||||||
|
data-mdx-footer="true"
|
||||||
|
className="bg-[rgba(var(--label-d),0.03)] mt-16 p-4 lg:p-6 rounded-xl"
|
||||||
|
>
|
||||||
|
<div className="mb-5 font-sans font-semibold text-l1 text-base">
|
||||||
|
Metadata
|
||||||
|
</div>
|
||||||
|
<dl className="gap-x-6 gap-y-6 grid grid-cols-2 lg:grid-cols-3">
|
||||||
|
{article.meta.map(([dt, dd]) => (
|
||||||
|
<div key={dt} className="flex flex-col gap-1.5">
|
||||||
|
<dt className="font-sans font-semibold text-l1 text-sm">{dt}</dt>
|
||||||
|
<dd>
|
||||||
|
<span className="font-mono tabular-nums text-l2 text-sm">{dd}</span>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</dl>
|
||||||
|
<div className="my-6 border-line border-t border-dashed" />
|
||||||
|
<div className="gap-x-6 gap-y-4 grid grid-cols-2 lg:grid-cols-3">
|
||||||
|
<div className="hidden lg:block font-sans font-semibold text-l1 text-sm">
|
||||||
|
Links
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col items-start gap-1 font-mono">
|
||||||
|
<DetailNavLink href="/">Home</DetailNavLink>
|
||||||
|
<DetailNavLink href="/">Work</DetailNavLink>
|
||||||
|
<DetailNavLink href="/">Contact</DetailNavLink>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col items-start gap-1 font-mono">
|
||||||
|
{["Twitter/X", "Figma", "GitHub"].map((label) => (
|
||||||
|
<a
|
||||||
|
key={label}
|
||||||
|
href="#"
|
||||||
|
className="relative before:content-[''] before:absolute before:inset-0 before:border-2 before:border-dotted before:border-transparent before:pointer-events-none before:transition-colors before:duration-200 lg:hover:before:border-l1 inline-block -mx-1 px-1 py-0.5 text-l2 lg:hover:text-l1 text-sm transition-colors"
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</a>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
)}
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DetailNavLink({ href, children }: { href: string; children: string }) {
|
||||||
|
const { startNavigation } = useRouteTransitionController();
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => startNavigation(href)}
|
||||||
|
className="relative before:content-[''] before:absolute before:inset-0 before:border-2 before:border-dotted before:border-transparent before:pointer-events-none before:transition-colors before:duration-200 lg:hover:before:border-l1 inline-block -mx-1 px-1 py-0.5 text-l2 lg:hover:text-l1 text-sm transition-colors text-left cursor-pointer"
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function WorkDetailInner() {
|
||||||
|
const params = useParams<{ slug: string }>();
|
||||||
|
const raw = String(params?.slug ?? "");
|
||||||
|
// /work/2026 is the passcode-protected scope; the others map back to the
|
||||||
|
// original slugs (/work/reunimos → content key "/reunimos").
|
||||||
|
const slug = `/${raw}`;
|
||||||
|
const allowed = usePasscodeAllowed(slug);
|
||||||
|
if (!allowed) {
|
||||||
|
// Protected scope (e.g. /2026) renders the unlock screen in place,
|
||||||
|
// exactly like the original detail route.
|
||||||
|
return <PasscodeUnlockScreen scope={slug} returnTo={slug} />;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Article slug={slug} />
|
||||||
|
<CustomScrollbar />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function WorkDetailPage() {
|
||||||
|
return (
|
||||||
|
<Suspense fallback={null}>
|
||||||
|
<WorkDetailInner />
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -112,10 +112,12 @@ export function HeroScene() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// z-30 keeps it above the BackgroundGrid (z-20) to prevent mix-blend-difference from making it gray
|
// 1:1 original stacking: z-auto fixed host BEFORE the grid/main in DOM.
|
||||||
|
// The z-20 BackgroundGrid (rendered after this element) paints above the
|
||||||
|
// canvas with mix-blend-difference — same as the original site.
|
||||||
<div
|
<div
|
||||||
ref={hostRef}
|
ref={hostRef}
|
||||||
className="z-30 fixed inset-0 w-full h-full pointer-events-none"
|
className="fixed inset-0 w-full h-full pointer-events-none"
|
||||||
>
|
>
|
||||||
<Canvas
|
<Canvas
|
||||||
dpr={[1, 2]}
|
dpr={[1, 2]}
|
||||||
|
|||||||
@@ -1,9 +1,26 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
|
import { usePathname } from 'next/navigation';
|
||||||
|
import { loadingBus } from '@/lib/loadingBus';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Background grid — 1:1 port of the original (chunk 2689132c4e070b68.js):
|
||||||
|
*
|
||||||
|
* - Three cross junctions at thirds of the viewport height (y = h/3 - 12,
|
||||||
|
* y = h/3 + 12 + i + 24), i.e. rows at h/3-12 and 2h/3+12, with 12px gaps
|
||||||
|
* around the crosses and 12px notches where lines meet the frame.
|
||||||
|
* - 2 columns (<1280) / 3 columns of vertical lines between the px paddings
|
||||||
|
* (16 mobile / 56 lg), fractions of the inner width.
|
||||||
|
* - Whole overlay hidden while the home loading gate is up
|
||||||
|
* (`"/"===pathname && !readyToLoadHeavy`); visible at all other times —
|
||||||
|
* that is why the original keeps the crosses on screen while scrolling.
|
||||||
|
*/
|
||||||
|
const LINE = 'rgba(255, 255, 255, 0.1)';
|
||||||
|
|
||||||
export default function BackgroundGrid() {
|
export default function BackgroundGrid() {
|
||||||
const [size, setSize] = useState({ w: 375, h: 812 });
|
const pathname = usePathname();
|
||||||
|
const [size, setSize] = useState({ w: 0, h: 0 });
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const updateSize = () => {
|
const updateSize = () => {
|
||||||
@@ -14,60 +31,71 @@ export default function BackgroundGrid() {
|
|||||||
return () => window.removeEventListener('resize', updateSize);
|
return () => window.removeEventListener('resize', updateSize);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// useHomeLoadingGate (original module 97839): "/" && !readyToLoadHeavy.
|
||||||
|
// Our equivalent heavy-ready signal is the loading curtain (loadingBus).
|
||||||
|
const [heavyReady, setHeavyReady] = useState(pathname !== '/');
|
||||||
|
useEffect(() => {
|
||||||
|
if (pathname !== '/') {
|
||||||
|
setHeavyReady(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setHeavyReady(loadingBus.getSnapshot().ready);
|
||||||
|
return loadingBus.subscribe(() => {
|
||||||
|
setHeavyReady(loadingBus.getSnapshot().ready);
|
||||||
|
});
|
||||||
|
}, [pathname]);
|
||||||
|
|
||||||
const { w, h } = size;
|
const { w, h } = size;
|
||||||
|
|
||||||
// Calculate grid lines
|
const loadingGate = pathname === '/' && !heavyReady;
|
||||||
// Responsive padding: lg is px-14 (56px), mobile is px-4 (16px)
|
|
||||||
const isDesktop = w >= 1024;
|
|
||||||
const paddingX = isDesktop ? 56 : 16;
|
|
||||||
const edgeOffset = paddingX + 0.5; // +0.5 for crisp SVG rendering
|
|
||||||
|
|
||||||
const cols = 3; // Left, Center, Right
|
const { verticalPath, horizontalPath, crossPath } = useMemo(() => {
|
||||||
const rows = Math.ceil(h / 450) + 1;
|
if (w <= 0 || h <= 0) return { verticalPath: '', horizontalPath: '', crossPath: '' };
|
||||||
|
const n = w < 1024 ? 16 : 56;
|
||||||
const vLines = Array.from({ length: cols }).map((_, i) => {
|
const innerW = Math.max(0, w - 2 * n);
|
||||||
if (i === 0) return edgeOffset;
|
const i = Math.max(0, h / 3 - 12);
|
||||||
if (i === cols - 1) return w - edgeOffset;
|
const s = i + 24;
|
||||||
return w / 2;
|
const a = s + i;
|
||||||
});
|
const cols = w < 1280 ? 2 : 3;
|
||||||
|
const xs = Array.from({ length: cols + 1 }, (_, k) => n + (k / cols) * innerW).map(
|
||||||
const hLines = Array.from({ length: rows }).map((_, i) => (i + 1) * 442);
|
(x) => Math.round(x) + 0.5
|
||||||
|
);
|
||||||
|
const rows = [
|
||||||
|
{ startY: 0, endY: i },
|
||||||
|
{ startY: s, endY: a },
|
||||||
|
{ startY: a + 24, endY: h },
|
||||||
|
];
|
||||||
|
const u = [i + 12, a + 12];
|
||||||
|
const verticalPath = rows
|
||||||
|
.map(({ startY, endY }) => xs.map((x) => `M${x} ${startY}V${endY}`).join(''))
|
||||||
|
.join('');
|
||||||
|
const horizontalPath = u
|
||||||
|
.map((y) => {
|
||||||
|
if (xs.length < 2) return '';
|
||||||
|
const first = xs[0];
|
||||||
|
const last = xs[xs.length - 1];
|
||||||
|
const mids = xs.slice(0, -1)
|
||||||
|
.map((x, k) => `M${x + 12} ${y}H${xs[k + 1] - 12}`)
|
||||||
|
.join('');
|
||||||
|
return [`M0 ${y}H${first - 12}`, mids, `M${last + 12} ${y}H${w}`].join('');
|
||||||
|
})
|
||||||
|
.join('');
|
||||||
|
const crossPath = xs
|
||||||
|
.flatMap((x) => u.flatMap((y) => [`M${x} ${y - 6}V${y + 6}`, `M${x - 6} ${y}H${x + 6}`]))
|
||||||
|
.join('');
|
||||||
|
return { verticalPath, horizontalPath, crossPath };
|
||||||
|
}, [w, h]);
|
||||||
|
|
||||||
// Generate paths
|
if (loadingGate) return null;
|
||||||
let vPath = '';
|
|
||||||
let hPath = '';
|
|
||||||
let crossPath = '';
|
|
||||||
|
|
||||||
const crossSize = 6; // 12px total width/height for the cross
|
|
||||||
|
|
||||||
vLines.forEach(x => {
|
|
||||||
hLines.forEach((y, i) => {
|
|
||||||
const startY = i === 0 ? 0 : hLines[i - 1] + 12;
|
|
||||||
const endY = y - 12;
|
|
||||||
vPath += `M${x} ${startY}V${endY} `;
|
|
||||||
|
|
||||||
crossPath += `M${x} ${y - crossSize}V${y + crossSize} `;
|
|
||||||
crossPath += `M${x - crossSize} ${y}H${x + crossSize} `;
|
|
||||||
});
|
|
||||||
const lastY = hLines[hLines.length - 1] + 12;
|
|
||||||
vPath += `M${x} ${lastY}V${h} `;
|
|
||||||
});
|
|
||||||
|
|
||||||
hLines.forEach(y => {
|
|
||||||
vLines.forEach((x, i) => {
|
|
||||||
const startX = i === 0 ? 0 : vLines[i - 1] + 12;
|
|
||||||
const endX = x - 12;
|
|
||||||
hPath += `M${startX} ${y}H${endX} `;
|
|
||||||
});
|
|
||||||
const lastX = vLines[vLines.length - 1] + 12;
|
|
||||||
hPath += `M${lastX} ${y}H${w} `;
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="z-20 fixed inset-0 w-full h-full pointer-events-none mix-blend-difference">
|
<div className="z-20 fixed inset-0 w-full h-full pointer-events-none mix-blend-difference">
|
||||||
<svg viewBox={`0 0 ${w} ${h}`} className="block shape-rendering-crispEdges w-full h-full">
|
<svg
|
||||||
<path d={vPath} stroke="rgba(255, 255, 255, 0.1)" strokeWidth="1" fill="none" />
|
viewBox={`0 0 ${w} ${h}`}
|
||||||
<path d={hPath} stroke="rgba(255, 255, 255, 0.1)" strokeWidth="1" fill="none" />
|
className="block shape-rendering-crispEdges w-full h-full"
|
||||||
|
>
|
||||||
|
<path d={verticalPath} stroke={LINE} strokeWidth="1" fill="none" />
|
||||||
|
<path d={horizontalPath} stroke={LINE} strokeWidth="1" fill="none" />
|
||||||
<path d={crossPath} stroke="#FFFFFF" strokeWidth="1" fill="none" opacity="0.4" />
|
<path d={crossPath} stroke="#FFFFFF" strokeWidth="1" fill="none" opacity="0.4" />
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,273 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom scrollbar — 1:1 port of the original (chunk 2689132c4e070b68.js
|
||||||
|
* module 72443):
|
||||||
|
*
|
||||||
|
* - Desktop (lg+): a right-edge fixed 32×200 SVG track + draggable thumb.
|
||||||
|
* Thumb geometry = progress mapping with min length 20 of a 188 track
|
||||||
|
* (max(20, 188·clientH/totalH), start 6+progress·(188-len)). Clicking the
|
||||||
|
* track jumps; dragging the thumb scrubs (lenisScrollTo immediate).
|
||||||
|
* - Mobile: a 24px circular "Scroll to top" button with a progress ring.
|
||||||
|
* - Auto-hides after 2s without scroll activity (o), shows on hover / drag.
|
||||||
|
*/
|
||||||
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
|
import { scrollEnv } from "@/lib/scrollEnv";
|
||||||
|
|
||||||
|
const RING_CIRCUMFERENCE = 2 * Math.PI * 12;
|
||||||
|
const HIDE_AFTER_MS = 2000;
|
||||||
|
|
||||||
|
const clamp = (v: number, min: number, max: number) =>
|
||||||
|
Math.min(max, Math.max(min, v));
|
||||||
|
|
||||||
|
export default function CustomScrollbar({ hidden = false }: { hidden?: boolean }) {
|
||||||
|
const thumbRef = useRef<SVGPathElement | null>(null);
|
||||||
|
const ringRef = useRef<SVGCircleElement | null>(null);
|
||||||
|
const draggingRef = useRef(false);
|
||||||
|
const dragStart = useRef({ startY: 0, startScrollTop: 0 });
|
||||||
|
const abortRef = useRef<AbortController | null>(null);
|
||||||
|
const hideTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
const rafRef = useRef<number | null>(null);
|
||||||
|
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
|
const [transitioning, setTransitioning] = useState(false);
|
||||||
|
const [mounted, setMounted] = useState(false);
|
||||||
|
const [nearBottom, setNearBottom] = useState(false);
|
||||||
|
const [progress, setProgress] = useState(0);
|
||||||
|
|
||||||
|
const scheduleHide = useCallback((delay = HIDE_AFTER_MS) => {
|
||||||
|
setVisible(true);
|
||||||
|
if (hideTimer.current) clearTimeout(hideTimer.current);
|
||||||
|
hideTimer.current = setTimeout(() => setVisible(false), delay);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const update = useCallback(() => {
|
||||||
|
const container = scrollEnv.getContainerEl();
|
||||||
|
const scrollTop = scrollEnv.getScrollTopPx();
|
||||||
|
const near = Math.max(0, (container?.scrollHeight ?? document.documentElement.scrollHeight) - scrollTop) <= window.innerHeight * clamp(nearBottomRatio(), 0, 1);
|
||||||
|
setNearBottom((prev) => (prev === near ? prev : near));
|
||||||
|
|
||||||
|
const totalH = Math.max(1, container?.scrollHeight ?? document.documentElement.scrollHeight);
|
||||||
|
const clientH = Math.max(1, container?.clientHeight ?? window.innerHeight);
|
||||||
|
const p = clamp(scrollTop / Math.max(1, totalH - clientH), 0, 1);
|
||||||
|
setProgress(p);
|
||||||
|
const thumbLen = Math.max(20, 188 * clamp(clientH / totalH, 0, 1));
|
||||||
|
const start = 6 + p * (188 - thumbLen);
|
||||||
|
thumbRef.current?.setAttribute("d", `M 16 ${start} V ${start + thumbLen}`);
|
||||||
|
ringRef.current?.setAttribute("stroke-dashoffset", String(RING_CIRCUMFERENCE * (1 - p)));
|
||||||
|
// nearBottom threshold (original useNearBottom(.5)): keep simple ratio hook
|
||||||
|
void near;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const container = scrollEnv.getContainerEl();
|
||||||
|
if (!container) return;
|
||||||
|
setMounted(true);
|
||||||
|
scheduleHide(3000);
|
||||||
|
// First-paint show (original x flag via rAF).
|
||||||
|
if (!rafRef.current) {
|
||||||
|
rafRef.current = requestAnimationFrame(() => setTransitioning(true));
|
||||||
|
}
|
||||||
|
const onScroll = () => {
|
||||||
|
update();
|
||||||
|
scheduleHide();
|
||||||
|
};
|
||||||
|
update();
|
||||||
|
const ro = new ResizeObserver(update);
|
||||||
|
ro.observe(container);
|
||||||
|
const firstChild = container.firstElementChild;
|
||||||
|
if (firstChild instanceof HTMLElement) ro.observe(firstChild);
|
||||||
|
const rafs: number[] = [];
|
||||||
|
let n = 3;
|
||||||
|
const tick = () => {
|
||||||
|
update();
|
||||||
|
if (--n > 0) rafs.push(requestAnimationFrame(tick));
|
||||||
|
};
|
||||||
|
rafs.push(requestAnimationFrame(tick));
|
||||||
|
const onLoad = () => update();
|
||||||
|
window.addEventListener("load", onLoad, { passive: true });
|
||||||
|
window.addEventListener("scroll", onScroll, { passive: true });
|
||||||
|
return () => {
|
||||||
|
if (hideTimer.current) clearTimeout(hideTimer.current);
|
||||||
|
if (rafRef.current) cancelAnimationFrame(rafRef.current);
|
||||||
|
for (const r of rafs) cancelAnimationFrame(r);
|
||||||
|
ro.disconnect();
|
||||||
|
window.removeEventListener("load", onLoad);
|
||||||
|
window.removeEventListener("scroll", onScroll);
|
||||||
|
};
|
||||||
|
}, [scheduleHide, update]);
|
||||||
|
|
||||||
|
const measure = useCallback(() => {
|
||||||
|
const container = scrollEnv.getContainerEl();
|
||||||
|
const totalH = container?.scrollHeight ?? Math.max(document.documentElement.scrollHeight, document.body.scrollHeight, 1);
|
||||||
|
const clientH = container?.clientHeight ?? Math.max(1, window.innerHeight || document.documentElement.clientHeight || 1);
|
||||||
|
return { el: container, totalH, clientH, validH: Math.max(1, totalH - clientH) };
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const onDragMove = useCallback(
|
||||||
|
(e: MouseEvent) => {
|
||||||
|
if (!draggingRef.current) return;
|
||||||
|
const dy = e.clientY - dragStart.current.startY;
|
||||||
|
const { totalH, clientH, validH } = measure();
|
||||||
|
const trackLen = 188 - Math.max(20, 188 * (totalH > 0 ? clamp(clientH / totalH, 0, 1) : 1));
|
||||||
|
if (trackLen <= 0) return;
|
||||||
|
const target = dragStart.current.startScrollTop + (validH / trackLen) * dy;
|
||||||
|
scrollEnv.lenisScrollTo(target, { immediate: true });
|
||||||
|
},
|
||||||
|
[measure]
|
||||||
|
);
|
||||||
|
|
||||||
|
const onDragEnd = useCallback(() => {
|
||||||
|
draggingRef.current = false;
|
||||||
|
abortRef.current?.abort();
|
||||||
|
abortRef.current = null;
|
||||||
|
document.body.style.userSelect = "";
|
||||||
|
if (hideTimer.current) clearTimeout(hideTimer.current);
|
||||||
|
hideTimer.current = setTimeout(() => setVisible(false), HIDE_AFTER_MS);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const onThumbDown = useCallback(
|
||||||
|
(e: React.MouseEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
draggingRef.current = true;
|
||||||
|
dragStart.current = {
|
||||||
|
startY: e.clientY,
|
||||||
|
startScrollTop: scrollEnv.getScrollTopPx(),
|
||||||
|
};
|
||||||
|
if (hideTimer.current) clearTimeout(hideTimer.current);
|
||||||
|
setVisible(true);
|
||||||
|
document.body.style.userSelect = "none";
|
||||||
|
abortRef.current?.abort();
|
||||||
|
abortRef.current = new AbortController();
|
||||||
|
const signal = abortRef.current.signal;
|
||||||
|
document.addEventListener("mousemove", onDragMove, { signal });
|
||||||
|
document.addEventListener("mouseup", onDragEnd, { signal });
|
||||||
|
},
|
||||||
|
[onDragEnd, onDragMove]
|
||||||
|
);
|
||||||
|
|
||||||
|
const desktopCls = [
|
||||||
|
"pointer-events-auto top-1/2 right-0 bottom-0 z-30 fixed w-14 px-3 h-50 -translate-y-1/2 hidden lg:block",
|
||||||
|
transitioning ? "transition-opacity duration-500" : "",
|
||||||
|
visible ? "opacity-100" : "opacity-0",
|
||||||
|
hidden ? " hidden!" : "",
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" ");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{mounted && (
|
||||||
|
<div
|
||||||
|
className={desktopCls}
|
||||||
|
aria-hidden={hidden}
|
||||||
|
onMouseEnter={() => {
|
||||||
|
setVisible(true);
|
||||||
|
if (hideTimer.current) clearTimeout(hideTimer.current);
|
||||||
|
}}
|
||||||
|
onMouseLeave={() => {
|
||||||
|
if (hideTimer.current) clearTimeout(hideTimer.current);
|
||||||
|
hideTimer.current = setTimeout(() => setVisible(false), HIDE_AFTER_MS);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
width="32"
|
||||||
|
height="200"
|
||||||
|
viewBox="0 0 32 200"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
onClick={(e) => {
|
||||||
|
const rect = e.currentTarget.getBoundingClientRect();
|
||||||
|
const y = clamp((e.clientY - rect.top) * (200 / rect.height), 6, 194);
|
||||||
|
const ratio = (y - 6) / 188;
|
||||||
|
const { validH } = measure();
|
||||||
|
scrollEnv.lenisScrollTo(ratio * validH, { immediate: false });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M 16 6 V 194"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeOpacity={0.2}
|
||||||
|
strokeWidth="6"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeLinecap="round"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
ref={thumbRef}
|
||||||
|
d="M 16 6 V 6"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="6"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeLinecap="round"
|
||||||
|
onMouseDown={onThumbDown}
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{mounted && (
|
||||||
|
<div
|
||||||
|
className="pointer-events-auto lg:hidden right-0 bottom-0 z-30 fixed flex justify-center items-center px-6 py-6"
|
||||||
|
role="button"
|
||||||
|
tabIndex={hidden ? -1 : 0}
|
||||||
|
aria-label="Scroll to top"
|
||||||
|
aria-hidden={hidden}
|
||||||
|
onClick={() => scrollEnv.scrollToTop("smooth")}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter" || e.key === " ") {
|
||||||
|
e.preventDefault();
|
||||||
|
scrollEnv.scrollToTop("smooth");
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
width="24px"
|
||||||
|
height="24px"
|
||||||
|
viewBox="0 0 32 32"
|
||||||
|
className={`${nearBottom ? "scale-100" : "scale-50"} transition-all duration-[0.66s] ease-66 pointer-events-none`}
|
||||||
|
>
|
||||||
|
<circle
|
||||||
|
r="12"
|
||||||
|
cy="16"
|
||||||
|
cx="16"
|
||||||
|
fill="none"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeWidth={nearBottom ? 4 : 8}
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeOpacity={nearBottom ? 0.2 : 1}
|
||||||
|
transform="rotate(-90 16 16)"
|
||||||
|
style={{
|
||||||
|
transition:
|
||||||
|
"stroke-opacity 0.66s cubic-bezier(0.66, 0, 0.01, 1), stroke-width 0.66s cubic-bezier(0.66, 0, 0.01, 1)",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<circle
|
||||||
|
ref={ringRef}
|
||||||
|
r="12"
|
||||||
|
cy="16"
|
||||||
|
cx="16"
|
||||||
|
fill="none"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeWidth={nearBottom ? 4 : 8}
|
||||||
|
strokeDashoffset={RING_CIRCUMFERENCE * (1 - progress)}
|
||||||
|
strokeDasharray={RING_CIRCUMFERENCE}
|
||||||
|
transform="rotate(-90 16 16)"
|
||||||
|
style={{
|
||||||
|
transition:
|
||||||
|
"stroke-opacity 0.66s cubic-bezier(0.66, 0, 0.01, 1), stroke-width 0.66s cubic-bezier(0.66, 0, 0.01, 1)",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Original useNearBottom(.5) ratio. */
|
||||||
|
function nearBottomRatio() {
|
||||||
|
return 0.5;
|
||||||
|
}
|
||||||
@@ -6,20 +6,21 @@ import ScrambleReveal from "@/components/dom/ScrambleReveal";
|
|||||||
* #contact footer — 1:1 port of the original footer (chunk 2689132c4e070b68.js
|
* #contact footer — 1:1 port of the original footer (chunk 2689132c4e070b68.js
|
||||||
* module 28192):
|
* module 28192):
|
||||||
*
|
*
|
||||||
* - `<footer id="contact">` fills the last viewport (h-dvh / lg:h-screen),
|
* - `<footer id="contact">` fills the last viewport (h-dvh / lg:h-screen)
|
||||||
* z-10 (below the fixed canvas at z-30, above the grid) and carries
|
* and carries `data-section="footer"` — SmoothScroller's sP f2 factor and
|
||||||
* `data-section="footer"` — SmoothScroller's sP f2 factor and PostFX's
|
* PostFX's bright-source gating both read this attribute.
|
||||||
* bright-source gating both read this attribute.
|
|
||||||
* - Headline: three 12-col grid rows at 6svw, "Let's / Create / Something /
|
* - Headline: three 12-col grid rows at 6svw, "Let's / Create / Something /
|
||||||
* Extraordinary"; "Create" and "Extraordinary" use reverse reveal (chars
|
* Extraordinary"; "Create" and "Extraordinary" use reverse reveal (chars
|
||||||
* run last→first).
|
* run last→first).
|
||||||
* - Bottom bar: mailto + Twitter/X / Figma / GitHub links with the dotted
|
* - Bottom bar: mailto + Twitter/X / Figma / GitHub links with the dotted
|
||||||
* hover border.
|
* hover border.
|
||||||
*
|
*
|
||||||
* NOTE: contact targets are placeholders — swap in VIRTHEART's real email
|
* NOTE: contact email is chenchun@virtheart.com (user-provided); social
|
||||||
* and social URLs.
|
* URLs are still placeholders.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const CONTACT_EMAIL = "chenchun@virtheart.com";
|
||||||
|
|
||||||
const dottedLink =
|
const dottedLink =
|
||||||
"block before:absolute relative before:inset-0 p-2 lg:hover:before:border-l1 before:border-2 before:border-transparent active:before:border-l1 before:border-dotted uppercase before:content-[''] before:transition-colors before:duration-200 cursor-pointer pointer-events-auto before:pointer-events-none";
|
"block before:absolute relative before:inset-0 p-2 lg:hover:before:border-l1 before:border-2 before:border-transparent active:before:border-l1 before:border-dotted uppercase before:content-[''] before:transition-colors before:duration-200 cursor-pointer pointer-events-auto before:pointer-events-none";
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ export default function FooterSection() {
|
|||||||
<footer
|
<footer
|
||||||
id="contact"
|
id="contact"
|
||||||
data-section="footer"
|
data-section="footer"
|
||||||
className="z-30 relative flex flex-col justify-center p-6 lg:p-16 w-full h-dvh lg:h-screen pointer-events-none"
|
className="relative flex flex-col justify-center p-6 lg:p-16 w-full h-dvh lg:h-screen pointer-events-none"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="gap-2 grid grid-cols-12 font-bold text-[7.2svw] lg:text-[6svw] 2xl:text-[5svw] xl:text-[5.6svw] uppercase leading-none"
|
className="gap-2 grid grid-cols-12 font-bold text-[7.2svw] lg:text-[6svw] 2xl:text-[5svw] xl:text-[5.6svw] uppercase leading-none"
|
||||||
@@ -79,17 +80,15 @@ export default function FooterSection() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="absolute inset-0 flex flex-col justify-end px-4 lg:px-14 py-18 lg:py-24 font-mono-2 text-sm lg:text-base">
|
<div className="absolute inset-0 flex flex-col justify-end px-4 lg:px-14 py-18 lg:py-24 font-mono-2 text-sm lg:text-base">
|
||||||
<div className="flex lg:flex-row flex-col justify-between w-full">
|
<div className="flex lg:flex-row flex-col justify-between w-full">
|
||||||
{/* TODO: replace with the real VIRTHEART contact address. */}
|
<a className={dottedLink} href={`mailto:${CONTACT_EMAIL}`}>
|
||||||
<a className={dottedLink} href="mailto:hello@virtheart.com">
|
|
||||||
<ScrambleReveal
|
<ScrambleReveal
|
||||||
text="hello@virtheart.com"
|
text={CONTACT_EMAIL}
|
||||||
startDelayMs={300}
|
startDelayMs={300}
|
||||||
scrambleColors={false}
|
scrambleColors={false}
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
<div className="flex flex-row items-center gap-2 lg:gap-4">
|
<div className="flex flex-row items-center gap-2 lg:gap-4">
|
||||||
{/* TODO: replace with the real VIRTHEART social URLs. */}
|
{/* TODO: replace with the real VIRTHEART social URLs. */}{SOCIALS.map(({ href, label }) => (
|
||||||
{SOCIALS.map(({ href, label }) => (
|
|
||||||
<a
|
<a
|
||||||
key={label}
|
key={label}
|
||||||
className={dottedLink}
|
className={dottedLink}
|
||||||
|
|||||||
@@ -549,7 +549,7 @@ export default function HyperSpaceSection() {
|
|||||||
getLayerTarget("hyper-space").current = el;
|
getLayerTarget("hyper-space").current = el;
|
||||||
void el;
|
void el;
|
||||||
}}
|
}}
|
||||||
className={`relative z-30 ${ARROW_FULLSCREEN_DOM_COLOR_TRANSITION} ${
|
className={`relative ${ARROW_FULLSCREEN_DOM_COLOR_TRANSITION} ${
|
||||||
pastThreshold ? "text-white" : "text-l1"
|
pastThreshold ? "text-white" : "text-l1"
|
||||||
}`}
|
}`}
|
||||||
style={{ height: `${8 * viewportH}px` }}
|
style={{ height: `${8 * viewportH}px` }}
|
||||||
|
|||||||
@@ -0,0 +1,164 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RouteTransitionOverlay — 1:1 port of the original orchestrator (chunk
|
||||||
|
* 3c6cc5b2fcccdee5.js `function M`, module 34841), simplified to the pixel
|
||||||
|
* wipe without the WebGL mask material:
|
||||||
|
*
|
||||||
|
* startNavigation(href)
|
||||||
|
* → phase "cover" : b1-colored fixed layer wipes IN over the page
|
||||||
|
* (0.8s, cubic-bezier(0.66, 0, 0.01, 1)); on complete → router.push
|
||||||
|
* (or replace) to the target href.
|
||||||
|
* → phase "wait" : new page mounts; heavy assets may still load.
|
||||||
|
* → phase "reveal" : layer wipes OUT (same easing), then → idle and
|
||||||
|
* the overlay unmounts; scramble lines re-enabled 100ms in.
|
||||||
|
*
|
||||||
|
* The b1 background matches the page body so the wipe reads as the page
|
||||||
|
* turning into a blank sheet — the original achieves the same look via the
|
||||||
|
* WebGL mask + grid colors.
|
||||||
|
*/
|
||||||
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
|
import { usePathname, useRouter } from "next/navigation";
|
||||||
|
import { useRouteTransitionController } from "@/lib/routeTransition";
|
||||||
|
|
||||||
|
type Phase = "wait" | "cover" | "reveal";
|
||||||
|
type Mode = "idle" | "entry" | "route";
|
||||||
|
|
||||||
|
const DURATION_MS = 800;
|
||||||
|
const EASING = "cubic-bezier(0.66, 0, 0.01, 1)";
|
||||||
|
const BG = "var(--color-b1)";
|
||||||
|
|
||||||
|
export default function RouteTransitionOverlay() {
|
||||||
|
const router = useRouter();
|
||||||
|
const pathname = usePathname();
|
||||||
|
const { targetHref, navigationReplace, clearNavigation, setAllowScrambleLines } =
|
||||||
|
useRouteTransitionController();
|
||||||
|
|
||||||
|
const routeFrom = useRef<{ path: string | null; coverDone: boolean }>({
|
||||||
|
path: null,
|
||||||
|
coverDone: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [mode, setMode] = useState<Mode>("idle");
|
||||||
|
const [phase, setPhase] = useState<Phase>("wait");
|
||||||
|
|
||||||
|
const navigateRef = useRef<() => void>(() => {});
|
||||||
|
navigateRef.current = () => {
|
||||||
|
if (mode === "route" && phase === "cover") {
|
||||||
|
routeFrom.current.coverDone = true;
|
||||||
|
setAllowScrambleLines(false);
|
||||||
|
if (targetHref) {
|
||||||
|
if (navigationReplace) router.replace(targetHref);
|
||||||
|
else router.push(targetHref);
|
||||||
|
}
|
||||||
|
setPhase("wait");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const targetPath = useMemo(() => {
|
||||||
|
if (!targetHref) return null;
|
||||||
|
if (targetHref.startsWith("/")) {
|
||||||
|
const [p] = targetHref.split("?");
|
||||||
|
return p || "/";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return new URL(targetHref, window.location.origin).pathname || "/";
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, [targetHref]);
|
||||||
|
|
||||||
|
// Intent → start cover.
|
||||||
|
useEffect(() => {
|
||||||
|
if (targetHref && mode === "idle") {
|
||||||
|
routeFrom.current.path = pathname;
|
||||||
|
routeFrom.current.coverDone = false;
|
||||||
|
setMode("route");
|
||||||
|
setPhase("cover");
|
||||||
|
}
|
||||||
|
}, [targetHref, mode, pathname]);
|
||||||
|
|
||||||
|
// New page mounted → reveal.
|
||||||
|
useEffect(() => {
|
||||||
|
if (
|
||||||
|
mode === "route" &&
|
||||||
|
phase === "wait" &&
|
||||||
|
routeFrom.current.coverDone &&
|
||||||
|
routeFrom.current.path &&
|
||||||
|
pathname !== routeFrom.current.path
|
||||||
|
) {
|
||||||
|
setPhase("reveal");
|
||||||
|
}
|
||||||
|
}, [mode, phase, pathname]);
|
||||||
|
|
||||||
|
// Reveal finished → idle.
|
||||||
|
const onRevealComplete = () => {
|
||||||
|
if (mode !== "idle" && phase === "reveal") {
|
||||||
|
setMode("idle");
|
||||||
|
clearNavigation();
|
||||||
|
routeFrom.current.path = null;
|
||||||
|
routeFrom.current.coverDone = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Scramble lines gate (original: idle → true immediately; 100ms after
|
||||||
|
// a reveal starts).
|
||||||
|
useEffect(() => {
|
||||||
|
if (mode === "idle") {
|
||||||
|
setAllowScrambleLines(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (phase !== "reveal") return;
|
||||||
|
const t = window.setTimeout(() => setAllowScrambleLines(true), 100);
|
||||||
|
return () => window.clearTimeout(t);
|
||||||
|
}, [mode, phase, setAllowScrambleLines]);
|
||||||
|
|
||||||
|
const overlayVisible = mode !== "idle" && phase !== "wait";
|
||||||
|
const wipeIn = phase === "cover";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
aria-hidden={!overlayVisible}
|
||||||
|
style={{
|
||||||
|
position: "fixed",
|
||||||
|
inset: 0,
|
||||||
|
zIndex: 60,
|
||||||
|
background: BG,
|
||||||
|
pointerEvents: overlayVisible ? "auto" : "none",
|
||||||
|
opacity: overlayVisible ? 1 : 0,
|
||||||
|
visibility: overlayVisible ? "visible" : "hidden",
|
||||||
|
transition: overlayVisible
|
||||||
|
? `opacity 80ms linear`
|
||||||
|
: `opacity 200ms linear`,
|
||||||
|
clipPath: overlayVisible
|
||||||
|
? wipeIn
|
||||||
|
? "inset(0 0 100% 0)"
|
||||||
|
: "inset(0 0 0 0)"
|
||||||
|
: "inset(0 0 100% 0)",
|
||||||
|
...(overlayVisible
|
||||||
|
? {
|
||||||
|
animation: `route-wipe ${DURATION_MS}ms ${EASING} forwards`,
|
||||||
|
animationDirection: wipeIn ? "normal" : "reverse",
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
}}
|
||||||
|
onAnimationEnd={(e) => {
|
||||||
|
if (e.animationName !== "route-wipe") return;
|
||||||
|
if (wipeIn) navigateRef.current();
|
||||||
|
else onRevealComplete();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<style>{`@keyframes route-wipe { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }`}</style>
|
||||||
|
{/* 16px checker texture (original pixelSize:16 maskCells) */}
|
||||||
|
<div
|
||||||
|
className="absolute inset-0 pointer-events-none"
|
||||||
|
style={{
|
||||||
|
opacity: 0.05,
|
||||||
|
backgroundImage:
|
||||||
|
"repeating-conic-gradient(var(--color-l1) 0% 25%, transparent 0% 50%)",
|
||||||
|
backgroundSize: "32px 32px",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -11,7 +11,9 @@ import {
|
|||||||
setLayerDef,
|
setLayerDef,
|
||||||
touchLayerRegistry,
|
touchLayerRegistry,
|
||||||
} from "@/lib/imageLayers";
|
} from "@/lib/imageLayers";
|
||||||
import { usePasscodeAccessLookup } from "@/components/dom/PasscodeAccess";
|
import { usePasscodeAllowed, usePasscodeAccessLookup } from "@/components/dom/PasscodeAccess";
|
||||||
|
import { buildPasscodeUnlockHref } from "@/lib/passcode";
|
||||||
|
import { useRouteTransitionController } from "@/lib/routeTransition";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selected Work grid — 1:1 port of the original section `h` (chunk
|
* Selected Work grid — 1:1 port of the original section `h` (chunk
|
||||||
@@ -124,6 +126,8 @@ function WorkCard({ item, ratio }: { item: WorkItem; ratio?: string }) {
|
|||||||
const cls = "group block space-y-3 p-2";
|
const cls = "group block space-y-3 p-2";
|
||||||
const label = `${item.name} - ${item.year}${external ? " (external)" : ""}`;
|
const label = `${item.name} - ${item.year}${external ? " (external)" : ""}`;
|
||||||
const target = getLayerTarget(item.href);
|
const target = getLayerTarget(item.href);
|
||||||
|
const { startNavigation } = useRouteTransitionController();
|
||||||
|
const allowed = usePasscodeAllowed(item.href);
|
||||||
const body = (
|
const body = (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
@@ -171,13 +175,31 @@ function WorkCard({ item, ratio }: { item: WorkItem; ratio?: string }) {
|
|||||||
{body}
|
{body}
|
||||||
</a>
|
</a>
|
||||||
) : (
|
) : (
|
||||||
// Internal detail routes (/reunimos, /inspire_mono, …) are not ported
|
// Internal detail routes (/reunimos, /inspire_mono, …) navigate
|
||||||
// yet — keep the anchor for markup parity but don't navigate to a 404.
|
// through the fullscreen cover/reveal transition (original Link
|
||||||
|
// wrapper module 80894: preventDefault + startNavigation; same-path
|
||||||
|
// clicks scroll back to top).
|
||||||
<a
|
<a
|
||||||
href={item.href}
|
href={item.href}
|
||||||
className={cls}
|
className={cls}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
onClick={(e) => e.preventDefault()}
|
onClick={(e) => {
|
||||||
|
if (e.defaultPrevented) return;
|
||||||
|
if (e.button !== 0 || e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)
|
||||||
|
return;
|
||||||
|
e.preventDefault();
|
||||||
|
if (!allowed) {
|
||||||
|
const scope = item.href.replace(/^\//, "");
|
||||||
|
window.location.assign(
|
||||||
|
buildPasscodeUnlockHref(scope, item.href)
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const detail = item.href.startsWith("/2026")
|
||||||
|
? item.href
|
||||||
|
: `/work${item.href}`;
|
||||||
|
startNavigation(detail);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{body}
|
{body}
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -0,0 +1,267 @@
|
|||||||
|
/**
|
||||||
|
* Work detail article content — extracted 1:1 from the original site's
|
||||||
|
* rendered detail pages (haoqi.design/{reunimos,inspire_mono,...}, MDX
|
||||||
|
* article markup parsed into typed segments on 2026-02). Images stay as the
|
||||||
|
* original external CDN URLs; links keep their original hrefs. `meta` is the
|
||||||
|
* original data-mdx-footer Metadata table; `iframe` the live-site preview
|
||||||
|
* embed when the original has one.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export type InlineSeg =
|
||||||
|
| { t: "text"; v: string }
|
||||||
|
| { t: "link"; v: string; href: string };
|
||||||
|
|
||||||
|
export type ArticleBlock =
|
||||||
|
| { type: "p"; segs: InlineSeg[] }
|
||||||
|
| { type: "h2"; text: string }
|
||||||
|
| { type: "h3"; text: string }
|
||||||
|
| { type: "img"; src: string }
|
||||||
|
| { type: "hr" }
|
||||||
|
| { type: "list"; ordered: boolean; items: InlineSeg[][] }
|
||||||
|
| { type: "quote"; items: string[] }
|
||||||
|
| { type: "code"; text: string };
|
||||||
|
|
||||||
|
export type WorkArticle = {
|
||||||
|
title: string;
|
||||||
|
date: string;
|
||||||
|
year: string;
|
||||||
|
meta: [string, string][] | null;
|
||||||
|
iframe: { src: string; title: string } | null;
|
||||||
|
blocks: ArticleBlock[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const WORK_ARTICLES: Record<string, WorkArticle> = {
|
||||||
|
"/reunimos": {
|
||||||
|
title: "Reunimos™",
|
||||||
|
date: "May 31, 2026",
|
||||||
|
year: "2024-2026",
|
||||||
|
meta: [
|
||||||
|
["Last Updated", "May 31, 2026"],
|
||||||
|
["Dimensions", "1×1"],
|
||||||
|
["Characters", "—"],
|
||||||
|
],
|
||||||
|
iframe: { src: "https://www.reunimos.cc", title: "Reunimos preview" },
|
||||||
|
blocks: [
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "Reunimos™ 是我从 2024 年起构建的个人 AI 灵感收藏夹。一个地方,接住你在浏览、阅读、随手截图时掉落的参考:图片、链接、文档、片段想法,先收进来,不必先想好该放进哪个文件夹。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "它面向个人:不做协作,也不催促你「整理得更漂亮」。我更希望它像一块私人的视觉记忆板,少花时间管理,多留空间给真正会回访的灵感。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "保存之后,AI 会理解内容、补全上下文;界面以视觉优先的方式呈现,让你按颜色、意象,或某一刻模糊的印象去找回来,而不只是靠标题或路径回忆。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "动效与界面质感由 Rive、Motion 与 Shader 共同驱动,整体视觉偏向圆润平滑,贴合年轻用户,长时间使用也依然耐看。2025 年还在 Chrome 下接入了 Liquid Glass 特效,让玻璃质感与这套界面语言更统一。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "我对 UI 要求很高,现成工具链往往达不到我想要的效果,于是我为自己搭了一整套 UI 工具库,后来打包开源为 " }, { t: "link", v: "@wenhaoqi/wasm_design_utils", href: "https://www.npmjs.com/package/@wenhaoqi/wasm_design_utils" }, { t: "text", v: "。图片主色与调色板提取用 extractColors(@wenhaoqi/wasm_design_utils/extract-colors);sRGB ↔ OKLCH 转换用 rgb2oklch、oklch2rgb_abs、oklch2rgb_rel(@wenhaoqi/wasm_design_utils/color);squircle / capsule 平滑圆角路径用 getSquircle、getCapsule、getPath(@wenhaoqi/wasm_design_utils/squircle)。Reunimos 里三者都会用到:取色支撑视觉检索与卡片氛围,OKLCH 负责色彩换算,squircle 路径撑起圆润的界面形态,都是我在做设计、打磨产品时沉淀下来的,后来发布开源,也希望帮到有需要的人。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "欢迎去 " }, { t: "link", v: "reunimos.cc", href: "https://www.reunimos.cc" }, { t: "text", v: " 注册体验,保存一张图、一条链接,感受一下这套视觉优先的收藏方式。" }] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"/inspire_mono": {
|
||||||
|
title: "Inspire Mono",
|
||||||
|
date: "May 07, 2026",
|
||||||
|
year: "2025",
|
||||||
|
meta: [
|
||||||
|
["Last Updated", "May 07, 2026"],
|
||||||
|
["Dimensions", "1×1"],
|
||||||
|
["Characters", "—"],
|
||||||
|
],
|
||||||
|
iframe: null,
|
||||||
|
blocks: [
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "InspireMono 是我在 2025 年一次基于 vibe coding 的实验项目,灵感来自 " }, { t: "link", v: "RSMS 的字体工作流", href: "https://www.figma.com/community/file/1115382696459820988" }, { t: "text", v: ":通过 Figma 绘制 glyph,并结合脚本将字形导出为字体。我让 agent 分析了其中关键的字体构建流程,最终定位到基于 " }, { t: "link", v: "opentype.js", href: "https://opentype.js.org" }, { t: "text", v: " 的字体生成能力——这也是目前 JavaScript 生态里最成熟的字体读写与构建库之一。\n最初,我只是想做一个能在 Figma 中绘制并管理图标字体的小工具,类似过去做的 " }, { t: "link", v: "VectorSymbols", href: "https://www.figma.com/community/plugin/1255914175202017737/vectorsymbols" }, { t: "text", v: ";但随着开发推进,对字体构建本身的兴趣逐渐超过了图标管理,于是项目开始演变成一个完整的字体构建插件。它支持字体元信息、OpenType Ligatures、数字与符号变体(Stylistic Sets)、替换字形等特性,并逐步扩展出图标字体、字体管理工具以及最终的 InspireMono 字体本身。字体外观则参考并融合了部分 " }, { t: "link", v: "TikTok Sans", href: "https://www.tiktok.com/font" }, { t: "text", v: " 的设计特征。近期准备开源字体的 Figma 源文件。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "下载 InspireMono.zip" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/Cover.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/1.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/2.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/3.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/4.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/5.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/6.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/7.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/8.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/9.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/10.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/11.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/12.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/13.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/mono/14.png" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"/wasm_design_utils": {
|
||||||
|
title: "Wasm design utils",
|
||||||
|
date: "May 31, 2026",
|
||||||
|
year: "2025",
|
||||||
|
meta: [
|
||||||
|
["Last Updated", "May 31, 2026"],
|
||||||
|
["Dimensions", "1×1"],
|
||||||
|
["Characters", "—"],
|
||||||
|
],
|
||||||
|
iframe: null,
|
||||||
|
blocks: [
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "@wenhaoqi/wasm_design_utils 是一组浏览器端设计小工具:sRGB ↔ OKLCH 色彩转换、图片取色、以及 squircle / capsule 的 SVG 路径生成。npm:" }, { t: "link", v: "@wenhaoqi/wasm_design_utils", href: "https://www.npmjs.com/package/@wenhaoqi/wasm_design_utils" }, { t: "text", v: "。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "它最初是在做 " }, { t: "link", v: "Reunimos™", href: "/reunimos" }, { t: "text", v: " 时沉淀下来的,后来打包开源。" }] },
|
||||||
|
{ type: "h2", text: "#安装" },
|
||||||
|
{ type: "code", text: "1npm install @wenhaoqi/wasm_design_utils" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "包是 ESM,WASM 默认内联在包里,一般不用自己托管 .wasm 文件。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "所有 API 都是 async,调用时要 await。" }] },
|
||||||
|
{ type: "h2", text: "#三个模块,按需引入" },
|
||||||
|
{ type: "list", ordered: false, items: [[{ t: "text", v: "@wenhaoqi/wasm_design_utils/color — RGB ↔ OKLCH" }], [{ t: "text", v: "@wenhaoqi/wasm_design_utils/extract-colors — 从图片提取主色" }], [{ t: "text", v: "@wenhaoqi/wasm_design_utils/squircle — 生成平滑圆角 SVG path" }]] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "也可以从根路径 @wenhaoqi/wasm_design_utils 一次性导入全部 API。" }] },
|
||||||
|
{ type: "h2", text: "#颜色" },
|
||||||
|
{ type: "code", text: "1import { rgb2oklch, oklch2rgb_abs, oklch2rgb_rel } from \"@wenhaoqi/wasm_design_utils/color\";2\n3// sRGB 0–255 → OKLCH4const { L, C, h } = await rgb2oklch(128, 100, 231);5\n6// OKLCH → sRGB,直接指定色度7const { R, G, B } = await oklch2rgb_abs(L, C, h);8\n9// 只定明暗和色相,彩度用 0–1 滑杆(更直觉)10const tint = await oklch2rgb_rel(L, h, 0.5);" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "init() 可选。不传的话,第一次调用转换函数时会自动加载 WASM;想在页面启动时预热,可以提前 await init()。" }] },
|
||||||
|
{ type: "h2", text: "#取色" },
|
||||||
|
{ type: "code", text: "1import extractColors from \"@wenhaoqi/wasm_design_utils/extract-colors\";2\n3// 从 <img> 提取调色板,第一个色块通常是主色4const [dominant, ...rest] = await extractColors(img);5\n6// 常用参数7const palette = await extractColors(img, {8 pixels: 64000, // 抽样分辨率,默认 640009 distance: 0.22, // 聚类距离10 crossOrigin: \"anonymous\", // 跨域图片 URL 时需要11});" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "input 支持:图片 URL 字符串、<img> / Image、ImageData。" }] },
|
||||||
|
{ type: "h2", text: "#平滑圆角" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "普通 border-radius 在大圆角时转角容易发尖;squircle 用 SVG path 过渡更顺。" }] },
|
||||||
|
{ type: "code", text: "1import { getPath } from \"@wenhaoqi/wasm_design_utils/squircle\";2\n3const d = await getPath(\"squircle\", 200, 120, 16);4pathEl.setAttribute(\"d\", d);5// viewBox 对应:0 0 200 120" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "shape 也可以是 "capsule"(胶囊形标签、Chip 等)。" }] },
|
||||||
|
{ type: "h2", text: "#本站怎么用" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "文章页图片放大时,会用取色 + OKLCH 生成跟图片主色接近的蒙层背景:" }] },
|
||||||
|
{ type: "list", ordered: true, items: [[{ t: "text", v: "extractColors 取主色" }], [{ t: "text", v: "rgb2oklch 转成 OKLCH" }], [{ t: "text", v: "按明暗主题调整亮度,再 oklch2rgb_abs 转回 RGB" }]] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "这样全屏查看图片时,背景不会突兀地跳成纯黑。" }] },
|
||||||
|
{ type: "h2", text: "#Next.js 注意" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "需要在客户端使用(依赖 Image 和 WebAssembly)。放在 "use client" 组件里,或用动态 import() 加载即可。" }] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"/adrive": {
|
||||||
|
title: "aDrive 阿里云盘",
|
||||||
|
date: "Jan 07, 2022",
|
||||||
|
year: "",
|
||||||
|
meta: [
|
||||||
|
["Last Updated", "Jan 07, 2022"],
|
||||||
|
["Dimensions", "1×1"],
|
||||||
|
["Characters", "—"],
|
||||||
|
],
|
||||||
|
iframe: null,
|
||||||
|
blocks: [
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "从零搭建阿里云盘设计系统,并参与其长期维护,支撑全端设计语言统一与设计组件复用。参与首页、各版本导航结构与启动器框架,以及影音播放器等业务设计;同时开发或协作开发设计系统文档工具 ADS 客户端与 Figma design token 导出工具。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "Teambition 网盘是阿里云盘的前身。前期为了快速搭建并验证方向,我们选择在 Teambition 主产品内「生长」:底层天然具备协作能力,无论面向企业还是个人,都比从零起步更省力。设计侧同样如此,直接沿用成熟的 " }, { t: "link", v: "Clarity design", href: "https://design.teambition.com" }, { t: "text", v: ",也无需再搭一套全新的设计系统。" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad1.jpg" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "首页、传输列表、相册分享菜单" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad2.jpg" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "文件预览、文件预览讨论圈点、视频弹幕圈点(概念)" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "在获得外界与集团内部认可之后,我们决定把它做成独立的客户端,并争取到更充裕的研发资源;资源到位之后,也就有条件从零建立一套新的设计系统。" }] },
|
||||||
|
{ type: "h2", text: "#ADS 架构" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad3.png" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "ADS 有两个驱动核心:一是设计目标,二是业务目标。我们刻意不把二者混为一谈——业务诉求本身并不会自动指向更好的用户体验。持续迭代、不断补全的设计目标,才是拉升体验的主轴;业务目标则负责在收益与体验之间拿捏分寸,避免过度设计。" }] },
|
||||||
|
{ type: "h2", text: "#ADS 设计原则" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "好的工作流能够显著提高团队效率;相较某些偏形而上的设计方法,它对组织而言往往更落地、也更容易推广。设计系统本质上就是设计、产品、工程有机融合的一条工作流,Figma 等工具协作可以帮助完成约 60% 的工作,其余部分要靠管理机制与各相关方达成共识来补齐。" }] },
|
||||||
|
{ type: "h3", text: "#规范简洁" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad4.png" },
|
||||||
|
{ type: "list", ordered: false, items: [[{ t: "text", v: "场景命名" }], [{ t: "text", v: "使用缩写" }], [{ t: "text", v: "层级清晰" }]] },
|
||||||
|
{ type: "h3", text: "#高度复用" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad5.png" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad6.png" },
|
||||||
|
{ type: "list", ordered: false, items: [[{ t: "text", v: "组件复用" }], [{ t: "text", v: "跨端一致性" }], [{ t: "text", v: "统一 Token 管理" }]] },
|
||||||
|
{ type: "h3", text: "#可持续性" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad7.png" },
|
||||||
|
{ type: "list", ordered: false, items: [[{ t: "text", v: "反馈敏捷" }], [{ t: "text", v: "受控逃逸 / Escape hatch(允许在特殊情况下跨出设计系统的既定限制,避免机制僵化;并非鼓励随意破窗,而是为真实业务留出可控出口)" }]] },
|
||||||
|
{ type: "h2", text: "#ADS 周边工具链" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad8.png" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "ADS 客户端基于 Gatsby 与 Electron 开发,用于承载设计系统文档、组件演示与设计资源整合。对仅有 Figma 查看权限的同学,它还能把多条设计稿链接拼成一张「设计地图」。在团队语境里,大家默认:凡与云盘设计相关的内容,都会在 ADS 客户端里找到对应落点。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "Fridge 也被纳入阿里云盘项目,用于把更完整的色板与 icon 实时同步给使用者。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "Figma Time Line 是我们借助 Figma 的 Auto Layout「搭」出来的排期看板,全组的工作日程都通过它来对齐。" }] },
|
||||||
|
{ type: "hr" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad9.jpg" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "阿里云盘在上线初期收获好评之后,为了在行业内做出差异化、参与竞争,团队探索了以「场景」为核心的个人云:用户不仅能把数字资产放进云盘,还能按不同使用场景在云盘内完成消费,而不必反复跳转到其他应用,从而形成「存—用」一体的个人数字资产闭环。" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad10.jpg" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "滑动导航与启动器" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "滑动导航是一次有趣的探索:我们希望单一导航栏仍能完整呈现「个人云」的能力版图,又不能牺牲可用性。这一方案在设计冲刺阶段我曾持保留态度,但在原型与可用性测试之后我改变了看法;我接手了与滑动导航相关的全部设计工作,并最终推动上线——日后有机会可以再单独展开当时的推演与取舍。" }] },
|
||||||
|
{ type: "hr" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad11.jpg" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "多功能菜单、分享菜单" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "多功能菜单既贴合当代产品的操作习惯,又比层层模态与二级页面更轻、更快;相较传统的 Action sheet,它在布局与信息密度上也更自由。这也是许多优质 iOS 与 Android 应用正在采用的设计趋势之一。" }] },
|
||||||
|
{ type: "hr" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad12.jpg" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "音频播放器、视频播放器、放映室" }] },
|
||||||
|
{ type: "hr" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad13.jpg" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "占位符" }] },
|
||||||
|
{ type: "hr" },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/adrive/ad14.jpg" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "高度统一的桌面端" }] },
|
||||||
|
{ type: "hr" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "最后,在阿里云盘与 Teambition 的这段经历非常充实:不仅让我的设计能力有了明显提升,也结识了许多一路互相促进的伙伴。" }] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"/shore_icon": {
|
||||||
|
title: "Shore Icon",
|
||||||
|
date: "Mar 01, 2022",
|
||||||
|
year: "2022",
|
||||||
|
meta: [
|
||||||
|
["Last Updated", "Mar 01, 2022"],
|
||||||
|
["Dimensions", "1×1"],
|
||||||
|
["Characters", "—"],
|
||||||
|
],
|
||||||
|
iframe: null,
|
||||||
|
blocks: [
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "在 Shore 的工作时间不长,但我做了一套风格现代、维护成本可控的图标系统(Icon System)。过程中主要参考了刚完成重构的 " }, { t: "link", v: "Spotify Icon System", href: "https://spotify.design/article/refreshing-our-icon-system-the-why-and-how-behind-the-changes" }, { t: "text", v: "、微软的 " }, { t: "link", v: "Microsoft Fluent System Icons", href: "https://www.figma.com/community/file/836835755999342788/Microsoft-Fluent-System-Icons" }, { t: "text", v: ",以及业内的 " }, { t: "link", v: "SF Symbols", href: "https://developer.apple.com/design/resources/#sf-symbols" }, { t: "text", v: "。这套系统在风格管理、版本管理、跨端表现和自动化交付上都更顺手,我也希望把其中的经验留给正在从零搭建或准备重构图标系统的团队与设计师。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "要做一套好用的图标系统,风格统一、识别清晰、交付与管理简单——听起来是共识,真正落地时每一环都可能变成痛点。" }] },
|
||||||
|
{ type: "h2", text: "#风格统一" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "图标能不能称为「系统」,第一条往往是够不够统一。我们以前的做法,是在统一尺寸的画布上,用一套网格约束、几档规范的圆角和统一的描边粗细去框图形。这样顶多统一了表层样式;若网格卡得太死,执行时很容易出现「多一格嫌长、少一格嫌短」的别扭,反而违背视觉直觉。" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/shore/icon01.png" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "Material 与 Ant Design 的图标网格" }] },
|
||||||
|
{ type: "h2", text: "#识别清晰" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "图标传达内容,不只靠外形,还与最小可用尺寸、正负形是否一致有关;这些细节会直接影响识别,也容易制造视觉错觉。" }] },
|
||||||
|
{ type: "h3", text: "#交付与管理" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "把多人绘制的图标收成一套资源,本身就很费神。好在 Figma 能让更多人在同一份设计稿里协作,历史版本也算能管。但设计稿的版本并不等于研发最终接手的版本,两者很容易脱节。每次还要按端单独导出格式,若没有专人维护,输出就会越来越乱,最后线上各端各版本、各画各的图标。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "阿里巴巴的 " }, { t: "link", v: "iconfont", href: "https://www.iconfont.cn/" }, { t: "text", v: " 在上一代工具里很好地缓解过这些问题,但以今天的协作与工程节奏来看,已经明显不够用了。" }] },
|
||||||
|
{ type: "h2", text: "#SF Symbols" },
|
||||||
|
{ type: "p", segs: [{ t: "link", v: "SF Symbols →", href: "https://developer.apple.com/design/resources/#sf-symbols" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "门槛最低:多数设计师的 Mac 上都装得到 SF Symbols。细读之后会发现,无论从哪个维度看,这套图标都相当出色。" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/shore/icon02.png" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "SF 的图标与 SF Pro 是一起为混排设计的,因此字形的中线、基线也会进图标参考;字体没有「裁剪内容」一类的包袱,边缘留多少不必纠结。每个字重都有对应图标,第一眼就很震撼。3.0 起又补了大量彩色图标,同样基于彩色字体。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "我把 SF 放进 Figma 看路径时发现:每个字重下还有 5 档相对宽度,而且宽度变化是线性的,并不是随便挑几个档位——多半是为了让描边粗细在观感上更均匀。另一个细节是转折与交叉处的「收口」,这是字形里常用的手法,让弯折处看起来和直线段一样稳,小尺寸也更清楚;在成千上万枚图标里坚持这样做,非常难得。" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/shore/icon03.png" },
|
||||||
|
{ type: "h2", text: "#Microsoft Fluent System Icons" },
|
||||||
|
{ type: "p", segs: [{ t: "link", v: "Microsoft Fluent System Icons →", href: "https://www.figma.com/community/file/836835755999342788/Microsoft-Fluent-System-Icons" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "微软更慷慨一些,把整套图标系统设计稿放在 Figma 社区里,规范也写得清楚,很适合当教材。" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/shore/icon04.png" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "Fluent 讲了网格、不同类型外形的画法、怎么测视觉权重、填充图标怎么处理,以及角标不要挡关键信息——而不只是「铺一层底色」那种粗暴做法,等等。" }] },
|
||||||
|
{ type: "h2", text: "#Spotify Icon System" },
|
||||||
|
{ type: "p", segs: [{ t: "link", v: "Refreshing our Icon System: the why and how behind the changes →", href: "https://spotify.design/article/refreshing-our-icon-system-the-why-and-how-behind-the-changes" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/shore/icon05.png" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "在我看来,Spotify 很擅长用较低成本换较大收益,跨端设计系统就是例子;这次图标系统更新也延续了同一套思路。" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/shore/icon06.png" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "新系统用两种线宽覆盖两类尺寸区间,并对不同线宽做不同细化——相比 SF 为每个字重各做一整套图标,更贴近「资源没有苹果那么宽裕」的普通团队。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "有了前面的输入,我想做一套自己的图标系统:视觉统一、识别清楚、手感平衡,还要有一条顺手的交付链路。把整套库做成能和文字自然混排的字体,对我来说不现实,维护和绘制成本都太高,最后还是落在更主流的 SVG 上。不同的是我选了 " }, { t: "link", v: "SVG Symbol", href: "https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/symbol" }, { t: "text", v: " 这种单文件、多图形的组织方式,导出则依赖我自研的 Figma 插件 " }, { t: "link", v: "VectorS", href: "/stories/figma_and_me#vectors" }, { t: "text", v: "。" }] },
|
||||||
|
{ type: "h2", text: "#多重线宽" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "我借鉴了 SF 的多档线宽思路,在 24×24 的格子里找出视觉平衡的 5 档宽度,并为每一档写了使用说明。" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/shore/icon07.png" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "为了批量整理图标在 Frame 里的适配规则、少手填线宽,我在 VectorS 里加了一串小工具做样式填充,线宽这一层就这样收住了。" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/shore/icon08.png" },
|
||||||
|
{ type: "h2", text: "#非严格的网格" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "很多第三方图标不如官方图标「舒服」,很大一部分原因是对网格的理解:网格应是参照,而不是枷锁;在网格给定的范围里画出舒服的形,比处处贴齐更重要。各家的官方图标也不是死板对齐,而是灵活运用对齐与对比。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "我画了一套偏「非严格」的辅助网格,定形之后再配合模糊看视觉权重。" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/shore/icon09.png" },
|
||||||
|
{ type: "h2", text: "#非零与偶奇填充" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "非零规则(non-zero)与偶奇规则(even-odd)对应 SVG 的 " }, { t: "link", v: "fill-rule", href: "https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/fill-rule" }, { t: "text", v: ",描述的是路径布尔运算怎么算。简单说,要么按路径的绕向自动运算,要么靠标记规则;前者兼容性更好(字体、Android 矢量等),后者在 Web 与 iOS 上往往更可控。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "Figma 默认更接近 even-odd。用过 Figma 导出到 iconfont 的人多半知道 " }, { t: "link", v: "Fill Rule Editor", href: "https://www.figma.com/community/plugin/771155994770327940/Fill-Rule-Editor" }, { t: "text", v: "——它通过调整路径方向,让结果符合 non-zero 规则。作者曾是 Figma 的前 CTO,不知是否因此,社区里几乎找不到第二个做同类事的插件。" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/shore/icon10.png" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "为跨端考虑,Shore Icon 的填充规则我选了兼容性更好的 non-zero。" }] },
|
||||||
|
{ type: "h2", text: "#统一输出格式" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "格式统一同样是跨端前提。我用插件导出两种格式,给研发同事评估怎么消费。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "SVG Symbol 格式预览" }] },
|
||||||
|
{ type: "code", text: "1<svg style=\"display: none;\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">2 <!-- 3 icons / 2022/3/18上午1:31:10 / VectorS 1.0.0 -->3 <symbol id=\"Figma\" viewbox=\"0 0 24 24\">4 <g transform=\"translate(5.1 2.1)\">5 <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M 3.9 0 L 9.9 0 C 12.053 0 13.8 1.747 13.8 3.9 C 13.8 5.106 13.252 6.185 12.391 6.9 C 13.252 7.616 13.8 8.694 13.8 9.9 C 13.8 12.053 12.053 13.8 9.9 13.8 C 9.127 13.8 8.406 13.575 7.8 13.186 L 7.8 15.9 C 7.8 18.053 6.053 19.8 3.9 19.8 C 1.747 19.8 0 18.053 0 15.9 C 0 14.694 0.548 13.616 1.409 12.9 C 0.548 12.184 0 11.106 0 9.9 C 0 8.694 0.548 7.616 1.409 6.9 C 0.548 6.185 0 5.106 0 3.9 C 0 1.747 1.747 0 3.9 0 Z M 1.8 3.9 C 1.8 2.741 2.741 1.8 3.9 1.8 L 6 1.8 L 6 6 L 3.9 6 C 2.741 6 1.8 5.059 1.8 3.9 Z M 6 9.902 C 6 9.901 6 9.901 6 9.9 C 6 9.899 6 9.899 6 9.898 L 6 7.8 L 3.9 7.8 C 2.741 7.8 1.8 8.741 1.8 9.9 C 1.8 11.059 2.741 12 3.9 12 L 6 12 L 6 9.902 Z M 7.8 9.9 C 7.8 11.059 8.741 12 9.9 12 C 11.059 12 12 11.059 12 9.9 C 12 8.741 11.059 7.8 9.9 7.8 C 8.741 7.8 7.8 8.741 7.8 9.9 Z M 9.9 6 C 11.059 6 12 5.059 12 3.9 C 12 2.741 11.059 1.8 9.9 1.8 L 7.8 1.8 L 7.8 6 L 9.9 6 Z M 1.8 15.9 C 1.8 14.741 2.741 13.8 3.9 13.8 L 6 13.8 L 6 15.9 C 6 17.059 5.059 18 3.9 18 C 2.741 18 1.8 17.059 1.8 15.9 Z\" fill=\"rgb(0,0,0)\" />6 </g>7 </symbol>8 <symbol id=\"Twitter\" viewbox=\"0 0 24 24\">9 <g transform=\"translate(2.5 4)\">10 <path d=\"M 17.048 3.984 C 17.055 4.16 17.055 4.328 17.055 4.504 C 17.063 9.84 13.143 16 5.973 16 C 3.859 16 1.783 15.368 0 14.184 C 0.309 14.224 0.617 14.24 0.926 14.24 C 2.678 14.24 4.383 13.632 5.765 12.504 C 4.098 12.472 2.632 11.344 2.122 9.696 C 2.709 9.816 3.311 9.792 3.882 9.624 C 2.068 9.256 0.764 7.6 0.756 5.672 C 0.756 5.656 0.756 5.64 0.756 5.624 C 1.297 5.936 1.906 6.112 2.524 6.128 C 0.818 4.944 0.286 2.584 1.32 0.736 C 3.303 3.264 6.22 4.792 9.353 4.96 C 9.037 3.56 9.469 2.088 10.48 1.096 C 12.047 -0.432 14.516 -0.352 15.998 1.272 C 16.87 1.096 17.711 0.76 18.475 0.288 C 18.182 1.224 17.572 2.016 16.762 2.52 C 17.534 2.424 18.29 2.208 19 1.888 C 18.475 2.704 17.812 3.408 17.048 3.984 Z\" fill=\"rgb(0,0,0)\" />11 </g>12 </symbol>13 <symbol id=\"Instagram\" viewbox=\"0 0 24 24\">14 <g transform=\"translate(2 2)\">15 <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M 9.996 4.865 C 7.163 4.865 4.861 7.163 4.861 10 C 4.861 12.837 7.159 15.135 9.996 15.135 C 12.833 15.135 15.131 12.837 15.131 10 C 15.131 7.163 12.833 4.865 9.996 4.865 Z M 9.996 13.329 C 8.155 13.329 6.663 11.837 6.663 9.996 C 6.663 8.155 8.155 6.663 9.996 6.663 C 11.837 6.663 13.329 8.155 13.329 9.996 C 13.329 11.837 11.837 13.329 9.996 13.329 Z M 16.532 4.659 C 16.532 5.321 15.995 5.857 15.333 5.857 C 14.671 5.857 14.135 5.321 14.135 4.659 C 14.135 3.997 14.671 3.46 15.333 3.46 C 15.995 3.46 16.532 3.997 16.532 4.659 Z M 9.996 0 C 7.282 0 6.94 0.012 5.873 0.06 C 4.81 0.107 4.083 0.278 3.448 0.524 C 2.79 0.778 2.234 1.123 1.679 1.679 C 1.123 2.234 0.782 2.794 0.524 3.448 C 0.278 4.083 0.107 4.81 0.06 5.877 C 0.012 6.94 0 7.282 0 9.996 C 0 12.71 0.012 13.052 0.06 14.119 C 0.107 15.183 0.278 15.909 0.524 16.548 C 0.778 17.206 1.123 17.762 1.679 18.317 C 2.234 18.873 2.794 19.214 3.448 19.472 C 4.083 19.718 4.81 19.889 5.877 19.936 C 6.944 19.984 7.282 19.996 10 19.996 C 12.718 19.996 13.056 19.984 14.123 19.936 C 15.187 19.889 15.913 19.718 16.552 19.472 C 17.21 19.218 17.766 18.873 18.321 18.317 C 18.877 17.762 19.218 17.202 19.476 16.548 C 19.722 15.913 19.893 15.186 19.94 14.119 C 19.988 13.052 20 12.714 20 9.996 C 20 7.278 19.988 6.94 19.94 5.873 C 19.893 4.81 19.722 4.083 19.476 3.444 C 19.222 2.786 18.877 2.23 18.321 1.675 C 17.766 1.119 17.206 0.778 16.552 0.52 C 15.917 0.274 15.19 0.103 14.123 0.056 C 13.052 0.012 12.71 0 9.996 0 Z M 9.996 1.802 C 12.667 1.802 12.98 1.813 14.036 1.861 C 15.012 1.905 15.54 2.067 15.893 2.206 C 16.361 2.389 16.694 2.603 17.044 2.952 C 17.393 3.302 17.611 3.635 17.79 4.103 C 17.925 4.456 18.091 4.984 18.135 5.96 C 18.183 7.016 18.194 7.329 18.194 10 C 18.194 12.671 18.183 12.984 18.135 14.04 C 18.091 15.016 17.929 15.544 17.79 15.897 C 17.607 16.365 17.393 16.698 17.044 17.048 C 16.694 17.397 16.361 17.615 15.893 17.794 C 15.54 17.929 15.012 18.095 14.036 18.139 C 12.98 18.186 12.667 18.198 9.996 18.198 C 7.325 18.198 7.012 18.186 5.956 18.139 C 4.98 18.095 4.452 17.933 4.099 17.794 C 3.631 17.611 3.298 17.397 2.948 17.048 C 2.599 16.698 2.381 16.365 2.202 15.897 C 2.067 15.544 1.901 15.016 1.857 14.04 C 1.81 12.984 1.798 12.671 1.798 10 C 1.798 7.329 1.81 7.016 1.857 5.96 C 1.901 4.984 2.063 4.456 2.202 4.103 C 2.385 3.635 2.599 3.302 2.948 2.952 C 3.298 2.603 3.631 2.385 4.099 2.206 C 4.452 2.071 4.98 1.905 5.956 1.861 C 7.012 1.81 7.329 1.802 9.996 1.802 Z\" fill=\"rgb(0,0,0)\" />16 </g>17 </symbol>18</svg>" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "JSON 格式数据结构预览" }] },
|
||||||
|
{ type: "code", text: "1{2 \"name\": \"FigmaIcon\",3 \"description\": \"\",4 \"width\": 24,5 \"height\": 24,6 \"id\": [7 \"3627:1307\",8 \"046c56ddfafa72e2cbb4b521de681feed7b9db0b\"9 ],10 \"paths\": [11 {12 \"color\": {13 \"r\": 0,14 \"g\": 0,15 \"b\": 016 },17 \"evenodd\": false,18 \"opacity\": 1,19 \"path\": [20 \"M 3.9 0 L 9.9 0 C 12.053 0 13.8 1.747 13.8 3.9 C 13.8 5.106 13.252 6.185 12.391 6.9 C 13.252 7.616 13.8 8.694 13.8 9.9 C 13.8 12.053 12.053 13.8 9.9 13.8 C 9.127 13.8 8.406 13.575 7.8 13.186 L 7.8 15.9 C 7.8 18.053 6.053 19.8 3.9 19.8 C 1.747 19.8 0 18.053 0 15.9 C 0 14.694 0.548 13.616 1.409 12.9 C 0.548 12.184 0 11.106 0 9.9 C 0 8.694 0.548 7.616 1.409 6.9 C 0.548 6.185 0 5.106 0 3.9 C 0 1.747 1.747 0 3.9 0 Z M 1.8 3.9 C 1.8 2.741 2.741 1.8 3.9 1.8 L 6 1.8 L 6 6 L 3.9 6 C 2.741 6 1.8 5.059 1.8 3.9 Z M 6 9.902 C 6 9.901 6 9.901 6 9.9 C 6 9.899 6 9.899 6 9.898 L 6 7.8 L 3.9 7.8 C 2.741 7.8 1.8 8.741 1.8 9.9 C 1.8 11.059 2.741 12 3.9 12 L 6 12 L 6 9.902 Z M 7.8 9.9 C 7.8 11.059 8.741 12 9.9 12 C 11.059 12 12 11.059 12 9.9 C 12 8.741 11.059 7.8 9.9 7.8 C 8.741 7.8 7.8 8.741 7.8 9.9 Z M 9.9 6 C 11.059 6 12 5.059 12 3.9 C 12 2.741 11.059 1.8 9.9 1.8 L 7.8 1.8 L 7.8 6 L 9.9 6 Z M 1.8 15.9 C 1.8 14.741 2.741 13.8 3.9 13.8 L 6 13.8 L 6 15.9 C 6 17.059 5.059 18 3.9 18 C 2.741 18 1.8 17.059 1.8 15.9 Z\"21 ],22 \"x\": 5.1,23 \"y\": 2.124 }25 ]26}" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "调研下来,JSON 虽易读,若要再编译成各端格式,往往仍要各端各用各的技术栈。前端的方案是直接消费 SVG Symbol,打包进 React 组件、用 Props 调图标;构建阶段再用 Node 工具把 Symbol 拆成适合移动端的单文件 SVG。整条链路可以交给 GitHub Actions 一类流程自动化,统一格式与交付也就闭环了。" }] },
|
||||||
|
{ type: "h2", text: "#版本管理" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "最后一个问题乍看棘手,其实前面几步已经埋好答案:用 GitHub 管代码即可。只是 GitHub 面向工程思维,我能逐行读 SVG 的 Diff,不是所有设计师都习惯这一套。" }] },
|
||||||
|
{ type: "img", src: "https://mysite2026-blog-cyn6.vercel.app/blog/shore/icon11.png" },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "接下来想把 VectorS 接到 GitHub:身份验证通过后,插件读取仓库里约定的 SVG Symbol,在界面里渲染出来,再通过 API 拉 Diff 做图形化对比——有点像 Abstract 在做的事。" }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "我会尽量把这套流程带进以后的项目,也不排除把它做成自己的第一个小产品。回头看,以前对计算机图形只有模糊印象,这次折腾下来,总算又往清楚走近了一点。" }] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"/teambition": {
|
||||||
|
title: "Teambition",
|
||||||
|
date: "May 31, 2026",
|
||||||
|
year: "2018-2020",
|
||||||
|
meta: [
|
||||||
|
["Last Updated", "May 31, 2026"],
|
||||||
|
["Dimensions", "1×1"],
|
||||||
|
["Characters", "—"],
|
||||||
|
],
|
||||||
|
iframe: null,
|
||||||
|
blocks: [
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "Work in progress — this page is not finished yet." }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "From 2018 to 2020, I worked on product and design at Teambition (Alibaba), focused on collaboration and project management. More details coming soon." }] },
|
||||||
|
{ type: "p", segs: [{ t: "link", v: "teambition.com", href: "https://www.teambition.com/" }] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FullscreenTransitionProvider — 1:1 port of the original module 73475
|
||||||
|
* (chunk d59f7a97fb1c563f.js): a context holding the navigation intent
|
||||||
|
* (targetHref), the cover/reveal phase flags and the scramble-lines gate.
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
createContext,
|
||||||
|
useCallback,
|
||||||
|
useContext,
|
||||||
|
useMemo,
|
||||||
|
useState,
|
||||||
|
type ReactNode,
|
||||||
|
} from "react";
|
||||||
|
|
||||||
|
type TransitionState = {
|
||||||
|
menuOpen: boolean;
|
||||||
|
setMenuOpen: (open: boolean) => void;
|
||||||
|
targetHref: string | null;
|
||||||
|
navigationReplace: boolean;
|
||||||
|
startNavigation: (href: string, opts?: { replace?: boolean }) => void;
|
||||||
|
clearNavigation: () => void;
|
||||||
|
readyToLoadHeavy: boolean;
|
||||||
|
setReadyToLoadHeavy: (ready: boolean) => void;
|
||||||
|
heavyLoadProgress: number;
|
||||||
|
setHeavyLoadProgress: (progress: number) => void;
|
||||||
|
allowScrambleLines: boolean;
|
||||||
|
setAllowScrambleLines: (allow: boolean) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const FullscreenTransitionContext = createContext<TransitionState | null>(null);
|
||||||
|
|
||||||
|
export function useFullscreenTransitionController(): TransitionState {
|
||||||
|
const ctx = useContext(FullscreenTransitionContext);
|
||||||
|
if (!ctx)
|
||||||
|
throw new Error(
|
||||||
|
"useFullscreenTransitionController must be used within FullscreenTransitionProvider"
|
||||||
|
);
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRouteTransitionController(): {
|
||||||
|
targetHref: string | null;
|
||||||
|
navigationReplace: boolean;
|
||||||
|
startNavigation: (href: string, opts?: { replace?: boolean }) => void;
|
||||||
|
clearNavigation: () => void;
|
||||||
|
readyToLoadHeavy: boolean;
|
||||||
|
setReadyToLoadHeavy: (ready: boolean) => void;
|
||||||
|
heavyLoadProgress: number;
|
||||||
|
setHeavyLoadProgress: (progress: number) => void;
|
||||||
|
allowScrambleLines: boolean;
|
||||||
|
setAllowScrambleLines: (allow: boolean) => void;
|
||||||
|
} {
|
||||||
|
const ctx = useContext(FullscreenTransitionContext);
|
||||||
|
if (!ctx)
|
||||||
|
throw new Error(
|
||||||
|
"useRouteTransitionController must be used within FullscreenTransitionProvider"
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
targetHref: ctx.targetHref,
|
||||||
|
navigationReplace: ctx.navigationReplace,
|
||||||
|
startNavigation: ctx.startNavigation,
|
||||||
|
clearNavigation: ctx.clearNavigation,
|
||||||
|
readyToLoadHeavy: ctx.readyToLoadHeavy,
|
||||||
|
setReadyToLoadHeavy: ctx.setReadyToLoadHeavy,
|
||||||
|
heavyLoadProgress: ctx.heavyLoadProgress,
|
||||||
|
setHeavyLoadProgress: ctx.setHeavyLoadProgress,
|
||||||
|
allowScrambleLines: ctx.allowScrambleLines,
|
||||||
|
setAllowScrambleLines: ctx.setAllowScrambleLines,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function FullscreenTransitionProvider({
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
children: ReactNode;
|
||||||
|
}) {
|
||||||
|
const [menuOpen, setMenuOpen] = useState(false);
|
||||||
|
const [target, setTarget] = useState<{ href: string; replace: boolean } | null>(
|
||||||
|
null
|
||||||
|
);
|
||||||
|
const [readyToLoadHeavy, setReadyToLoadHeavy] = useState(false);
|
||||||
|
const [heavyLoadProgress, setHeavyLoadProgress] = useState(0);
|
||||||
|
const [allowScrambleLines, setAllowScrambleLines] = useState(false);
|
||||||
|
|
||||||
|
const startNavigation = useCallback(
|
||||||
|
(href: string, opts?: { replace?: boolean }) => {
|
||||||
|
setReadyToLoadHeavy(false);
|
||||||
|
setHeavyLoadProgress(0);
|
||||||
|
setTarget((prev) => prev ?? { href, replace: opts?.replace ?? false });
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
const clearNavigation = useCallback(() => {
|
||||||
|
setTarget(null);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const value = useMemo(
|
||||||
|
() => ({
|
||||||
|
menuOpen,
|
||||||
|
setMenuOpen,
|
||||||
|
targetHref: target?.href ?? null,
|
||||||
|
navigationReplace: target?.replace ?? false,
|
||||||
|
startNavigation,
|
||||||
|
clearNavigation,
|
||||||
|
readyToLoadHeavy,
|
||||||
|
setReadyToLoadHeavy,
|
||||||
|
heavyLoadProgress,
|
||||||
|
setHeavyLoadProgress,
|
||||||
|
allowScrambleLines,
|
||||||
|
setAllowScrambleLines,
|
||||||
|
}),
|
||||||
|
[
|
||||||
|
menuOpen,
|
||||||
|
target,
|
||||||
|
startNavigation,
|
||||||
|
clearNavigation,
|
||||||
|
readyToLoadHeavy,
|
||||||
|
heavyLoadProgress,
|
||||||
|
allowScrambleLines,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FullscreenTransitionContext.Provider value={value}>
|
||||||
|
{children}
|
||||||
|
</FullscreenTransitionContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
+35
-2
@@ -4,8 +4,11 @@
|
|||||||
* Scroll environment — module singleton mirroring the original
|
* Scroll environment — module singleton mirroring the original
|
||||||
* `scrollEnv` (module 29680): holds the Lenis instance so header
|
* `scrollEnv` (module 29680): holds the Lenis instance so header
|
||||||
* shortcuts (coords click → top, [T] top, [B] bottom, Work/Contact
|
* shortcuts (coords click → top, [T] top, [B] bottom, Work/Contact
|
||||||
* anchors) can scroll from anywhere. SmoothScroller registers the
|
* anchors) and the custom scrollbar can scroll from anywhere.
|
||||||
* instance on mount.
|
*
|
||||||
|
* Our clone scrolls the WINDOW (the original scrolls inside <main>);
|
||||||
|
* the container-el surface is kept for API parity — the container is
|
||||||
|
* document.documentElement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type LenisLike = {
|
type LenisLike = {
|
||||||
@@ -16,6 +19,13 @@ type LenisLike = {
|
|||||||
} | null;
|
} | null;
|
||||||
|
|
||||||
let lenis: LenisLike = null;
|
let lenis: LenisLike = null;
|
||||||
|
let containerEl: HTMLElement | null = null;
|
||||||
|
const containerListeners = new Set<(el: HTMLElement | null) => void>();
|
||||||
|
|
||||||
|
function getContainer(): HTMLElement | null {
|
||||||
|
if (containerEl) return containerEl;
|
||||||
|
return typeof document === "undefined" ? null : document.documentElement;
|
||||||
|
}
|
||||||
|
|
||||||
export const scrollEnv = {
|
export const scrollEnv = {
|
||||||
setLenis(instance: LenisLike) {
|
setLenis(instance: LenisLike) {
|
||||||
@@ -24,6 +34,29 @@ export const scrollEnv = {
|
|||||||
getLenis() {
|
getLenis() {
|
||||||
return lenis;
|
return lenis;
|
||||||
},
|
},
|
||||||
|
/** Original scrollEnv.setContainerEl (our scroller is the window). */
|
||||||
|
setContainerEl(el: HTMLElement | null) {
|
||||||
|
containerEl = el;
|
||||||
|
containerListeners.forEach((l) => l(el));
|
||||||
|
},
|
||||||
|
getContainerEl(): HTMLElement | null {
|
||||||
|
return getContainer();
|
||||||
|
},
|
||||||
|
subscribeContainerEl(listener: (el: HTMLElement | null) => void) {
|
||||||
|
containerListeners.add(listener);
|
||||||
|
return () => containerListeners.delete(listener);
|
||||||
|
},
|
||||||
|
/** Current scroll top in px (window scroller). */
|
||||||
|
getScrollTopPx(): number {
|
||||||
|
return window.scrollY || document.documentElement.scrollTop || 0;
|
||||||
|
},
|
||||||
|
/** Original lenisScrollTo: smoothed by Lenis unless immediate. */
|
||||||
|
lenisScrollTo(target: number | string | HTMLElement, opts?: { immediate?: boolean; lerp?: number }) {
|
||||||
|
const t = typeof target === "number" ? Math.max(0, target) : target;
|
||||||
|
if (lenis) lenis.scrollTo(t, { lerp: 0.1, immediate: !!opts?.immediate });
|
||||||
|
else if (typeof t === "number") window.scrollTo({ top: t, behavior: opts?.immediate ? "auto" : "smooth" });
|
||||||
|
else (t as HTMLElement).scrollIntoView({ behavior: opts?.immediate ? "auto" : "smooth" });
|
||||||
|
},
|
||||||
scrollToTop(behavior: "smooth" | "auto" = "smooth") {
|
scrollToTop(behavior: "smooth" | "auto" = "smooth") {
|
||||||
if (lenis) lenis.scrollTo(0, { lerp: 0.1, immediate: behavior === "auto" });
|
if (lenis) lenis.scrollTo(0, { lerp: 0.1, immediate: behavior === "auto" });
|
||||||
else window.scrollTo({ top: 0, behavior });
|
else window.scrollTo({ top: 0, behavior });
|
||||||
|
|||||||
+39
-1
@@ -11,6 +11,10 @@ import { useEffect, useRef } from "react";
|
|||||||
export function useBgm(enabled: boolean) {
|
export function useBgm(enabled: boolean) {
|
||||||
const audioRef = useRef<HTMLAudioElement | null>(null);
|
const audioRef = useRef<HTMLAudioElement | null>(null);
|
||||||
const readyRef = useRef(false);
|
const readyRef = useRef(false);
|
||||||
|
// Track the latest enabled state for the load-once effect (its closure
|
||||||
|
// captures the initial false otherwise).
|
||||||
|
const enabledRef = useRef(enabled);
|
||||||
|
enabledRef.current = enabled;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
@@ -31,7 +35,7 @@ export function useBgm(enabled: boolean) {
|
|||||||
audio.volume = 0.35;
|
audio.volume = 0.35;
|
||||||
audioRef.current = audio;
|
audioRef.current = audio;
|
||||||
readyRef.current = true;
|
readyRef.current = true;
|
||||||
if (enabled) void audio.play().catch(() => {});
|
if (enabledRef.current) void audio.play().catch(() => {});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (!cancelled) console.warn("Failed to load BGM:", err);
|
if (!cancelled) console.warn("Failed to load BGM:", err);
|
||||||
@@ -55,4 +59,38 @@ export function useBgm(enabled: boolean) {
|
|||||||
if (enabled) void audio.play().catch(() => {});
|
if (enabled) void audio.play().catch(() => {});
|
||||||
else audio.pause();
|
else audio.pause();
|
||||||
}, [enabled]);
|
}, [enabled]);
|
||||||
|
|
||||||
|
// Autoplay-policy recovery: when sound is persisted ON, the mount-time
|
||||||
|
// play() is rejected (NotAllowedError — no user gesture yet) and the
|
||||||
|
// header would show SOUND[|] forever while staying silent. Retry on the
|
||||||
|
// first user gesture (click / key / touch), like the original which
|
||||||
|
// resumes music as soon as the user interacts.
|
||||||
|
const retriedRef = useRef(false);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!enabled || retriedRef.current) return;
|
||||||
|
const tryPlay = () => {
|
||||||
|
const audio = audioRef.current;
|
||||||
|
if (!audio || !readyRef.current) return;
|
||||||
|
if (!audio.paused) {
|
||||||
|
retriedRef.current = true;
|
||||||
|
cleanup();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
audio
|
||||||
|
.play()
|
||||||
|
.then(() => {
|
||||||
|
retriedRef.current = true;
|
||||||
|
cleanup();
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
};
|
||||||
|
const events = ["pointerdown", "keydown", "touchstart"] as const;
|
||||||
|
const cleanup = () => {
|
||||||
|
for (const ev of events)
|
||||||
|
window.removeEventListener(ev, tryPlay, { capture: true });
|
||||||
|
};
|
||||||
|
for (const ev of events)
|
||||||
|
window.addEventListener(ev, tryPlay, { capture: true });
|
||||||
|
return cleanup;
|
||||||
|
}, [enabled]);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -4,9 +4,9 @@
|
|||||||
* via `WORK_ITEMS.filter(t => !t.passcodeProtected || lookup(t.href))` — the
|
* via `WORK_ITEMS.filter(t => !t.passcodeProtected || lookup(t.href))` — the
|
||||||
* locked one reveals the brand label "TikTok"; see WorkSection).
|
* locked one reveals the brand label "TikTok"; see WorkSection).
|
||||||
*
|
*
|
||||||
* Internal hrefs (/reunimos, /inspire_mono, …) are detail-page routes that
|
* Internal detail routes render app/work/[slug]/page.tsx (content extracted
|
||||||
* do not exist in this clone yet; WorkSection renders them as inert links
|
* 1:1 from the original pages); clicks go through the cover/reveal
|
||||||
* until the route system is ported.
|
* transition (startNavigation).
|
||||||
*/
|
*/
|
||||||
import { revealBrandLabel } from "@/lib/passcode";
|
import { revealBrandLabel } from "@/lib/passcode";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user