docs: add inline comments across components and hooks

This commit is contained in:
xiaozhou233 committed 2026-07-26 10:26:21 +08:00
1 parent e2c020a641
commit f7770bb8af
9 files changed
+22 -9

No files matched your search

+5
View File
@@ -8,6 +8,7 @@ import bannerImg from "@/assets/banner.png";
const FULL_TEXT = "Xiaozhou's Website"; const FULL_TEXT = "Xiaozhou's Website";
// Full-screen hero banner with parallax background, typewriter title, and nav cards
export default function Banner() { export default function Banner() {
const text = useTypewriter(FULL_TEXT, 100); const text = useTypewriter(FULL_TEXT, 100);
const parallaxRef = useParallax(0.25); const parallaxRef = useParallax(0.25);
@@ -21,11 +22,13 @@ export default function Banner() {
backgroundSize: "cover", backgroundSize: "cover",
}} }}
> >
{/* Dark overlay for text readability */}
<div className="absolute inset-0 bg-black/45 pointer-events-none" /> <div className="absolute inset-0 bg-black/45 pointer-events-none" />
<Header /> <Header />
<main className="relative z-10 flex-1 flex flex-col items-center justify-center px-4 -translate-y-4"> <main className="relative z-10 flex-1 flex flex-col items-center justify-center px-4 -translate-y-4">
{/* Animated typewriter heading */}
<h1 className="text-5xl md:text-7xl lg:text-8xl font-extrabold tracking-tighter text-transparent bg-clip-text bg-linear-to-r from-emerald-50 via-white to-emerald-50 drop-shadow-[0_0_15px_rgba(52,211,153,0.4)]"> <h1 className="text-5xl md:text-7xl lg:text-8xl font-extrabold tracking-tighter text-transparent bg-clip-text bg-linear-to-r from-emerald-50 via-white to-emerald-50 drop-shadow-[0_0_15px_rgba(52,211,153,0.4)]">
{text} {text}
<span className="animate-pulse text-emerald-400 ml-0.5">|</span> <span className="animate-pulse text-emerald-400 ml-0.5">|</span>
@@ -35,8 +38,10 @@ export default function Banner() {
{"< / Code. Deploy. Repeat. >"} {"< / Code. Deploy. Repeat. >"}
</p> </p>
{/* Decorative divider */}
<div className="w-12 h-0.5 bg-emerald-500 mt-5 shadow-[0_0_8px_#10b981]" /> <div className="w-12 h-0.5 bg-emerald-500 mt-5 shadow-[0_0_8px_#10b981]" />
{/* Navigation card grid */}
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-5 gap-6 mt-14 w-full max-w-6xl px-4"> <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-5 gap-6 mt-14 w-full max-w-6xl px-4">
{NAV_ITEMS.map((item) => ( {NAV_ITEMS.map((item) => (
<NavCard key={item.name} item={item} /> <NavCard key={item.name} item={item} />
+1
View File
@@ -4,6 +4,7 @@ interface NavCardProps {
item: NavItem; item: NavItem;
} }
// A clickable navigation card with icon, title, and description
export default function NavCard({ item }: NavCardProps) { export default function NavCard({ item }: NavCardProps) {
const { name, desc, path, Icon, color, borderHover } = item; const { name, desc, path, Icon, color, borderHover } = item;
+1
View File
@@ -1,5 +1,6 @@
import { ChevronDown } from "lucide-react"; import { ChevronDown } from "lucide-react";
// Bottom section with scroll indicator and tech stack credit
export default function Footer() { export default function Footer() {
return ( return (
<footer className="relative z-10 w-full pb-6 flex flex-col items-center justify-center gap-4 bg-linear-to-t from-black/40 to-transparent"> <footer className="relative z-10 w-full pb-6 flex flex-col items-center justify-center gap-4 bg-linear-to-t from-black/40 to-transparent">
+1
View File
@@ -1,6 +1,7 @@
import { LayoutDashboard, GitFork } from "lucide-react"; import { LayoutDashboard, GitFork } from "lucide-react";
import type { NavItem } from "@/types"; import type { NavItem } from "@/types";
// External links displayed as navigation cards on the banner
export const NAV_ITEMS: NavItem[] = [ export const NAV_ITEMS: NavItem[] = [
{ {
name: "Blog", name: "Blog",
+1
View File
@@ -1,5 +1,6 @@
import { useEffect, useRef } from "react"; import { useEffect, useRef } from "react";
// Moves the element's background vertically on scroll for a parallax effect
export function useParallax(speed = 0.25) { export function useParallax(speed = 0.25) {
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
+1
View File
@@ -1,5 +1,6 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
// Reveals `text` one character at a time at the given `speed` (ms per char)
export function useTypewriter(text: string, speed = 100) { export function useTypewriter(text: string, speed = 100) {
const [displayed, setDisplayed] = useState(""); const [displayed, setDisplayed] = useState("");
+1
View File
@@ -1,6 +1,7 @@
import { clsx, type ClassValue } from "clsx" import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge" import { twMerge } from "tailwind-merge"
// Merges Tailwind classes, resolving conflicts via tailwind-merge
export function cn(...inputs: ClassValue[]) { export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs)) return twMerge(clsx(inputs))
} }
+10 -9
View File
@@ -1,10 +1,11 @@
import React from "react"; import React from "react";
import ReactDOM from "react-dom/client"; import ReactDOM from "react-dom/client";
import App from "./App"; import App from "./App";
import './index.css' import './index.css'
ReactDOM.createRoot(document.getElementById("root")!).render( // Entry point — mounts the React app into the DOM
<React.StrictMode> ReactDOM.createRoot(document.getElementById("root")!).render(
<App /> <React.StrictMode>
</React.StrictMode> <App />
</React.StrictMode>
); );
+1
View File
@@ -1,5 +1,6 @@
import type { LucideIcon } from "lucide-react"; import type { LucideIcon } from "lucide-react";
// Shape of a navigation card item used on the banner
export interface NavItem { export interface NavItem {
name: string; name: string;
desc: string; desc: string;