Files
personal/components/dom/Header.tsx
T
virtheart 744ec0becc feat: add glass models with advanced refractive shader and integrate into hero scene
- Introduced GlassModels component with custom vertex and fragment shaders for realistic glass effects.
- Updated HeroScene to include HelloModel and CursorStar components, utilizing the new glass shader.
- Enhanced Header component with ScrambleReveal for dynamic text display and local clock functionality.
- Implemented useIsMobile hook to adapt rendering based on screen size.
- Adjusted StickerLayer to ensure falling stickers are captured in the glass models' FBO pass.
2026-08-31 23:39:58 +08:00

92 lines
4.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { useEffect, useState } from "react";
import ScrambleReveal from "@/components/dom/ScrambleReveal";
/**
* Header, matching the original: scramble-revealed labels (startDelay 300),
* live local clock (HH:MM, minute tick), and a center coordinate readout
* driven by the pointer (normalized position × viewport size, zero-padded 4).
*/
export default function Header() {
const [time, setTime] = useState("--:--");
const [coords, setCoords] = useState({ x: "0001", y: "0001" });
useEffect(() => {
const tick = () => {
const d = new Date();
setTime(
`${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`
);
};
tick();
const interval = window.setInterval(tick, 60_000);
return () => window.clearInterval(interval);
}, []);
useEffect(() => {
const onMove = (e: PointerEvent) => {
const x = Math.round(e.clientX);
const y = Math.round(
(window.innerHeight || 0) - e.clientY
);
setCoords({
x: String(Math.max(0, x)).padStart(4, "0").slice(0, 4),
y: String(Math.max(0, y)).padStart(4, "0").slice(0, 4),
});
};
window.addEventListener("pointermove", onMove, { passive: true });
return () => window.removeEventListener("pointermove", onMove);
}, []);
const dotted =
"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";
return (
<header className="z-50 fixed inset-0 flex flex-col justify-between font-mono-2 pointer-events-none transition-colors duration-300 ease-out text-l1">
<div className="flex justify-between items-center px-4 lg:px-14 py-4 lg:py-7 text-base">
<a
className={`${dotted} p-2 font-sans font-bold uppercase pointer-events-auto transition-colors duration-300 ease-out`}
style={{ fontVariationSettings: '"wght" 700, "wdth" 120' }}
href="/"
>
<ScrambleReveal text="haoqi" startDelayMs={300} scrambleColors={false} />
<ScrambleReveal text=".design" startDelayMs={300} scrambleColors={false} />
</a>
<div className="hidden lg:flex flex-wrap justify-between items-center gap-x-3 gap-y-2 pointer-events-auto basis-1/2 xl:basis-1/3">
<button type="button" className={`${dotted} p-2 uppercase cursor-pointer`}>
<ScrambleReveal text="Work" startDelayMs={300} scrambleColors={false} />
</button>
<button type="button" className={`${dotted} p-2 uppercase cursor-pointer`}>
<ScrambleReveal text="Contact" startDelayMs={300} scrambleColors={false} />
</button>
<span role="button" tabIndex={0} className={`${dotted} p-2 uppercase cursor-pointer pointer-events-auto`}>
<ScrambleReveal text="THEME[A]" startDelayMs={300} scrambleColors={false} />
</span>
<span role="button" tabIndex={0} className={`${dotted} p-2 uppercase cursor-pointer pointer-events-auto normal-case`}>
<ScrambleReveal text="SOUND[|]" startDelayMs={300} scrambleColors={false} />
</span>
</div>
</div>
<div className="flex justify-between px-4 lg:px-14 py-4 lg:py-7">
<span className="lg:hidden p-2 uppercase">
<ScrambleReveal text={time} startDelayMs={300} letterDelayMs={40} scrambleColors={false} />
</span>
<span className="hidden lg:inline p-2 uppercase">
<ScrambleReveal text={`GMT+8 CN ${time}`} startDelayMs={300} letterDelayMs={40} scrambleColors={false} />
</span>
<span
className={`${dotted} hidden lg:inline lg:bottom-7 lg:left-1/2 lg:fixed p-2 lg:-translate-x-1/2 cursor-pointer pointer-events-auto`}
>
<ScrambleReveal
text={`${coords.x} X ${coords.y} Y`}
startDelayMs={300}
letterDelayMs={40}
scrambleColors={false}
/>
</span>
</div>
</header>
);
}