diff --git a/.omp/RULES.md b/.omp/RULES.md new file mode 100644 index 0000000..3ee110e --- /dev/null +++ b/.omp/RULES.md @@ -0,0 +1,36 @@ +# Agent Rules + +## 1. General Principles + +- Understand the existing codebase before making changes. +- Prefer simple, maintainable solutions over clever solutions. +- Do not introduce unnecessary dependencies. +- Do not rewrite working code unless there is a clear reason. +- Preserve existing behavior unless the task explicitly requires a behavior change. +- Follow the existing project architecture and coding conventions. +- Keep changes small and focused on the requested task. + +## 2. Before Making Changes + +Before modifying code: + +1. Inspect the relevant project structure. +2. Identify the modules/classes/components affected. +3. Read the existing implementation and related tests. +4. Identify existing utilities that can be reused. +5. Check whether similar functionality already exists. +6. Understand the data flow before changing it. + +Do not start coding based only on the user's description. + +## 3. Change Workflow + +1. **Investigate** — research the issue using the steps in Section 2. +2. **Report** — present findings: root cause, affected files, proposed fix. +3. **Confirm** — wait for user approval before applying any code changes. +4. **Execute** — apply the approved change, verify, then report results. + +## 4. Conversation language + +**IMPORTANT:** All responses are in Vietnamese. Source code and docs are in English. +## 5. Don't run the headless browser to verify. It costs so times to complete. I will verify the result in real browser and tell you if the change works. \ No newline at end of file diff --git a/AGENTS.md b/AGENTS.md index 4c5fe75..7cb869c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,7 +11,7 @@ Personal engineering portfolio — multi-page SPA built with React + TypeScript | Framework | React 19 | | Language | TypeScript 6 (bundler mode, `verbatimModuleSyntax`, `noEmit`) | | Bundler | Vite 8 | -| Router | React Router DOM v6 (pin `6.30.6` — do NOT upgrade to v7) | +| Router | React Router v8 (`react-router` package, pinned `8.4.0`) | | Linter | Oxlint 1 (`plugins: react, typescript, oxc`) | | Package manager | pnpm | @@ -82,12 +82,26 @@ src/ ## Known Issues & Gotchas -1. **React Router v6 routing:** Use `...`, NOT `}>` with nested routes — the latter doesn't pass `children` correctly -2. **React Router v6 pin:** `package.json` has `"react-router-dom": "6.30.6"` (exact, no `^`) — v7 breaks the build and routing +1. **React Router v8 routing:** Use `...`, NOT `}>` with nested routes — the latter doesn't pass `children` correctly +2. **Import path:** All router imports use `react-router` (not `react-router-dom`) — e.g., `import { Link, useLocation } from 'react-router'` 3. **Theme cycle:** `cycleTheme` dependency array must be `[]` (empty), NOT `[setTheme]` — `setTheme` is not used inside `cycleTheme` 4. **Theme from system:** When stored theme is `'system'`, `cycleTheme` must skip to opposite theme on first click (not go to `'dark'` which resolves to same visual) 5. **Footer/Nav links:** Must use ``, not `` for client-side navigation +## Design Specs + +All specification documents are in `docs/design/`: + +| File | Purpose | +|------|---------| +| `spec.md` | Main PRD — product vision, positioning, narrative, IA, acceptance criteria | +| `spec-v1.md` | v1 completion record — features implemented, known limitations, files summary | +| `spec-v2.md` | v2 index — overview, implementation order, feature list | +| `specs/ui/spec-ui-*.md` | UI specs per section (hero, about, expertise, etc.) | +| `specs/v2/spec-v2-*.md` | v2 feature specs (resume, seo, blog, analytics, testing, cicd) | + +Read `spec.md` first for product context. Read `spec-v2.md` for current feature scope. + ## Code Style & Linting - TypeScript: `verbatimModuleSyntax`, `noUnusedLocals`, `noUnusedParameters`, `noFallthroughCasesInSwitch` diff --git a/docs/design/spec-v1.md b/docs/design/spec-v1.md new file mode 100644 index 0000000..353e13b --- /dev/null +++ b/docs/design/spec-v1.md @@ -0,0 +1,174 @@ +# Specification — v1 (Foundation + Core Portfolio) + +> **Document:** `spec_v1.md` +> **Version:** 1.0.0 +> **Status:** Completed +> **Branch:** `dev` (merged from `dev_v1`) +> **Tag:** `v0.0.1` +> **Commit:** `7e42bd8` (feat) + `59951a7` (docs) + +--- + +## Overview + +v1 implements **Phase 1 (Foundation)** and **Phase 2 (Core Portfolio)** from `spec.md`. All pages, components, theming, and responsive layout are complete. + +--- + +## Completed Features + +### 1. Foundation + +| Feature | Status | Details | +|---------|--------|---------| +| Vite 8 + React 19 + TypeScript 6 | Done | Bundler mode, strict linting | +| Oxlint 1 | Done | `react/rules-of-hooks` error, `react/only-export-components` warn | +| React Router v6 | Done | Pin `6.30.6`, 7 routes defined | +| CSS Variables + Theming | Done | `data-theme` attribute, dark/light/system | +| Responsive Design | Done | Mobile menu, fluid containers, touch-friendly | + +### 2. Routing & Pages + +| Route | Page | Component | Status | +|-------|------|-----------|--------| +| `/` | Home | `HomePage` | Done | +| `/about` | About | `AboutPage` | Done | +| `/experience` | Experience | `ExperiencePage` | Done | +| `/projects` | Projects List | `ProjectsListPage` | Done | +| `/projects/:id` | Project Detail | `ProjectDetailPage` | Done | +| `/engineering` | Engineering | `EngineeringPage` | Done (placeholder content) | +| `/contact` | Contact | `ContactPage` | Done | + +### 3. Layout Components + +| Component | File | Status | +|-----------|------|--------| +| `Layout` | `src/components/layout/Layout.tsx` | Done — wraps Navigation + main + Footer | +| `Navigation` | `src/components/layout/Navigation.tsx` | Done — desktop menu, mobile drawer, theme toggle | +| `Footer` | `src/components/layout/Footer.tsx` | Done — copyright, nav links, social links | + +### 4. Page Sections (HomePage) + +| Section | Component | Status | +|---------|-----------|--------| +| Hero | `src/components/sections/Hero.tsx` | Done — name, title, tagline, CTA, social links | +| About | `src/components/sections/About.tsx` | Done — bio, engineering philosophy, current interests | +| Expertise | `src/components/sections/Expertise.tsx` | Done — skill groups grid | +| Experience | `src/components/sections/Experience.tsx` | Done — timeline with responsibilities | +| Projects | `src/components/sections/Projects.tsx` | Done — featured projects grid | +| Contact | `src/components/sections/Contact.tsx` | Done — email, GitHub, LinkedIn links | + +### 5. UI Components + +| Component | File | Props/Features | Status | +|-----------|------|----------------|--------| +| `Button` | `src/components/ui/Button.tsx` | `variant`, `size`, `disabled` | Done | +| `Badge` | `src/components/ui/Badge.tsx` | `variant: accent | outline | muted` | Done | +| `Tag` | `src/components/ui/Tag.tsx` | `accent` | Done | +| `Card` | `src/components/ui/Card.tsx` | `as`, children | Done | +| `SectionHeading` | `src/components/ui/SectionHeading.tsx` | `title`, `subtitle` | Done | +| `SocialLinks` | `src/components/ui/SocialLinks.tsx` | `links`, `variant` | Done | + +### 6. Theming + +| Feature | Status | Details | +|---------|--------|---------| +| `ThemeProvider` | Done | Context provider, `data-theme` on `` | +| `useTheme()` hook | Done | Returns `{ theme, resolvedTheme, setTheme, cycleTheme }` | +| Theme cycle | Done | `dark` ↔ `light` ↔ `system` (system skips to opposite) | +| localStorage persistence | Done | Key: `portfolio-theme` | +| System preference detection | Done | `prefers-color-scheme: dark` | +| CSS variables for both themes | Done | `src/index.css` root + `[data-theme="dark"]` | + +### 7. Data Layer + +| Module | File | Content | Status | +|--------|------|---------|--------| +| Profile | `src/data/profile.ts` | Name, title, tagline, bio, links, interests, philosophy | Done | +| Skills | `src/data/skills.ts` | 6 skill groups × 5-6 skills each | Done | +| Experience | `src/data/experience.ts` | 1 entry with 3 featured achievements | Done | +| Projects | `src/data/projects.ts` | 4 projects with sections, metrics, tech stacks | Done | + +### 8. Types + +| Interface | File | Fields | Status | +|-----------|------|--------|--------| +| `Profile` | `src/types/index.ts` | name, title, tagline, bio, email, links, interests, philosophy | Done | +| `SkillGroup` | `src/types/index.ts` | title, skills[] | Done | +| `ExperienceEntry` | `src/types/index.ts` | id, title, company, duration, location, responsibilities, achievements | Done | +| `FeaturedAchievement` | `src/types/index.ts` | id, title, context, technicalWork, impact, metrics, technologies, featured | Done | +| `Project` | `src/types/index.ts` | id, title, summary, category, role, technologies, metrics, featured, urls | Done | +| `ProjectDetail` | `src/types/index.ts` | extends Project + sections[] | Done | +| `ProjectSection` | `src/types/index.ts` | id, number, title, content, type | Done | +| `PhilosophyPoint` | `src/types/index.ts` | title, description, keywords[] | Done | +| `ProjectCategory` | `src/types/index.ts` | 6 union types | Done | + +--- + +## Architecture + +``` +App.tsx + └── ThemeProvider + └── BrowserRouter + └── Layout + ├── Navigation (top bar + mobile drawer) + ├── + │ ├── HomePage (Hero + About + Expertise + Experience + Projects + Contact) + │ ├── AboutPage + │ ├── ExperiencePage + │ ├── ProjectsListPage + │ ├── ProjectDetailPage + │ ├── EngineeringPage + │ └── ContactPage + └── Footer +``` + +**Data flow:** All content comes from `src/data/*.ts` modules. Components are presentational — no hardcoded text except labels/CTAs. + +**CSS:** Global variables in `src/index.css`, component styles in `src/App.css`. No CSS library. + +--- + +## Known Limitations + +| # | Limitation | Impact | v2 Plan | +|---|------------|--------|---------| +| 1 | No Blog system | Cannot publish articles | Phase 4: MDX-based blog | +| 2 | No SEO metadata | No ``, `<meta>`, OG tags per page | Phase 5: react-helmet-async | +| 3 | No Analytics | No page view tracking | Phase 5: Plausible | +| 4 | No Testing | No unit/E2E tests | Phase 5: Vitest + Playwright | +| 5 | No CI/CD | Manual builds only | Phase 5: GitHub Actions | +| 6 | No Resume download | No PDF resume | v2: Add link/button | +| 7 | Engineering page placeholder | "Coming soon" text | v2: Populate with real content | +| 8 | Projects use `<a href>` not `<Link>` | Client-side nav broken on projects page | v2: Fix to `<Link>` | +| 9 | No i18n | Vietnamese-only | Future: English support | +| 10 | No CMS | Content in TS files | Future: headless CMS or MDX | + +--- + +## Files Summary + +| Category | Count | Path | +|----------|-------|------| +| Pages | 7 | `src/pages/*.tsx` | +| Layout components | 3 | `src/components/layout/*.tsx` | +| Section components | 6 | `src/components/sections/*.tsx` | +| UI components | 6 | `src/components/ui/*.tsx` | +| Data modules | 4 | `src/data/*.ts` | +| Hooks | 1 | `src/hooks/useTheme.tsx` | +| Types | 1 | `src/types/index.ts` | +| CSS | 2 | `src/index.css`, `src/App.css` | +| **Total source files** | **30** | | + +--- + +## Approval + +- [x] All Phase 1 + Phase 2 requirements implemented +- [x] TypeScript compiles without errors +- [x] Oxlint passes +- [x] Build succeeds +- [x] Responsive on mobile/desktop +- [x] Tagged `v0.0.1` on branch `dev` +- [x] AGENTS.md updated with project context diff --git a/docs/design/spec-v2.md b/docs/design/spec-v2.md new file mode 100644 index 0000000..d0465e4 --- /dev/null +++ b/docs/design/spec-v2.md @@ -0,0 +1,51 @@ +# Specification — v2 Features + +> **Document:** `spec-v2.md` +> **Version:** 0.1.0 +> **Status:** Draft — awaiting review +> **Branch:** `dev_v2` +> **Parent branch:** `dev` (v0.0.1) + +--- + + +## Prerequisites (Completed) + +| File | Feature | Status | +|------|---------|--------| +| `specs/v2/spec-v2-router.md` | React Router v6 → v7 | ✅ Done | +| `specs/v2/spec-v2-router-v8.md` | React Router v7 → v8 | ✅ Done | +## Overview + +v2 bao gồm 6 tính năng, mỗi tính năng có spec riêng trong `specs/`: + +| File | Feature | Priority | Est. | Status | +|------|---------|----------|------|--------| +| `specs/v2/spec-v2-resume.md` | Resume download | P1 | ~15 min | ✅ Done | +| `specs/v2/spec-v2-hero-carousel.md` | Hero visual carousel | P1 | ~1 hour | | +| `specs/v2/spec-v2-seo.md` | SEO (metadata, OG, sitemap) | P1 | ~1 hour | | +| `specs/v2/spec-v2-blog.md` | Blog (MDX, articles, syntax highlight) | P1 | ~4 hours | | +| `specs/v2/spec-v2-analytics.md` | Analytics (Plausible) | P2 | ~30 min | | +| `specs/v2/spec-v2-testing.md` | Testing (Vitest + E2E) | P5 | ~3 hours | | +| `specs/v2/spec-v2-cicd.md` | CI/CD (GitHub Actions) | P5 | ~1 hour | | + +**Implementation order:** ~~Resume~~ → Hero Carousel → SEO → Blog → Analytics → Testing → CI/CD + +--- + +## Out of Scope (v2) + +- CMS integration (Phase 5+) +- Multi-language / i18n (Phase 5+) +- Interactive diagrams / simulations (Phase 5+) +- Search functionality (Phase 5+) +- Contact form with backend (Phase 5+) +- Resume PDF generation (user uploads manually) + +--- + +## Approval + +- [ ] All requirements reviewed and confirmed +- [ ] Implementation order agreed +- [ ] Ready to start coding diff --git a/spec.md b/docs/design/spec.md similarity index 100% rename from spec.md rename to docs/design/spec.md diff --git a/docs/design/specs/fix/spec-nav-router-links.md b/docs/design/specs/fix/spec-nav-router-links.md new file mode 100644 index 0000000..019e29a --- /dev/null +++ b/docs/design/specs/fix/spec-nav-router-links.md @@ -0,0 +1,272 @@ +# Fix: Navigation & Router Links Causing Full Page Reloads + +## Problem + +Internal navigation links cause full page reloads instead of client-side routing. Root causes: + +1. **RollingTextLink** (`src/components/ui/RollingTextLink.tsx`) — renders `<a href={to}>` for all nav items +2. **Button** (`src/components/ui/Button.tsx`) — renders `<motion.a href={href}>` for all href values, including internal routes +3. **Projects** (`src/components/sections/Projects.tsx`) — uses `<motion.a href="/projects">` and `<motion.a href="/projects/:id">` + +## Changes + +### 1. `src/components/ui/RollingTextLink.tsx` + +Replace `<a>` with React Router `<Link>`. + +```diff +import { Link } from "react-router" + +- return ( +- <a +- href={to} +- className={className} +- onClick={onClick} +- onPointerEnter={() => { hovered.current = true; requestActive(true) }} +- onPointerLeave={() => { hovered.current = false; requestActive(focused.current) }} +- onFocus={() => { focused.current = true; requestActive(true) }} +- onBlur={() => { focused.current = false; requestActive(hovered.current) }} +- > ++ return ( ++ <Link ++ to={to} ++ className={className} ++ onClick={onClick} ++ onPointerEnter={() => { hovered.current = true; requestActive(true) }} ++ onPointerLeave={() => { hovered.current = false; requestActive(focused.current) }} ++ onFocus={() => { focused.current = true; requestActive(true) }} ++ onBlur={() => { focused.current = false; requestActive(hovered.current) }} ++ > + <span style={{ position: "relative", display: "inline-block", overflow: "hidden" }}> + <motion.span + style={{ display: "block", whiteSpace: "nowrap" }} + variants={outgoingVariants} + initial="rest" + animate={active ? "active" : "rest"} + onAnimationComplete={completeAnimation} + transition={transition} + > + {children} + </motion.span> + <motion.span + style={{ + display: "block", + whiteSpace: "nowrap", + position: "absolute", + inset: 0, + }} + variants={incomingVariants} + initial="rest" + animate={active ? "active" : "rest"} + transition={transition} + > + {children} + </motion.span> + </span> +- </a> ++ </Link> + ) +``` + +**Rationale:** `<Link>` renders an `<a>` element under the hood but intercepts click events for client-side navigation. Animation event handlers (`onPointerEnter`, `onFocus`, etc.) work identically since the DOM element is the same. + +--- + +### 2. `src/components/ui/Button.tsx` + +Detect internal routes (`href` starts with `/`) → use `motion(Link)`. External URLs keep `motion.a`. + +```diff +import { Link } from "react-router" + + type ButtonVariant = "primary" | "secondary" | "ghost" + type ButtonSize = "sm" | "md" | "lg" + + interface ButtonProps extends ComponentPropsWithoutRef<"button"> { + variant?: ButtonVariant + size?: ButtonSize + href?: string + download?: boolean + children: React.ReactNode + } + + // ... variantClasses, sizeClasses unchanged ... + + export const Button = forwardRef< + HTMLButtonElement | HTMLAnchorElement, + ButtonProps + >( + ( + { + variant = "primary", + size = "md", + href, + className = "", + children, ++ download, + ...props + }, + ref + ) => { + const classes = `${variantClasses[variant]} ${sizeClasses[size]} ${className}`.trim() + + if (href) { ++ const isRoute = href.startsWith("/") ++ const safeProps = { ...props } ++ if (isRoute) { ++ delete (safeProps as Record<string, unknown>)["download"] ++ } ++ ++ if (isRoute) { ++ return ( ++ <motion(Link ++ to={href} ++ className={classes} ++ ref={ref as React.Ref<HTMLAnchorElement>} ++ whileTap={{ scale: 0.95 }} ++ {...(safeProps as Omit< ++ React.AnchorHTMLAttributes<HTMLAnchorElement>, ++ keyof ButtonProps | "to" ++ >)} ++ > ++ {children} ++ </motion(Link)> ++ ) ++ } ++ + return ( + <motion.a + href={href} + className={classes} + ref={ref as React.Ref<HTMLAnchorElement>} + whileTap={{ scale: 0.95 }} + {...(props as Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof ButtonProps>)} + > + {children} + </motion.a> + ) + } + + return ( + <motion.button + className={classes} + ref={ref as React.Ref<HTMLButtonElement>} + whileTap={{ scale: 0.95 }} + {...(props as Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof ButtonProps>)} + > + {children} + </motion.button> + ) + } + ) +``` + +**Rationale:** +- Internal routes (`/projects`, `/contact`) → `motion(Link)` for client-side nav +- External URLs (GitHub, LinkedIn) → `motion.a` unchanged +- `download` prop stripped for internal routes (invalid on `<Link>`, no-op on same-origin `<a>`) + +--- + +### 3. `src/components/sections/Projects.tsx` + +Replace `<motion.a>` with `motion(Link)` for project cards and "View All" link. + +```diff +import { Link } from "react-router" + import { motion } from "motion/react" + import { Badge } from "@/components/ui/Badge" + import { projects } from "@/data/projects" + import { InView } from "@/components/ui/InView" + + // ... categoryLabels, Projects function start unchanged ... + + <motion.div + initial="hidden" + whileInView="visible" + viewport={{ once: true, amount: 0.5 }} + variants={{ + hidden: { opacity: 0 }, + visible: { opacity: 1, transition: { staggerChildren: 0.05 } }, + }} + > + <h2 id="projects-heading">Featured Projects</h2> +- <motion.a +- href="/projects" +- style={{ fontSize: "14px", fontWeight: 500, color: "var(--accent)" }} +- whileHover={{ scale: 1.05 }} +- whileTap={{ scale: 0.95 }} +- > ++ <motion(Link ++ to="/projects" ++ style={{ fontSize: "14px", fontWeight: 500, color: "var(--accent)" }} ++ whileHover={{ scale: 1.05 }} ++ whileTap={{ scale: 0.95 }} ++ > + View All → +- </motion.a> ++ </motion(Link)> + </motion.div> + <div className="projects-grid"> + {featured.map((project, i) => ( +- <motion.a +- key={project.id} +- href={`/projects/${project.id}`} ++ <motion(Link ++ key={project.id} ++ to={`/projects/${project.id}`} + className="project-card" + variants={{ + hidden: { opacity: 0, y: 30 }, + visible: { + opacity: 1, + y: 0, + transition: { duration: 0.5, delay: i * 0.1 }, + }, + }} + whileHover={{ scale: 1.02, y: -4 }} + whileTap={{ scale: 0.98 }} + > + {/* card content unchanged */} +- </motion.a> ++ </motion(Link)> + ))} + </div> +``` + +**Rationale:** `motion(Link)` passes `whileHover`/`whileTap` to the underlying `<a>` element. Animation behavior is identical. + +--- + +### 4. `src/components/sections/Hero.tsx` + +Replace `download` with `target="_blank"` for resume PDF link. + +```diff +-<Button href="/resume.pdf" variant="secondary" download> ++<Button href="/resume.pdf" variant="secondary" target="_blank"> + Download Resume + </Button> +``` + +**Rationale:** +- `download` attribute has no effect on same-origin URLs (browsers ignore it) +- Button already strips `download` for internal routes (now `/resume.pdf` is treated as a route) +- `target="_blank"` opens PDF in new tab, which is the expected behavior + +--- + +## Verification + +| Element | Expected Behavior | +|---|---| +| Nav menu items (Home, About, etc.) | Client-side nav, no page reload | +| Logo "Portfolio" | Client-side nav to `/`, no reload | +| Mobile menu items | Client-side nav + menu auto-closes | +| "View Projects" button | Client-side nav to `/projects` | +| "Contact Me" button | Client-side nav to `/contact` | +| "Download Resume" button | Opens `/resume.pdf` in new tab | +| "View All →" link | Client-side nav to `/projects` | +| Project cards | Client-side nav to `/projects/:id` | +| Social links (GitHub, LinkedIn) | Open in new tab (unchanged) | +| Skip-to-content link | Jumps to `#main-content` on same page | diff --git a/spec-ui-about.md b/docs/design/specs/ui/spec-ui-about.md similarity index 100% rename from spec-ui-about.md rename to docs/design/specs/ui/spec-ui-about.md diff --git a/spec-ui-blog.md b/docs/design/specs/ui/spec-ui-blog.md similarity index 100% rename from spec-ui-blog.md rename to docs/design/specs/ui/spec-ui-blog.md diff --git a/spec-ui-components.md b/docs/design/specs/ui/spec-ui-components.md similarity index 100% rename from spec-ui-components.md rename to docs/design/specs/ui/spec-ui-components.md diff --git a/spec-ui-contact.md b/docs/design/specs/ui/spec-ui-contact.md similarity index 100% rename from spec-ui-contact.md rename to docs/design/specs/ui/spec-ui-contact.md diff --git a/spec-ui-engineering.md b/docs/design/specs/ui/spec-ui-engineering.md similarity index 100% rename from spec-ui-engineering.md rename to docs/design/specs/ui/spec-ui-engineering.md diff --git a/spec-ui-experience.md b/docs/design/specs/ui/spec-ui-experience.md similarity index 100% rename from spec-ui-experience.md rename to docs/design/specs/ui/spec-ui-experience.md diff --git a/spec-ui-expertise.md b/docs/design/specs/ui/spec-ui-expertise.md similarity index 100% rename from spec-ui-expertise.md rename to docs/design/specs/ui/spec-ui-expertise.md diff --git a/spec-ui-footer.md b/docs/design/specs/ui/spec-ui-footer.md similarity index 100% rename from spec-ui-footer.md rename to docs/design/specs/ui/spec-ui-footer.md diff --git a/docs/design/specs/ui/spec-ui-hero-photo.md b/docs/design/specs/ui/spec-ui-hero-photo.md new file mode 100644 index 0000000..792d1f9 --- /dev/null +++ b/docs/design/specs/ui/spec-ui-hero-photo.md @@ -0,0 +1,130 @@ +# UI Spec - Hero Photo Background + Open to Work Badge + +## Overview + +Thay thế hero-visual (SVG diagram) bằng profile photo background, fill toàn bộ vùng bên phải hero section. Badge "Open to Work" overlay ở góc dưới ảnh. + +--- + +## Structure + +``` +Hero (section) +├── hero-photo-bg (div, ảnh nền) +│ └── profile-photo.webp (img, object-fit: cover) +├── hero-content (div, text bên trái) +│ ├── hero-name (h1) +│ ├── hero-title (p) +│ ├── hero-tagline (p) +│ ├── hero-cta (div, buttons) +│ └── SocialLinks +└── OpenToWorkBadge (component, góc dưới-right) + ├── icon (checkmark) + ├── "Open to Work" (text chính) + └── "Software Engineer" (subtitle) +``` + +--- + +## Hero Photo Background + +### Desktop + +- Position: absolute, fill `hero-visual` area +- `object-fit: cover` — fill hết khung, cắt phần thừa +- `object-position: center top` — giữ khuôn mặt ở trên +- Border-radius: 0 (khung vuông/tròn?) +- Z-index: 0 (nằm dưới text) + +### Mobile + +- Position: absolute, fill TOÀN BỘ hero section +- `object-fit: cover` +- Overlay gradient để text readable + +--- + +## Text Overlay + +### Desktop + +- Text nằm bên trái, không đè lên ảnh +- Giữ layout 2 cột hiện tại +- Không cần overlay + +### Mobile + +- Overlay gradient từ trái qua (transparent → dark) +- Hoặc overlay bán trong suốt toàn bộ hero +- Đảm bảo text contrast ratio ≥ 4.5:1 + +--- + +## Open to Work Badge + +### Design + +- Shape: bo góc 12px +- Background: accent color (hoặc gradient accent) +- Size: 200x200 (max-width: 200px) +- Padding: 20px +- Shadow: subtle drop shadow + +### Content + +``` +┌──────────────────┐ +│ ✓ Open to Work │ +│ Software │ +│ Engineer │ +└──────────────────┘ +``` + +- Icon: checkmark (SVG inline) +- Title: "Open to Work" — bold, 18px +- Subtitle: "Software Engineer" — regular, 14px, muted +- Icon + Title: cùng dòng +- Subtitle: dòng dưới + +### Position + +- Desktop: góc dưới-right của `hero-visual` +- Mobile: góc dưới-right của hero section +- Margin: 20px từ cạnh + +--- + +## Responsive + +### Desktop (>768px) + +``` +┌──────────────────────────────────────┐ +│ Text Content │ Photo BG │ +│ (left 50%) │ (right 50%) │ +│ │ │ +│ │ [OTW] │ +└──────────────────────────────────────┘ +``` + +### Mobile (≤768px) + +``` +┌──────────────────────────────┐ +│ Photo BG (full) │ +│ ┌────────────────────────┐ │ +│ │ Text Content + Overlay │ │ +│ └────────────────────────┘ │ +│ [OTW] │ +└──────────────────────────────┘ +``` + +--- + +## Constraints + +- Không hard-code nội dung trong JSX — data-driven từ `profile.ts` +- Ảnh fallback: placeholder gray nếu thiếu asset +- Giảm motion: không animation khi scroll +- Accessibility: alt text cho ảnh, aria-label cho badge +- Không thay đổi layout text content bên trái diff --git a/spec-ui-hero.md b/docs/design/specs/ui/spec-ui-hero.md similarity index 100% rename from spec-ui-hero.md rename to docs/design/specs/ui/spec-ui-hero.md diff --git a/spec-ui-layout.md b/docs/design/specs/ui/spec-ui-layout.md similarity index 100% rename from spec-ui-layout.md rename to docs/design/specs/ui/spec-ui-layout.md diff --git a/docs/design/specs/ui/spec-ui-motion.md b/docs/design/specs/ui/spec-ui-motion.md new file mode 100644 index 0000000..e911009 --- /dev/null +++ b/docs/design/specs/ui/spec-ui-motion.md @@ -0,0 +1,456 @@ +# UI Spec - Motion Animations (Homepage) + +## Overview + +Thêm animations cho toàn bộ homepage sử dụng **motion** library (`motion/react`). Tất cả animations dùng motion API, không CSS keyframes. + +--- + +## Dependency + +```bash +pnpm add motion +``` + +```tsx +import { motion } from "motion/react" +``` + +--- + +## Animation Categories + +### 1. Enter Animations (Page Load) + +| Component | Prop | Values | Transition | +|---|---|---|---| +| Hero container | `initial` → `animate` | `opacity: 0, x: -30` → `opacity: 1, x: 0` | `duration: 0.6, delay: 0.2` | +| Hero name | `initial` → `animate` | `opacity: 0, y: 20` → `opacity: 1, y: 0` | `duration: 0.5, delay: 0.3` | +| Hero title | `initial` → `animate` | `opacity: 0, y: 20` → `opacity: 1, y: 0` | `duration: 0.5, delay: 0.4` | +| Hero tagline | `initial` → `animate` | `opacity: 0, y: 20` → `opacity: 1, y: 0` | `duration: 0.5, delay: 0.5` | +| Hero CTA buttons | `initial` → `animate` | `opacity: 0, y: 20` → `opacity: 1, y: 0` | `duration: 0.5, delay: 0.6` | +| Hero visual (photo) | `initial` → `animate` | `opacity: 0, x: 30` → `opacity: 1, x: 0` | `duration: 0.6, delay: 0.4` | +| OpenToWorkBadge | `initial` → `animate` | `opacity: 0, y: -20` → `opacity: 1, y: 0` | `duration: 0.5, delay: 0.3` | + +### 2. Gesture Animations (Hover/Tap) + +| Component | Prop | Values | +|---|---|---| +| CTA buttons | `whileHover` | `scale: 1.05` | +| CTA buttons | `whileTap` | `scale: 0.95` | +| Project cards | `whileHover` | `scale: 1.02, y: -4` | +| Project cards | `whileTap` | `scale: 0.98` | +| Social links | `whileHover` | `scale: 1.1` | +| Social links | `whileTap` | `scale: 0.9` | +| Skill items | `whileHover` | `scale: 1.05, y: -2` | +| Skill items | `whileTap` | `scale: 0.98` | + +### 3. Scroll Animations (whileInView) + +| Component | Prop | Values | +|---|---|---| +| Section titles | `initial` → `whileInView` | `opacity: 0, y: 30` → `opacity: 1, y: 0` | +| Expertise cards | `initial` → `whileInView` | `opacity: 0, y: 30` → `opacity: 1, y: 0` | +| Experience entries | `initial` → `whileInView` | `opacity: 0, y: 30` → `opacity: 1, y: 0` | +| Project cards | `initial` → `whileInView` | `opacity: 0, y: 30` → `opacity: 1, y: 0` | +| Contact section | `initial` → `whileInView` | `opacity: 0, y: 30` → `opacity: 1, y: 0` | + +**Viewport config:** +```tsx +viewport={{ once: true, amount: 0.1 }} +transition={{ duration: 0.5 }} +``` + +--- + +## Reusable Components + +### `src/components/ui/InView.tsx` + +Wrapper component cho scroll animations. + +```tsx +import { motion, type MotionProps } from "motion/react" +import { ReactNode } from "react" + +interface InViewProps extends Omit<MotionProps, "children"> { + children: ReactNode + delay?: number + threshold?: number + className?: string +} + +export function InView({ + children, + delay = 0, + threshold = 0.1, + className, + ...props +}: InViewProps) { + return ( + <motion.div + className={className} + initial={{ opacity: 0, y: 30 }} + whileInView={{ opacity: 1, y: 0 }} + viewport={{ once: true, amount: threshold }} + transition={{ duration: 0.5, delay }} + {...props} + > + {children} + </motion.div> + ) +} +``` + +**Usage:** +```tsx +<InView delay={0.1}> + <h2>Section Title</h2> +</InView> +``` + +### `src/components/ui/GestureButton.tsx` + +Wrapper cho hover/tap animations. + +```tsx +import { motion, type MotionProps } from "motion/react" +import { ComponentPropsWithRef, ElementType } from "react" + +interface GestureButtonProps extends MotionProps { + as?: ElementType + className?: string + children: React.ReactNode +} + +export function GestureButton({ as: Tag = "button", className, ...props }: GestureButtonProps) { + const MotionTag = motion(Tag as any) + return ( + <MotionTag + className={className} + whileHover={{ scale: 1.05 }} + whileTap={{ scale: 0.95 }} + {...props} + /> + ) +} +``` + +--- + +## Component Updates + +### `src/components/sections/Hero.tsx` + +Wrap các phần tử với motion: + +```tsx +import { motion } from "motion/react" + +export function Hero() { + return ( + <motion.section + className="hero container-wide" + initial={{ opacity: 0 }} + animate={{ opacity: 1 }} + transition={{ duration: 0.3 }} + aria-labelledby="hero-heading" + > + <motion.div + className="hero-content" + initial={{ opacity: 0, x: -30 }} + animate={{ opacity: 1, x: 0 }} + transition={{ duration: 0.6, delay: 0.2 }} + > + <motion.h1 + id="hero-heading" + className="hero-name" + initial={{ opacity: 0, y: 20 }} + animate={{ opacity: 1, y: 0 }} + transition={{ duration: 0.5, delay: 0.3 }} + > + {profile.name} + </motion.h1> + <motion.p + className="hero-title" + initial={{ opacity: 0, y: 20 }} + animate={{ opacity: 1, y: 0 }} + transition={{ duration: 0.5, delay: 0.4 }} + > + {profile.title} + </motion.p> + <motion.p + className="hero-tagline" + initial={{ opacity: 0, y: 20 }} + animate={{ opacity: 1, y: 0 }} + transition={{ duration: 0.5, delay: 0.5 }} + > + {profile.tagline} + </motion.p> + <motion.div + className="hero-cta" + initial={{ opacity: 0, y: 20 }} + animate={{ opacity: 1, y: 0 }} + transition={{ duration: 0.5, delay: 0.6 }} + > + <Button href="/projects" variant="primary"> + View Projects + </Button> + {resumeAvailable && ( + <Button href="/resume.pdf" variant="secondary" download> + Download Resume + </Button> + )} + <Button href="/contact" variant="secondary"> + Contact Me + </Button> + </motion.div> + <SocialLinks links={socialLinks} /> + </motion.div> + <motion.div + className="hero-visual" + initial={{ opacity: 0, x: 30 }} + animate={{ opacity: 1, x: 0 }} + transition={{ duration: 0.6, delay: 0.4 }} + > + <img src="/profile-photo.webp" alt="Profile photo" className="hero-photo" /> + <OpenToWorkBadge /> + </motion.div> + </motion.section> + ) +} +``` + +### `src/components/ui/Button.tsx` + +Thêm hover/tap animation: + +```tsx +import { motion } from "motion/react" + +// Thay thế <button> bằng: +<motion.button + className={`btn btn-${variant}`} + whileHover={{ scale: 1.05 }} + whileTap={{ scale: 0.95 }} + whileFocus={{ scale: 1.05 }} + {...buttonProps} +> + {children} +</motion.button> +``` + +### `src/components/sections/ExpertiseSection.tsx` + +Wrap section và stagger children: + +```tsx +import { motion } from "motion/react" + +export function ExpertiseSection() { + return ( + <InView> + <motion.section + className="expertise-section container-wide" + initial="hidden" + whileInView="visible" + viewport={{ once: true, amount: 0.1 }} + variants={{ + hidden: { opacity: 0 }, + visible: { + opacity: 1, + transition: { staggerChildren: 0.1 } + } + }} + > + <motion.h2 className="section-title" variants={{ + hidden: { opacity: 0, y: 30 }, + visible: { opacity: 1, y: 0, transition: { duration: 0.5 } } + }}> + Core Expertise + </motion.h2> + <div className="expertise-grid"> + {expertiseGroups.map((group, i) => ( + <motion.div + key={group.title} + className="expertise-card" + variants={{ + hidden: { opacity: 0, y: 30 }, + visible: { opacity: 1, y: 0, transition: { duration: 0.5, delay: i * 0.1 } } + }} + whileHover={{ scale: 1.05, y: -2 }} + whileTap={{ scale: 0.98 }} + > + <h3>{group.title}</h3> + <ul> + {group.skills.map(skill => ( + <li key={skill}>{skill}</li> + ))} + </ul> + </motion.div> + ))} + </div> + </motion.section> + </InView> + ) +} +``` + +### `src/components/sections/ExperienceSection.tsx` + +```tsx +<InView> + <motion.section + initial="hidden" + whileInView="visible" + viewport={{ once: true, amount: 0.1 }} + variants={{ + hidden: { opacity: 0 }, + visible: { opacity: 1, transition: { staggerChildren: 0.15 } } + }} + > + <motion.h2 variants={titleVariants}>Experience</motion.h2> + {experience.map((exp, i) => ( + <motion.div + key={exp.company} + variants={{ + hidden: { opacity: 0, y: 30 }, + visible: { opacity: 1, y: 0, transition: { duration: 0.5, delay: i * 0.15 } } + }} + whileHover={{ scale: 1.02, y: -4 }} + whileTap={{ scale: 0.98 }} + > + {/* Experience content */} + </motion.div> + ))} + </motion.section> +</InView> +``` + +### `src/components/sections/ProjectsSection.tsx` + +```tsx +<InView> + <motion.section + initial="hidden" + whileInView="visible" + viewport={{ once: true, amount: 0.1 }} + variants={{ + hidden: { opacity: 0 }, + visible: { opacity: 1, transition: { staggerChildren: 0.1 } } + }} + > + <motion.h2 variants={titleVariants}>Featured Projects</motion.h2> + <div className="projects-grid"> + {projects.map((project, i) => ( + <motion.div + key={project.title} + className="project-card" + variants={{ + hidden: { opacity: 0, y: 30 }, + visible: { opacity: 1, y: 0, transition: { duration: 0.5, delay: i * 0.1 } } + }} + whileHover={{ scale: 1.02, y: -4 }} + whileTap={{ scale: 0.98 }} + > + {/* Project content */} + </motion.div> + ))} + </div> + </motion.section> +</InView> +``` + +### `src/components/sections/ContactSection.tsx` + +```tsx +<InView> + <motion.section + initial="hidden" + whileInView="visible" + viewport={{ once: true, amount: 0.1 }} + variants={{ + hidden: { opacity: 0 }, + visible: { opacity: 1, transition: { duration: 0.5 } } + }} + > + <motion.h2 variants={titleVariants}>Get In Touch</motion.h2> + {/* Contact content */} + </motion.section> +</InView> +``` + +--- + +## Reduced Motion + +Motion library auto-handles `prefers-reduced-motion` khi config: + +```tsx +// Trong main.tsx hoặc app root +import { motion, domMax } from "motion/react" + +// Option 1: Global config +motion.config.reducedMotion = "user" + +// Option 2: Per-component +<motion.div + animate={{ x: 100 }} + transition={{ type: "spring" }} + reducedMotionConfig={{ type: "tween", duration: 0.3 }} +/> +``` + +**Effect:** +- Enter animations: skip, hiển thị ngay +- Scroll animations: hiển thị ngay khi in view +- Gesture animations: vẫn hoạt động (hover/tap state) +- Infinite animations (swaying): dừng lại + +--- + +## CSS Changes + +### Removed: +- CSS `@keyframes` cho animations (nếu có) +- CSS `animation` properties +- CSS `prefers-reduced-motion` media queries (motion auto-handled) + +### Added: +- Chỉ layout/styling CSS (position, color, font, spacing) +- Không có animation CSS + +--- + +## Files Summary + +| File | Action | Changes | +|---|---|---| +| `package.json` | Modify | Add `motion` dependency | +| `src/components/sections/Hero.tsx` | Modify | motion enter animations | +| `src/components/ui/Button.tsx` | Modify | motion hover/tap | +| `src/components/ui/InView.tsx` | **New** | Reusable scroll wrapper | +| `src/components/sections/Expertise.tsx` | Modify | motion scroll + hover | +| `src/components/sections/Experience.tsx` | Modify | motion scroll + hover | +| `src/components/sections/Projects.tsx` | Modify | motion scroll + hover | +| `src/components/sections/Contact.tsx` | Modify | motion scroll | +| `src/main.tsx` | Modify | Set `motion.config.reducedMotion` | +| `src/App.css` | Modify | Remove animation CSS, keep layout | + +--- + +## Animation Timing Summary + +| Element | Delay | Duration | Type | +|---|---|---|---| +| Hero container | 0s | 0.3s | fade | +| Hero content | 0.2s | 0.6s | slide-left | +| Hero name | 0.3s | 0.5s | slide-up | +| Hero title | 0.4s | 0.5s | slide-up | +| Hero tagline | 0.5s | 0.5s | slide-up | +| Hero CTA | 0.6s | 0.5s | slide-up | +| Hero visual | 0.4s | 0.6s | slide-right | +| OTW badge | 0.3s | 0.5s | slide-down + fade | +| Section titles | scroll | 0.5s | slide-up | +| Cards/entries | scroll | 0.5s | slide-up + stagger | +| Buttons/cards | hover | 0.2s | scale | diff --git a/spec-ui-navigation.md b/docs/design/specs/ui/spec-ui-navigation.md similarity index 100% rename from spec-ui-navigation.md rename to docs/design/specs/ui/spec-ui-navigation.md diff --git a/spec-ui-project-detail.md b/docs/design/specs/ui/spec-ui-project-detail.md similarity index 100% rename from spec-ui-project-detail.md rename to docs/design/specs/ui/spec-ui-project-detail.md diff --git a/spec-ui-projects-list.md b/docs/design/specs/ui/spec-ui-projects-list.md similarity index 100% rename from spec-ui-projects-list.md rename to docs/design/specs/ui/spec-ui-projects-list.md diff --git a/spec-ui-projects.md b/docs/design/specs/ui/spec-ui-projects.md similarity index 100% rename from spec-ui-projects.md rename to docs/design/specs/ui/spec-ui-projects.md diff --git a/docs/design/specs/v2/spec-v2-analytics.md b/docs/design/specs/v2/spec-v2-analytics.md new file mode 100644 index 0000000..d6a1b47 --- /dev/null +++ b/docs/design/specs/v2/spec-v2-analytics.md @@ -0,0 +1,65 @@ +# Specification — v2 Analytics + +> **Document:** `spec-v2-analytics.md` +> **Version:** 0.1.0 +> **Parent:** `spec-v2.md` +> **Priority:** P2 +> **Estimate:** ~30 minutes + +--- + +## Requirement + +Privacy-friendly analytics — không dùng Google Analytics. + +--- + +## Options + +**Option A: Plausible Analytics** (recommended) +- Lightweight, privacy-first +- No cookie banner needed +- Simple script integration + +**Option B: Umami** +- Self-hosted option +- Open source +- Similar to Plausible + +**Option C: Custom minimal tracking** +- Track page views only +- Store in localStorage +- Batch send to endpoint (optional) + +--- + +## Implementation (Plausible) + +```tsx +// main.tsx — add script tag +<script + defer + data-domain="yourdomain.com" + src="https://plausible.io/js/script.outbound-links.js" +/> +``` + +Hoặc dùng `react-use-plausible`: + +```tsx +import { usePlausible } from 'react-use-plausible' + +const plausible = usePlausible() +// Auto pageview tracking +``` + +Configurable via env var: `ENABLE_ANALYTICS` + +--- + +## Acceptance + +- [ ] Page view tracking hoạt động +- [ ] Không cookie banner +- [ ] Không ảnh hưởng performance +- [ ] Configurable via env var (ENABLE_ANALYTICS) diff --git a/docs/design/specs/v2/spec-v2-blog.md b/docs/design/specs/v2/spec-v2-blog.md new file mode 100644 index 0000000..4951976 --- /dev/null +++ b/docs/design/specs/v2/spec-v2-blog.md @@ -0,0 +1,105 @@ +# Specification — v2 Blog System + +> **Document:** `spec-v2-blog.md` +> **Version:** 0.1.0 +> **Parent:** `spec-v2.md` +> **Priority:** P1 +> **Estimate:** ~4 hours + +--- + +## Requirement + +Blog cho phép viết technical articles bằng Markdown/MDX, render trên client. + +--- + +## Architecture + +``` +src/ + content/ + blog/ + post-1.mdx + post-2.mdx + components/ + blog/ + BlogListPage.tsx + BlogPostPage.tsx + ArticleCard.tsx + CodeBlock.tsx +``` + +--- + +## Features + +### Frontmatter + +Mỗi article có frontmatter: + +```yaml +--- +title: "Building High-Performance Event Simulation with Go" +date: "2024-06-15" +tags: ["engineering", "golang", "simulation"] +summary: "Discrete event simulation for logistics facilities" +--- +``` + +### Blog List Page (`/blog`) + +- Hiển thị danh sách articles +- Sort theo date (newest first) +- Filter theo tags (pill buttons) +- Mỗi article card: title, date, tags, summary + +### Article Page (`/blog/:slug`) + +- Render MDX content +- Code blocks với syntax highlighting +- TOC (table of contents) sidebar (desktop) +- Reading time estimate +- Breadcrumb navigation + +### Code Highlighting + +- Dùng `rehype-prism-plus` hoặc `rehype-raw` + `prismjs` +- Không dùng library nặng như `react-syntax-highlighter` +- Theme: dark/light compatible với CSS variables + +### MDX Processing + +- Dùng `@mdx-js/react` + `@mdx-js/rollup` (Vite plugin) +- Build-time compilation (không runtime) +- Frontmatter extracted tại build time + +### Vite Config Changes + +```ts +import mdx from '@mdx-js/rollup' + +export default defineConfig({ + plugins: [ + react(), + mdx({ + providerImportSource: '@mdx-js/react', + }), + ], +}) +``` + +--- + +## Acceptance + +- [ ] `/blog` hiển thị danh sách articles +- [ ] Article card có title, date, tags, summary +- [ ] Click article → navigate đến `/blog/:slug` +- [ ] MDX content render đúng +- [ ] Code blocks có syntax highlighting +- [ ] Tags filter hoạt động +- [ ] TOC sidebar (desktop only) +- [ ] Reading time hiển thị +- [ ] Responsive +- [ ] Không crash khi missing article diff --git a/docs/design/specs/v2/spec-v2-cicd.md b/docs/design/specs/v2/spec-v2-cicd.md new file mode 100644 index 0000000..33eba73 --- /dev/null +++ b/docs/design/specs/v2/spec-v2-cicd.md @@ -0,0 +1,61 @@ +# Specification — v2 CI/CD Pipeline + +> **Document:** `spec-v2-cicd.md` +> **Version:** 0.1.0 +> **Parent:** `spec-v2.md` +> **Priority:** P5 +> **Estimate:** ~1 hour + +--- + +## Requirement + +GitHub Actions pipeline cho automated build, lint, test. Vercel cho deployment. + +--- + +## GitHub Actions + +```yaml +# .github/workflows/ci.yml +name: CI + +on: + push: + branches: [dev, main] + pull_request: + branches: [dev] + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm lint + - run: pnpm build + - run: pnpm test +``` + +## Vercel Integration + +- Connect GitHub repo +- Auto deploy on `dev` → preview +- Auto deploy on `main` → production +- Environment variables: `SITE_URL`, `PLAUSIBLE_DOMAIN` (optional) + +--- + +## Acceptance + +- [ ] CI pass trên push vào dev +- [ ] Lint pass +- [ ] Build pass +- [ ] Tests pass +- [ ] Preview deploy trên Vercel +- [ ] Production deploy khi merge vào main diff --git a/docs/design/specs/v2/spec-v2-homepage-enhancements.md b/docs/design/specs/v2/spec-v2-homepage-enhancements.md new file mode 100644 index 0000000..361f7de --- /dev/null +++ b/docs/design/specs/v2/spec-v2-homepage-enhancements.md @@ -0,0 +1,311 @@ +# Homepage Enhancements — Section Improvements + +## Overview + +Enhance all homepage sections with three improvements: +1. Proper mobile padding (text not too close to edges) +2. Smooth scroll transitions between sections +3. Unified container width for consistent alignment + +--- + +## 1. Mobile Padding Fix + +### Problem + +On small screens (≤768px), text content is too close to the left/right edges due to fixed `padding: 0 24px`. + +### Current + +```css +/* src/index.css */ +.container-wide, +.container-content, +.container-narrow { + padding: 0 24px; /* fixed, all screen sizes */ +} + +.section { + padding: 80px 0; +} + +@media (max-width: 768px) { + .section { + padding: 48px 0; /* vertical only */ + } +} +``` + +### Proposed + +**src/index.css** — Add two media queries for container padding: + +```css +/* Mobile: ≤768px */ +@media (max-width: 768px) { + .section { + padding: 48px 0; + } + .container-wide, + .container-content, + .container-narrow { + padding-left: 32px; + padding-right: 32px; + } +} + +/* Medium: 769px–1200px */ +@media (min-width: 769px) and (max-width: 1200px) { + .container-wide, + .container-content, + .container-narrow { + padding-left: 40px; + padding-right: 40px; + } +} +``` + +**src/App.css** — Add hero-content padding for medium screens: + +```css +/* Medium: 769px–1200px */ +@media (min-width: 769px) and (max-width: 1200px) { + .hero-content { + padding-left: 16px; + padding-right: 16px; + } +} +``` + +### Breakpoints + +| Screen size | Container padding | Hero-content padding | +|---|---|---| +| ≤768px (mobile) | 32px | 24px (already set) | +| 769px–1200px (tablet/laptop) | 40px | 16px (new) | +| >1200px (desktop) | 24px | 0 | + +### Files + +- `src/index.css` +- `src/App.css` +--- + +## 2. Smooth Scroll Transitions + +### Problem + +- `Hero` and `About` have no scroll animations +- No scroll-driven parallax effects +- Section transitions feel abrupt + +### Current State + +| Section | Animation | +|---|---| +| Hero | Fade-in (opacity only, no scroll trigger) | +| About | No animation | +| Expertise | `whileInView` fade-in + slide-up | +| Experience | `whileInView` fade-in + slide-up | +| Projects | `whileInView` fade-in + slide-up | +| Contact | `whileInView` fade-in + slide-up | + +### Proposed Changes + +#### 2.1 Add `InView` Wrapper for Hero + About + +**Hero.tsx:** Wrap section with `InView` to trigger scroll animation: + +```tsx +import { InView } from "@/components/ui/InView" + +export function Hero() { + return ( + <InView> + <motion.section + className="hero container-wide" + // ... existing motion props + > + {/* content */} + </motion.section> + </InView> + ) +} +``` + +**About.tsx:** Wrap section with `InView`: + +```tsx +import { InView } from "@/components/ui/InView" + +export function About() { + return ( + <InView> + <section className="section container-content" aria-labelledby="about-heading"> + {/* content */} + </section> + </InView> + ) +} +``` + +#### 2.2 Hero Parallax Effect + +Add scroll-driven parallax: hero photo moves on scroll, hero content fades out. + +```tsx +import { motion, useScroll, useTransform } from "motion/react" + +export function Hero() { + const { scrollY } = useScroll() + const y = useTransform(scrollY, [0, 300], [0, -80]) + const opacity = useTransform(scrollY, [0, 200], [1, 0.3]) + + return ( + <motion.section className="hero container-wide"> + <motion.div className="hero-content" style={{ opacity }}> + {/* content */} + </motion.div> + <motion.div className="hero-visual" style={{ y }}> + <img src="/profile-photo.webp" alt="Profile photo" className="hero-photo" /> + </motion.div> + </motion.section> + ) +} +``` + +**Effect:** Hero photo moves up 80px as user scrolls 300px (parallax). Hero content fades to 30% opacity over first 200px scroll. + +#### 2.3 Section Background Gradient + +Add subtle gradient transition between sections for smooth visual flow: + +```css +/* src/App.css */ +.section { + position: relative; +} + +.section::before { + content: ''; + position: absolute; + inset: 0; + background: linear-gradient( + to bottom, + transparent 0%, + var(--bg-primary) 10%, + var(--bg-primary) 90%, + transparent 100% + ); + pointer-events: none; + z-index: -1; +} +``` + +**Effect:** Creates a smooth fade from section content to background at top/bottom edges (10% gradient zone). + +### Files + +- `src/components/sections/Hero.tsx` +- `src/components/sections/About.tsx` +- `src/App.css` + +--- + +## 3. Container Width Alignment + +### Problem + +Sections alternate between two container widths (1200px ↔ 800px) → titles zigzag, hard to follow vertically. + +### Solution + +Unify all sections to use `container-wide` (1200px) for consistent title alignment. Text-heavy content gets inner `maxWidth: '700px'` wrapper for readability. + +### Changes + +**About.tsx:** +```tsx +// Before +<section className="section container-content"> +// After +<section className="section container-wide"> +``` + +**Experience.tsx:** +```tsx +// Before +<motion.section className="section container-content"> +// After +<motion.section className="section container-wide"> + {/* Added wrapper */} + <div style={{ maxWidth: '700px' }}> + <div className="timeline">...</div> + </div> +</motion.section> +``` + +**Contact.tsx:** +```tsx +// Before +<motion.section className="section container-content"> +// After +<motion.section className="section container-wide"> + {/* Added wrapper */} + <div style={{ maxWidth: '700px' }}> + <div className="contact-links">...</div> + </div> +</motion.section> +``` + +### Result + +| Section | Container | Content Width | +|---|---|---| +| Hero | `container-wide` | N/A (grid layout) | +| About | `container-wide` | 700px (inner div) | +| Expertise | `container-wide` | N/A (grid layout) | +| Experience | `container-wide` | 700px (inner div) | +| Projects | `container-wide` | N/A (grid layout) | +| Contact | `container-wide` | 700px (inner div) | + +All titles now align at the same left position. Grid sections use full width. Text sections constrained to 700px for readability. + +### Files + +- `src/components/sections/About.tsx` +- `src/components/sections/Experience.tsx` +- `src/components/sections/Contact.tsx` + +--- + +## Implementation Order + +| Step | Task | Files | Est. Time | +|---|---|---|---| +| 1 | Mobile padding fix | `src/index.css` | 5m | +| 2 | Add InView to Hero + About | `Hero.tsx`, `About.tsx` | 10m | +| 3 | Hero parallax effect | `Hero.tsx` | 15m | +| 4 | Section background gradient | `src/App.css` | 10m | +| 5 | Build + verify | — | 5m | + +**Total:** ~45m + +--- + +## Dependencies + +- `motion` (already installed) +- No new dependencies + +--- + +## Acceptance Criteria + +1. [ ] On mobile (≤768px), text has 32px padding on both sides (not 24px) +2. [ ] Hero has scroll animation (fadeInUp on viewport entry) +3. [ ] About has scroll animation (fadeInUp on viewport entry) +4. [ ] Hero photo has parallax effect on scroll +5. [ ] All sections have scroll reveal animation (fade-in + slide-up) +6. [ ] Build passes (`tsc -b && vite build`) +7. [ ] No breaking changes to desktop layout diff --git a/docs/design/specs/v2/spec-v2-nav-rolling-text.md b/docs/design/specs/v2/spec-v2-nav-rolling-text.md new file mode 100644 index 0000000..3a883e2 --- /dev/null +++ b/docs/design/specs/v2/spec-v2-nav-rolling-text.md @@ -0,0 +1,251 @@ +# Specification - Rolling Text Navigation Links + +> **Document:** `spec-v2-nav-rolling-text.md` +> **Version:** 0.1.0 +> **Parent:** `spec-ui-navigation.md` +> **Priority:** P2 +> **Estimate:** ~45 minutes + +--- + +## Requirement + +Apply the rolling text button animation pattern (from `docs/sample-code/rolling-text-button.md`) to navigation menu links in `Navigation.tsx`. On hover/focus, the link text slides out downward while an identical copy slides in from below. + +--- + +## Animation Design + +### Pattern + +Based on the sample code's dual-span approach: + +| Element | Variant | Initial | Hover/Focus | +|---|---|---|---| +| Outgoing `<motion.span>` | `rest` → `active` | `translateY(0%)` | `translateY(100%)` | +| Incoming `<motion.span>` | `rest` → `active` | `translateY(-100%)` | `translateY(0%)` | + +### Timing + +| Property | Value | +|---|---| +| Duration | `0.3s` | +| Easing | `[0.338, 0.015, 0.395, 0.959]` (custom cubic-bezier, snappy ease-out) | +| Trigger | `onHoverStart`/`onHoverEnd` + `onFocus`/`onBlur` | + +### Accessibility + +- `useReducedMotion` from `motion/react` disables animation when user prefers reduced motion +- When reduced motion is active, text swaps instantly with no animation +- `aria-hidden="true"` on the animated label spans (text is still read by screen reader via parent `<a>`) + +--- + +## Component Architecture + +### `RollingTextLink` — new component + +Extracted as a reusable component in `src/components/ui/RollingTextLink.tsx`: + +```tsx +import { motion, useReducedMotion } from "motion/react" +import { useRef, useState } from "react" + +interface RollingTextLinkProps { + to: string + children: React.ReactNode + className?: string + isActive?: boolean +} + +const outgoingVariants = { + rest: { transform: "translateY(0%)" }, + active: { transform: "translateY(100%)" }, +} + +const incomingVariants = { + rest: { transform: "translateY(-100%)" }, + active: { transform: "translateY(0%)" }, +} + +const transition = { + duration: 0.3, + ease: [0.338, 0.015, 0.395, 0.959] as const, +} + +export function RollingTextLink({ to, children, className, isActive }: RollingTextLinkProps) { + const reduceMotion = useReducedMotion() + const [active, setActive] = useState(false) + const activeRef = useRef(false) + const animating = useRef(false) + const pendingRequest = useRef<boolean | null>(null) + const hovered = useRef(false) + const focused = useRef(false) + + const updateActive = (next: boolean) => { + activeRef.current = next + setActive(next) + } + + const requestActive = (next: boolean) => { + if (reduceMotion) return + + if (next === activeRef.current) { + pendingRequest.current = null + return + } + + if (animating.current) { + pendingRequest.current = next + return + } + + animating.current = true + updateActive(next) + } + + const completeAnimation = () => { + if (!animating.current) return + animating.current = false + + if (pendingRequest.current !== null && pendingRequest.current !== activeRef.current) { + const next = pendingRequest.current + pendingRequest.current = null + animating.current = true + updateActive(next) + } else { + pendingRequest.current = null + } + } + + return ( + <a + href={to} + className={className} + aria-label={typeof children === 'string' ? children : undefined} + onHoverStart={() => { + hovered.current = true + requestActive(true) + }} + onHoverEnd={() => { + hovered.current = false + requestActive(focused.current) + }} + onFocus={() => { + focused.current = true + requestActive(true) + }} + onBlur={() => { + focused.current = false + requestActive(hovered.current) + }} + > + <span style={{ position: "relative", display: "inline-block", overflow: "hidden" }}> + <motion.span + style={{ display: "block", whiteSpace: "nowrap" }} + variants={outgoingVariants} + initial="rest" + animate={active ? "active" : "rest"} + onAnimationComplete={completeAnimation} + transition={transition} + > + {children} + </motion.span> + <motion.span + style={{ + display: "block", + whiteSpace: "nowrap", + position: "absolute", + inset: 0, + }} + variants={incomingVariants} + initial="rest" + animate={active ? "active" : "rest"} + transition={transition} + > + {children} + </motion.span> + </span> + </a> + ) +} +``` + +--- + +## Integration Points + +### Desktop nav links (`<NavLink>` → `<RollingTextLink>`) + +Replace in `src/components/layout/Navigation.tsx`: + +```tsx +// Before +<NavLink to={item.path} className={({ isActive }) => isActive ? 'nav-link active' : 'nav-link'}> + {item.label} +</NavLink> + +// After +<RollingTextLink + to={item.path} + className={({ isActive }) => isActive ? 'nav-link active' : 'nav-link'} +> + {item.label} +</RollingTextLink> +``` + +### Mobile nav links + +Same replacement in the mobile menu section: + +```tsx +// Before +<NavLink + to={item.path} + className={({ isActive }) => isActive ? 'mobile-menu-link active' : 'mobile-menu-link'} + onClick={() => setMobileOpen(false)} +> + {item.label} +</NavLink> + +// After +<RollingTextLink + to={item.path} + className={({ isActive }) => isActive ? 'mobile-menu-link active' : 'mobile-menu-link'} + onClick={() => setMobileOpen(false)} +> + {item.label} +</RollingTextLink> +``` + +### CSS — no changes required + +The rolling text uses inline styles for the animation container. Existing `.nav-link` and `.mobile-menu-link` classes remain unchanged — color, hover color, active state, and underline all apply to the parent `<a>` as before. + +--- + +## Edge Cases + +| Scenario | Behavior | +|---|---| +| Rapid hover enter/leave | `pendingRequest` queue ensures animation completes current frame before starting next | +| `prefers-reduced-motion` | Animation disabled; text swaps instantly | +| Active link (current page) | Text still rolls on hover; `active` class preserved | +| Mobile menu open | Touch triggers `onHoverStart`/`onHoverEnd` equivalents via `onFocus`/`onBlur` | +| Screen reader | Parent `<a>` still contains text node; motion spans have `aria-hidden` | + +--- + +## Acceptance + +- [ ] `RollingTextLink` component created in `src/components/ui/RollingTextLink.tsx` +- [ ] Desktop nav links use `RollingTextLink` wrapping label text +- [ ] Mobile nav links use `RollingTextLink` wrapping label text +- [ ] Text slides out downward on hover, new text slides in from below +- [ ] Transition: 0.3s, cubic-bezier `[0.338, 0.015, 0.395, 0.959]` +- [ ] `useReducedMotion` respected — no animation when preferred +- [ ] Rapid hover transitions handled without jank (queue system) +- [ ] Active link state preserved (color + underline) +- [ ] Hover color transition still works (parent `<a>` handles `color`) +- [ ] Builds clean (`pnpm build`) with no type errors +- [ ] Existing `.nav-link` / `.mobile-menu-link` CSS classes unchanged diff --git a/docs/design/specs/v2/spec-v2-resume.md b/docs/design/specs/v2/spec-v2-resume.md new file mode 100644 index 0000000..194bf6c --- /dev/null +++ b/docs/design/specs/v2/spec-v2-resume.md @@ -0,0 +1,121 @@ +# Specification — v2 Resume Download + +> **Document:** `spec-v2-resume.md` +> **Version:** 0.4.0 +> **Parent:** `spec-v2.md` +> **Priority:** P1 +> **Estimate:** ~15 minutes + +--- + +## Requirement + +- Nút **"Download Resume"** hiển thị ở **2 vị trí**: + 1. **Hero section** — CTA row (bên cạnh "View Projects" / "Contact Me") + 2. **Contact section / Contact page** — riêng biệt, sau `contact-links` grid +- Link trực tiếp đến file PDF (`/resume.pdf`) với attribute `download` +- Khi chưa có PDF → ẩn hoàn toàn ở cả 2 vị trí +- PDF upload vào `public/resume.pdf` +- (Optional) Nav link `/resume` để xem resume dạng HTML (Phase 2+) + +--- + +## Implementation + +### DownloadResume Component + +```tsx +// src/components/sections/DownloadResume.tsx +import { resumeAvailable } from '@/data/resume' + +export function DownloadResume() { + if (!resumeAvailable) return null + return ( + <div style={{ marginTop: '32px' }}> + <a href="/resume.pdf" download className="contact-link" style={...}> + <svg>...</svg> + <div>Download Resume</div> + <div style={{ fontSize: '14px', color: 'var(--text-muted)' }}>PDF</div> + </a> + </div> + ) +} +``` + +### Hero Section (primary CTA) + +```tsx +// Hero.tsx +import { Button } from '@/components/ui/Button' +import { resumeAvailable } from '@/data/resume' + +export function Hero() { + return ( + <div className="hero-cta"> + <Button href="/projects" variant="primary">View Projects</Button> + {resumeAvailable && ( + <Button href="/resume.pdf" variant="secondary" download>Download Resume</Button> + )} + <Button href="/contact" variant="secondary">Contact Me</Button> + </div> + ) +} +``` + +### Contact Section (home page) + +```tsx +// Contact.tsx +import { DownloadResume } from '@/components/sections/DownloadResume' + +export function Contact() { + return ( + <section> + <SectionHeading title="Contact" /> + <div className="contact-links"> + {/* Email, GitHub, LinkedIn */} + </div> + <DownloadResume /> + </section> + ) +} +``` + +### ContactPage (standalone page) + +```tsx +// ContactPage.tsx +import { DownloadResume } from '@/components/sections/DownloadResume' + +export function ContactPage() { + return ( + <section> + <h2>Contact</h2> + <div className="contact-links">...</div> + <DownloadResume /> + </section> + ) +} +``` + +### Data Detection + +```ts +// src/data/resume.ts +export const resumeAvailable = true // set false khi chưa có PDF +``` + +### Nav (optional — Phase 2) + +Nút Resume trong nav chỉ hiện khi có `/resume` route (HTML resume page). + +--- + +## Acceptance + +- [x] Nút "Download Resume" hiển thị trong Hero CTA row +- [x] DownloadResume component riêng, dùng lại trong Contact section và ContactPage +- [x] Click → download PDF từ `/resume.pdf` +- [x] Khi chưa có PDF → ẩn hoàn toàn ở cả 2 vị trí +- [x] Responsive trên mobile +- [x] Nav không có nút Resume (Phase 2) diff --git a/docs/design/specs/v2/spec-v2-router-v8.md b/docs/design/specs/v2/spec-v2-router-v8.md new file mode 100644 index 0000000..94cc191 --- /dev/null +++ b/docs/design/specs/v2/spec-v2-router-v8.md @@ -0,0 +1,94 @@ +# Specification — v2 React Router v7 → v8 Migration + +> **Document:** `spec-v2-router-v8.md` +> **Version:** 0.1.0 +> **Parent:** `spec-v2.md` +> **Priority:** P0 (prerequisite for v2) +> **Estimate:** ~15 minutes + +--- + +## Background + +React Router v8 consolidates DOM APIs into `react-router/dom` and removes the `react-router-dom` re-export package. This app uses only the declarative mode (`<BrowserRouter>` + `<Routes>` + `<Route>`) — no data router, no loaders, no actions, no meta functions, no splat routes. + +**Current state:** +- `react-router` pinned at `7.18.4` +- 4 files import from `react-router` +- No `react-router-dom` (already removed in v7 migration) +- No `meta` functions, no `useMatches().data`, no data router APIs +- React `^19.2.8` (≥ 19.2.7 ✅) +- Vite `^8.3.0` (≥ 7 ✅) + +--- + +## Analysis + +### Future flags + +All 5 future flags are framework/data mode only. **Not applicable** to this app: + +| Flag | Applicable? | Notes | +|------|-------------|-------| +| `v8_middleware` | No | No data router / framework mode | +| `v8_splitRouteModules` | No | No `<RouterProvider>` / data router | +| `v8_viteEnvironmentApi` | No | No SSR / custom server config | +| `v8_passThroughRequests` | No | No loaders/actions | +| `v8_trailingSlashAwareDataRequests` | No | No `.data` request handling | + +### Breaking changes + +| Change | Applicable? | Notes | +|--------|-------------|-------| +| `meta`/`matches` `.data` → `loaderData` | No | No meta functions | +| `react-router-dom` removal | No | Already removed in v7 migration | +| Cloudflare plugin | No | Not using Cloudflare | +| `@react-router/architect` | No | Not using adapters | + +### Minimum versions + +| Requirement | Current | Required | Status | +|-------------|---------|----------|--------| +| `react` | `^19.2.8` | `≥19.2.7` | ✅ | +| `react-dom` | `^19.2.8` | `≥19.2.7` | ✅ | +| `vite` | `^8.3.0` | `≥7` | ✅ | + +--- + +## Implementation Steps + +### Step 1: Update package.json + +```diff +- "react-router": "7.18.4" ++ "react-router": "8.4.0" +``` + +### Step 2: Install and verify + +```sh +pnpm install +pnpm build +pnpm lint +``` + +--- + +## Acceptance + +- [x] `package.json` has `react-router@8.4.0` +- [x] `pnpm build` succeeds without errors +- [x] Dev server runs without console warnings +- [x] All routes work correctly (/ → /about → /projects → /projects/:id → /engineering → /contact) +- [x] Navigation highlighting works (NavLink active state) +- [x] Mobile menu still works +- [x] Project detail page works (useParams + Link) + +--- + +## Notes + +- v8 upgrade is non-breaking for this app (pure declarative `<BrowserRouter>` pattern) +- No code changes needed — only package version bump +- `react-router-dom` already removed in v7 migration +- All future flags are framework/data mode only, not applicable to this app diff --git a/docs/design/specs/v2/spec-v2-router.md b/docs/design/specs/v2/spec-v2-router.md new file mode 100644 index 0000000..9cdc34f --- /dev/null +++ b/docs/design/specs/v2/spec-v2-router.md @@ -0,0 +1,98 @@ +# Specification — v2 React Router v6 → v7 Migration + +> **Document:** `spec-v2-router.md` +> **Version:** 0.1.0 +> **Parent:** `spec-v2.md` +> **Priority:** P0 (prerequisite for v2) +> **Estimate:** ~30 minutes + +--- + +## Background + +React Router v7 consolidates `react-router-dom` into `react-router`. The upgrade is non-breaking if future flags are enabled. This app uses the simple `<BrowserRouter>` + `<Routes>` pattern (no data router, no forms, no splat routes). + +**Current state:** +- `react-router-dom` pinned at `6.30.6` (exact, no `^`) +- 4 files import from `react-router-dom` +- No splat routes, no forms, no data router APIs + +--- + +## Analysis + +### Applicable flags + +| Flag | Applicable? | Notes | +|------|-------------|-------| +| `v7_relativeSplatPath` | No | No splat routes (`*`) in app | +| `v7_startTransition` | **Yes** | Must enable on `<BrowserRouter>` | +| `v7_fetcherPersist` | No | No `<RouterProvider>` / data router | +| `v7_normalizeFormMethod` | No | No forms in app | +| `v7_partialHydration` | No | No `<RouterProvider>` / data router | +| `v7_skipActionErrorRevalidation` | No | No data router | + +### Files affected + +| File | Current import | Change needed | +|------|---------------|---------------| +| `src/App.tsx` | `react-router-dom` | → `react-router` + enable flag | +| `src/components/layout/Navigation.tsx` | `react-router-dom` | → `react-router` | +| `src/components/layout/Footer.tsx` | `react-router-dom` | → `react-router` | +| `src/pages/ProjectDetailPage.tsx` | `react-router-dom` | → `react-router` | + +--- + +## Implementation Steps + +### Step 1: Verify no future flags needed + +In v7, `v7_startTransition` and other future flags are enabled by default. No `future` prop needed on `<BrowserRouter>`. + +### Step 2: Update package.json + + +```diff +- "react-router-dom": "6.30.6" ++ "react-router": "7.18.4" +``` + +Also remove `@types/react-router-dom` if present (v7 types are bundled). + +### Step 3: Update imports + +All files: replace `from 'react-router-dom'` → `from 'react-router'` + +``` +src/App.tsx +src/components/layout/Navigation.tsx +src/components/layout/Footer.tsx +src/pages/ProjectDetailPage.tsx +``` + +### Step 4: Install and verify + +```bash +pnpm install +pnpm build +``` + +--- + +## Acceptance + +- [x] `package.json` has `react-router` (not `react-router-dom`) +- [x] All 4 files import from `react-router` +- [x] `pnpm build` succeeds without errors +- [x] Dev server runs without console warnings +- [x] All routes work correctly (/ → /about → /projects → /projects/:id → /engineering → /contact) +- [x] Navigation highlighting works (NavLink active state) +- [x] Mobile menu still works + +--- + +## Notes + +- v7 upgrade is non-breaking for this app (simple `<BrowserRouter>` pattern) +- No code logic changes needed — only imports + package name +- v7 enables all future flags by default; no `future` prop needed diff --git a/docs/design/specs/v2/spec-v2-seo.md b/docs/design/specs/v2/spec-v2-seo.md new file mode 100644 index 0000000..b442ccf --- /dev/null +++ b/docs/design/specs/v2/spec-v2-seo.md @@ -0,0 +1,72 @@ +# Specification — v2 SEO + +> **Document:** `spec-v2-seo.md` +> **Version:** 0.1.0 +> **Parent:** `spec-v2.md` +> **Priority:** P1 +> **Estimate:** ~1 hour + +--- + +## Requirement + +Mỗi page có metadata riêng cho SEO và social sharing. + +--- + +## Implementation + +### Dynamic Metadata + +Dùng `react-helmet-async`. + +```tsx +import { Helmet } from 'react-helmet-async' + +// HomePage.tsx +<Helmet> + <title>{profile.name} — Senior Software Engineer + + + +``` + +### Open Graph + +Mỗi page có OG tags: + +```html + + + + + +``` + +### Sitemap + +- Generate `sitemap.xml` tại build time +- Dùng `vite-plugin-sitemap` hoặc tự viết script +- Include tất cả public pages + +### Robots.txt + +- `public/robots.txt` +- Allow all + +### Structured Data (JSON-LD) + +- `Person` schema cho homepage +- `Article` schema cho blog posts (sau này) +- `BreadcrumbList` cho nested pages + +--- + +## Acceptance + +- [ ] Mỗi page có `` và `<meta description>` riêng +- [ ] OG tags đúng trên mỗi page +- [ ] `sitemap.xml` generated tại build +- [ ] `robots.txt` có trong `public/` +- [ ] JSON-LD structured data +- [ ] Canonical URL đúng diff --git a/docs/design/specs/v2/spec-v2-testing.md b/docs/design/specs/v2/spec-v2-testing.md new file mode 100644 index 0000000..da61e1d --- /dev/null +++ b/docs/design/specs/v2/spec-v2-testing.md @@ -0,0 +1,99 @@ +# Specification — v2 Testing + +> **Document:** `spec-v2-testing.md` +> **Version:** 0.1.0 +> **Parent:** `spec-v2.md` +> **Priority:** P5 +> **Estimate:** ~3 hours + +--- + +## Requirement + +Unit tests cho components và hooks. E2E tests cho critical paths. + +--- + +## Stack + +- **Vitest** — unit/integration tests +- **@testing-library/react** — component tests +- **@testing-library/jest-dom** — assertions +- **Playwright** — E2E tests + +--- + +## Test Structure + +``` +src/ + __tests__/ + hooks/ + useTheme.test.tsx + components/ + Navigation.test.tsx + Footer.test.tsx + Badge.test.tsx + pages/ + HomePage.test.tsx + e2e/ + navigation.spec.ts + theme.spec.ts + responsive.spec.ts +``` + +--- + +## Critical Tests + +### useTheme + +```tsx +test('cycles through themes correctly', () => { + const { result } = renderHook(() => useTheme()) + act(() => { result.current.cycleTheme() }) + expect(result.current.theme).toBe('light') +}) + +test('persists theme to localStorage', () => { + renderHook(() => useTheme()) + expect(localStorage.getItem('portfolio-theme')).toBe('dark') +}) +``` + +### Navigation + +```tsx +test('renders all nav items', () => { + render(<Navigation />) + navItems.forEach(item => { + expect(screen.getByText(item.label)).toBeInTheDocument() + }) +}) + +test('NavLink highlights active route', () => { + render(<MemoryRouter initialEntries={['/about']}> <Navigation /> </MemoryRouter>) + expect(screen.getByText('About')).toHaveClass('active') +}) +``` + +### HomePage + +```tsx +test('renders hero section', () => { + render(<HomePage />) + expect(screen.getByRole('heading', { name: profile.name })).toBeInTheDocument() +}) +``` + +--- + +## Acceptance + +- [ ] useTheme tests pass +- [ ] Navigation tests pass +- [ ] HomePage tests pass +- [ ] E2E: navigation works +- [ ] E2E: theme toggle works +- [ ] E2E: responsive layout correct +- [ ] Test coverage > 70% diff --git a/docs/sample-code/rolling-text-button.md b/docs/sample-code/rolling-text-button.md new file mode 100644 index 0000000..c911fbf --- /dev/null +++ b/docs/sample-code/rolling-text-button.md @@ -0,0 +1,194 @@ +```typescript +"use client" + +import { motion, useReducedMotion } from "motion/react" +import { useRef, useState } from "react" + +const outgoingVariants = { + rest: { transform: "translateY(0%)" }, + active: { transform: "translateY(100%)" }, +} + +const incomingVariants = { + rest: { transform: "translateY(-100%)" }, + active: { transform: "translateY(0%)" }, +} + +const transition = { + duration: 0.3, + ease: [0.338, 0.015, 0.395, 0.959] as const, +} + +function ChevronRightIcon() { + return ( + <svg + xmlns="http://www.w3.org/2000/svg" + width="1em" + height="1em" + viewBox="0 0 24 24" + fill="none" + stroke="currentColor" + strokeWidth="2" + strokeLinecap="round" + strokeLinejoin="round" + aria-hidden="true" + focusable="false" + > + <path d="m9 18 6-6-6-6" /> + </svg> + ) +} + +export default function RollingTextButton() { + const reduceMotion = useReducedMotion() + const [active, setActive] = useState(false) + const activeRef = useRef(false) + const animating = useRef(false) + const pendingRequest = useRef<boolean | null>(null) + const hovered = useRef(false) + const focused = useRef(false) + + const updateActive = (next: boolean) => { + activeRef.current = next + setActive(next) + } + + const requestActive = (next: boolean) => { + if (reduceMotion) return + + if (next === activeRef.current) { + pendingRequest.current = null + return + } + + if (animating.current) { + pendingRequest.current = next + return + } + + animating.current = true + updateActive(next) + } + + const completeAnimation = () => { + if (!animating.current) return + animating.current = false + + if ( + pendingRequest.current !== null && + pendingRequest.current !== activeRef.current + ) { + const next = pendingRequest.current + pendingRequest.current = null + animating.current = true + updateActive(next) + } else { + pendingRequest.current = null + } + } + + return ( + <main className="rolling-button-stage fresh-system"> + <motion.button + type="button" + className="fresh-primary-action" + aria-label="Start free" + onHoverStart={() => { + hovered.current = true + requestActive(true) + }} + onHoverEnd={() => { + hovered.current = false + requestActive(focused.current) + }} + onFocus={() => { + focused.current = true + requestActive(true) + }} + onBlur={() => { + focused.current = false + requestActive(hovered.current) + }} + > + <span className="fresh-primary-action-content" aria-hidden="true"> + <span className="label-window"> + <motion.span + className="label-copy" + variants={outgoingVariants} + initial="rest" + animate={active ? "active" : "rest"} + onAnimationComplete={completeAnimation} + transition={transition} + > + Start free + </motion.span> + <motion.span + className="label-copy label-copy--incoming" + variants={incomingVariants} + initial="rest" + animate={active ? "active" : "rest"} + transition={transition} + > + Start free + </motion.span> + </span> + <span> + <ChevronRightIcon /> + </span> + </span> + </motion.button> + <Stylesheet /> + </main> + ) +} + +function Stylesheet() { + return ( + <style>{` + html, body { + margin: 0; + min-height: 100%; + } + + .rolling-button-stage, + .rolling-button-stage * { + box-sizing: border-box; + } + + .rolling-button-stage { + --fresh-accent: var(--lab-blueberry); + display: flex; + align-items: center; + justify-content: center; + width: 100%; + min-height: 100vh; + } + + .label-window { + position: relative; + display: block; + width: max-content; + overflow: hidden; + } + + .label-copy { + display: block; + white-space: nowrap; + } + + .label-copy--incoming { + position: absolute; + inset: 0; + } + + @media (hover: hover) { + .rolling-button-stage .fresh-primary-action:hover { + border-color: var(--fresh-primary-background); + } + } + + `}</style> + ) +} + +``` \ No newline at end of file diff --git a/package.json b/package.json index 6d0b62e..c458609 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,10 @@ "preview": "vite preview" }, "dependencies": { + "motion": "^14.0.0", "react": "^19.2.8", "react-dom": "^19.2.8", - "react-router-dom": "6.30.6" + "react-router": "8.4.0" }, "devDependencies": { "@types/node": "^24.13.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9d5c6c5..11beb33 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,15 +8,18 @@ importers: .: dependencies: + motion: + specifier: ^14.0.0 + version: 14.0.0(react-dom@19.3.0(react@19.3.0))(react@19.3.0) react: specifier: ^19.2.8 version: 19.3.0 react-dom: specifier: ^19.2.8 version: 19.3.0(react@19.3.0) - react-router-dom: - specifier: 6.30.6 - version: 6.30.6(react-dom@19.3.0(react@19.3.0))(react@19.3.0) + react-router: + specifier: 8.4.0 + version: 8.4.0(react-dom@19.3.0(react@19.3.0))(react@19.3.0) devDependencies: '@types/node': specifier: ^24.13.3 @@ -167,9 +170,8 @@ packages: cpu: [x64] os: [win32] - '@remix-run/router@1.23.4': - resolution: {integrity: sha512-q7j5geK7xs3UJSdm9/iytUNclBnLmYx1EnSeCFXHPeutdqgIMeFeHtUZgS3EhlKxdBEAu8OwtJCwmLrEzpSs7Q==} - engines: {node: '>=14.0.0'} + '@remix-run/route-pattern@0.22.1': + resolution: {integrity: sha512-czdGJWh09Lapvcqt7Vb09KlrU2PhRJ8xQaI+AItTuD9aDJ5MAgxnS38lnys6Ll+6RJEqPiaUqTwIQhVLwFvv+w==} '@rolldown/binding-android-arm-eabi@1.2.12': resolution: {integrity: sha512-dB/a1214qKfHMXCpgqR4OZT+jS4kTyEXbQGJPqzobt5EwH5rX080pxE37alt3RzvR1bf1Yz/yGqRfrYAxuPw0A==} @@ -297,6 +299,9 @@ packages: oxc-transform-react: optional: true + cookie-es@3.1.1: + resolution: {integrity: sha512-UaXxwISYJPTr9hwQxMFYZ7kNhSXboMXP+Z3TRX6f1/NyaGPfuNUZOWP1pUEb75B2HjfklIYLVRfWiFZJyC6Npg==} + csstype@3.2.3: resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==} @@ -313,6 +318,17 @@ packages: picomatch: optional: true + framer-motion@14.0.0: + resolution: {integrity: sha512-QAtHmybrDFSliyW1sexMtSQTQd+1jw2ajibEmzpuI4XdPVzQkn+dAzJMm2sW3pl9MJuSS4xN51djQ7huhlP/VA==} + peerDependencies: + react: ^18.0.0 || ^19.0.0 + react-dom: ^18.0.0 || ^19.0.0 + peerDependenciesMeta: + react: + optional: true + react-dom: + optional: true + fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -392,6 +408,23 @@ packages: resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==} engines: {node: '>= 12.0.0'} + motion-dom@14.0.0: + resolution: {integrity: sha512-aU3ApXo1yTpeUi3JU+jbDk2TELjxPE3MbBMUP7nZHlARb6RweJK+ojmLjpuB0YsY6zhbBl1YWGo8LMsI1/Llqw==} + + motion-utils@14.0.0: + resolution: {integrity: sha512-jBsyjVxTTRZNeuvd/v+btVXr90LQkYl4HhRu9T2ARc+PMnvkmjsjRVeAg4Qm10b6TlTw+kykWI8gu/6LuvpLSQ==} + + motion@14.0.0: + resolution: {integrity: sha512-oGc2lkge2lkRZCP+J8/JsnYu4NFjqP1MtXirNdetn3QbvK2JqwM9A200EdT4C598KfzDhjLT12zF21xDM4Oilw==} + peerDependencies: + react: ^18.0.0 || ^19.0.0 + react-dom: ^18.0.0 || ^19.0.0 + peerDependenciesMeta: + react: + optional: true + react-dom: + optional: true + nanoid@3.3.19: resolution: {integrity: sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -426,18 +459,15 @@ packages: peerDependencies: react: ^19.3.0 - react-router-dom@6.30.6: - resolution: {integrity: sha512-0RHKZz7wwffvkU+2MFVT2NnjK44ssLEV+m0CAJaS2Ksmorrwj7WxH00jO0SOCW26/tINUnJHToXblDs33I38YQ==} - engines: {node: '>=14.0.0'} + react-router@8.4.0: + resolution: {integrity: sha512-JtydAkBvU9UTEe5qNC+POhu+ZBNM7rlKY2IegwXc7Idj7xfRG16x5RZrw3mju+XlqBxfvb2ky9P3jUp9WyWC1g==} + engines: {node: '>=22.22.0'} peerDependencies: - react: '>=16.8' - react-dom: '>=16.8' - - react-router@6.30.6: - resolution: {integrity: sha512-5HfK7k5im7LTOB0EqCQmfvy4C13G92Ssj1VTmouTK3AJvyjKTnFuCV0vcMAD/JS+JC4DvDIBRrlAeJIFjh5VWg==} - engines: {node: '>=14.0.0'} - peerDependencies: - react: '>=16.8' + react: '>=19.2.7' + react-dom: '>=19.2.7' + peerDependenciesMeta: + react-dom: + optional: true react@19.3.0: resolution: {integrity: sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==} @@ -459,6 +489,9 @@ packages: resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} engines: {node: '>=12.0.0'} + tslib@2.8.1: + resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + typescript@6.0.3: resolution: {integrity: sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==} engines: {node: '>=14.17'} @@ -571,7 +604,7 @@ snapshots: '@oxlint/binding-win32-x64-msvc@1.86.0': optional: true - '@remix-run/router@1.23.4': {} + '@remix-run/route-pattern@0.22.1': {} '@rolldown/binding-android-arm-eabi@1.2.12': optional: true @@ -637,6 +670,8 @@ snapshots: '@rolldown/pluginutils': 1.0.1 vite: 8.3.2(@types/node@24.19.1) + cookie-es@3.1.1: {} + csstype@3.2.3: {} detect-libc@2.1.2: {} @@ -645,6 +680,15 @@ snapshots: optionalDependencies: picomatch: 4.0.7 + framer-motion@14.0.0(react-dom@19.3.0(react@19.3.0))(react@19.3.0): + dependencies: + motion-dom: 14.0.0 + motion-utils: 14.0.0 + tslib: 2.8.1 + optionalDependencies: + react: 19.3.0 + react-dom: 19.3.0(react@19.3.0) + fsevents@2.3.3: optional: true @@ -697,6 +741,20 @@ snapshots: lightningcss-win32-arm64-msvc: 1.33.0 lightningcss-win32-x64-msvc: 1.33.0 + motion-dom@14.0.0: + dependencies: + motion-utils: 14.0.0 + + motion-utils@14.0.0: {} + + motion@14.0.0(react-dom@19.3.0(react@19.3.0))(react@19.3.0): + dependencies: + framer-motion: 14.0.0(react-dom@19.3.0(react@19.3.0))(react@19.3.0) + tslib: 2.8.1 + optionalDependencies: + react: 19.3.0 + react-dom: 19.3.0(react@19.3.0) + nanoid@3.3.19: {} oxlint@1.86.0: @@ -736,17 +794,13 @@ snapshots: react: 19.3.0 scheduler: 0.28.0 - react-router-dom@6.30.6(react-dom@19.3.0(react@19.3.0))(react@19.3.0): + react-router@8.4.0(react-dom@19.3.0(react@19.3.0))(react@19.3.0): dependencies: - '@remix-run/router': 1.23.4 + '@remix-run/route-pattern': 0.22.1 + cookie-es: 3.1.1 react: 19.3.0 + optionalDependencies: react-dom: 19.3.0(react@19.3.0) - react-router: 6.30.6(react@19.3.0) - - react-router@6.30.6(react@19.3.0): - dependencies: - '@remix-run/router': 1.23.4 - react: 19.3.0 react@19.3.0: {} @@ -780,6 +834,8 @@ snapshots: fdir: 6.5.0(picomatch@4.0.7) picomatch: 4.0.7 + tslib@2.8.1: {} + typescript@6.0.3: {} undici-types@7.24.6: {} diff --git a/public/profile-photo.jpg b/public/profile-photo.jpg new file mode 100644 index 0000000..3d8c0ec Binary files /dev/null and b/public/profile-photo.jpg differ diff --git a/public/profile-photo.webp b/public/profile-photo.webp new file mode 100644 index 0000000..4670338 Binary files /dev/null and b/public/profile-photo.webp differ diff --git a/public/profile-photo.webp~ b/public/profile-photo.webp~ new file mode 100644 index 0000000..af79baf Binary files /dev/null and b/public/profile-photo.webp~ differ diff --git a/public/toast-bar0001-0120.mp4 b/public/toast-bar0001-0120.mp4 new file mode 100644 index 0000000..99d9088 Binary files /dev/null and b/public/toast-bar0001-0120.mp4 differ diff --git a/src/App.css b/src/App.css index 9c7ef55..c902a2f 100644 --- a/src/App.css +++ b/src/App.css @@ -200,6 +200,7 @@ .btn-primary:hover { background: var(--accent-hover); + color: #ffffff; } .btn-primary:active { @@ -355,6 +356,25 @@ width: 20px; height: 20px; } +/* ===== Section Background Gradient ===== */ +.section { + position: relative; +} + +.section::before { + content: ''; + position: absolute; + inset: 0; + background: linear-gradient( + to bottom, + transparent 0%, + var(--bg-primary) 10%, + var(--bg-primary) 90%, + transparent 100% + ); + pointer-events: none; + z-index: -1; +} /* ===== Hero ===== */ .hero { @@ -400,26 +420,32 @@ } .hero-visual { + position: relative; display: flex; align-items: center; justify-content: center; } -.hero-graphic { +.hero-photo { width: 100%; - max-width: 400px; - aspect-ratio: 1; - position: relative; + height: 100%; + object-fit: cover; + object-position: center top; + border-radius: 16px; + display: block; } @media (max-width: 768px) { .hero { - grid-template-columns: 1fr; - gap: 32px; - min-height: auto; - padding: 48px 0; + position: relative; + min-height: 500px; + overflow: hidden; + } + .hero { + max-width: 100%; + margin: 0; + padding: 0; } - .hero-cta { flex-direction: column; } @@ -429,7 +455,26 @@ } .hero-visual { - display: none; + position: absolute; + inset: 0; + z-index: 0; + } + + .hero-content { + position: absolute; + z-index: 1; + background: rgba(0, 0, 0, 0.55); + padding: 32px 24px; + backdrop-filter: blur(4px); + width: 100%; + } + +} + +@media (min-width: 769px) and (max-width: 1200px) { + .hero-content { + padding-left: 16px; + padding-right: 16px; } } diff --git a/src/App.tsx b/src/App.tsx index b22964b..70f639d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ import './App.css' -import { BrowserRouter, Routes, Route } from 'react-router-dom' +import { BrowserRouter, Routes, Route } from 'react-router' import { ThemeProvider } from '@/hooks/useTheme' import { Layout } from '@/components/layout/Layout' import { diff --git a/src/components/layout/Footer.tsx b/src/components/layout/Footer.tsx index 68dcb21..c7f8e15 100644 --- a/src/components/layout/Footer.tsx +++ b/src/components/layout/Footer.tsx @@ -1,4 +1,4 @@ -import { Link } from 'react-router-dom' +import { Link } from 'react-router' import { profile } from '@/data/profile' const footerLinks = [ diff --git a/src/components/layout/Navigation.tsx b/src/components/layout/Navigation.tsx index cc0246f..bc8a6d9 100644 --- a/src/components/layout/Navigation.tsx +++ b/src/components/layout/Navigation.tsx @@ -1,6 +1,7 @@ import { useState, useEffect } from 'react' -import { Link, NavLink, useLocation } from 'react-router-dom' +import { Link, useLocation } from 'react-router' import { useTheme } from '@/hooks/useTheme' +import { RollingTextLink } from '@/components/ui/RollingTextLink' const navItems = [ { label: 'Home', path: '/' }, @@ -42,14 +43,12 @@ export function Navigation() { <ul className="nav-menu"> {navItems.map((item) => ( <li key={item.path}> - <NavLink + <RollingTextLink to={item.path} - className={({ isActive }) => - isActive ? 'nav-link active' : 'nav-link' - } + className={item.path === location.pathname ? 'nav-link active' : 'nav-link'} > {item.label} - </NavLink> + </RollingTextLink> </li> ))} </ul> @@ -97,15 +96,13 @@ export function Navigation() { <ul className="mobile-menu-list"> {navItems.map((item) => ( <li key={item.path}> - <NavLink + <RollingTextLink to={item.path} - className={({ isActive }) => - isActive ? 'mobile-menu-link active' : 'mobile-menu-link' - } + className={item.path === location.pathname ? 'mobile-menu-link active' : 'mobile-menu-link'} onClick={() => setMobileOpen(false)} > {item.label} - </NavLink> + </RollingTextLink> </li> ))} </ul> diff --git a/src/components/sections/About.tsx b/src/components/sections/About.tsx index ece4457..4108526 100644 --- a/src/components/sections/About.tsx +++ b/src/components/sections/About.tsx @@ -1,10 +1,12 @@ import { SectionHeading } from '@/components/ui/SectionHeading' +import { InView } from '@/components/ui/InView' import { Tag } from '@/components/ui/Tag' import { profile } from '@/data/profile' export function About() { return ( - <section className="section container-content" aria-labelledby="about-heading"> + <InView> + <section className="section container-wide" aria-labelledby="about-heading"> <SectionHeading title="About Me" /> <div style={{ maxWidth: '700px' }}> <p style={{ fontSize: '18px', marginBottom: '32px' }}> @@ -41,5 +43,6 @@ export function About() { </div> </div> </section> + </InView> ) } diff --git a/src/components/sections/Contact.tsx b/src/components/sections/Contact.tsx index 91f7bbb..437c67e 100644 --- a/src/components/sections/Contact.tsx +++ b/src/components/sections/Contact.tsx @@ -1,40 +1,106 @@ -import { SectionHeading } from '@/components/ui/SectionHeading' -import { profile } from '@/data/profile' +import { motion } from "motion/react" +import { DownloadResume } from "@/components/sections/DownloadResume" +import { SectionHeading } from "@/components/ui/SectionHeading" +import { profile } from "@/data/profile" +import { InView } from "@/components/ui/InView" export function Contact() { return ( - <section className="section container-content" aria-labelledby="contact-heading"> - <SectionHeading title="Contact" /> - <div className="contact-links"> - <a href={`mailto:${profile.email}`} className="contact-link"> - <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" width="24" height="24"> - <rect x="2" y="4" width="20" height="16" rx="2" /> - <path d="M22 4l-10 8L2 4" /> - </svg> - <div> - <div style={{ fontWeight: 500, color: 'var(--text-primary)' }}>Email</div> - <div style={{ fontSize: '14px', color: 'var(--text-muted)' }}>{profile.email}</div> - </div> - </a> - <a href={profile.githubUrl} target="_blank" rel="noopener noreferrer" className="contact-link"> - <svg viewBox="0 0 24 24" fill="currentColor" width="24" height="24"> - <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" /> - </svg> - <div> - <div style={{ fontWeight: 500, color: 'var(--text-primary)' }}>GitHub</div> - <div style={{ fontSize: '14px', color: 'var(--text-muted)' }}>@yourusername</div> - </div> - </a> - <a href={profile.linkedinUrl} target="_blank" rel="noopener noreferrer" className="contact-link"> - <svg viewBox="0 0 24 24" fill="currentColor" width="24" height="24"> - <path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z" /> - </svg> - <div> - <div style={{ fontWeight: 500, color: 'var(--text-primary)' }}>LinkedIn</div> - <div style={{ fontSize: '14px', color: 'var(--text-muted)' }}>Your Name</div> - </div> - </a> - </div> - </section> + <InView> + <motion.section + className="section container-wide" + aria-labelledby="contact-heading" + initial="hidden" + whileInView="visible" + viewport={{ once: true, amount: 0.1 }} + variants={{ + hidden: { opacity: 0 }, + visible: { opacity: 1, transition: { duration: 0.5 } }, + }} + > + <SectionHeading title="Contact" /> + <div style={{ maxWidth: '700px' }}> + <div className="contact-links"> + <motion.a + href={`mailto:${profile.email}`} + className="contact-link" + whileHover={{ scale: 1.05 }} + whileTap={{ scale: 0.95 }} + > + <svg + viewBox="0 0 24 24" + fill="none" + stroke="currentColor" + strokeWidth="2" + width="24" + height="24" + > + <rect x="2" y="4" width="20" height="16" rx="2" /> + <path d="M22 4l-10 8L2 4" /> + </svg> + <div> + <div style={{ fontWeight: 500, color: "var(--text-primary)" }}> + Email + </div> + <div style={{ fontSize: "14px", color: "var(--text-muted)" }}> + {profile.email} + </div> + </div> + </motion.a> + <motion.a + href={profile.githubUrl} + target="_blank" + rel="noopener noreferrer" + className="contact-link" + whileHover={{ scale: 1.05 }} + whileTap={{ scale: 0.95 }} + > + <svg + viewBox="0 0 24 24" + fill="currentColor" + width="24" + height="24" + > + <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" /> + </svg> + <div> + <div style={{ fontWeight: 500, color: "var(--text-primary)" }}> + GitHub + </div> + <div style={{ fontSize: "14px", color: "var(--text-muted)" }}> + @yourusername + </div> + </div> + </motion.a> + <motion.a + href={profile.linkedinUrl} + target="_blank" + rel="noopener noreferrer" + className="contact-link" + whileHover={{ scale: 1.05 }} + whileTap={{ scale: 0.95 }} + > + <svg + viewBox="0 0 24 24" + fill="currentColor" + width="24" + height="24" + > + <path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z" /> + </svg> + <div> + <div style={{ fontWeight: 500, color: "var(--text-primary)" }}> + LinkedIn + </div> + <div style={{ fontSize: "14px", color: "var(--text-muted)" }}> + Your Name + </div> + </div> + </motion.a> + </div> + </div> + <DownloadResume /> + </motion.section> + </InView> ) } diff --git a/src/components/sections/DownloadResume.tsx b/src/components/sections/DownloadResume.tsx new file mode 100644 index 0000000..b68d3c1 --- /dev/null +++ b/src/components/sections/DownloadResume.tsx @@ -0,0 +1,21 @@ +import { resumeAvailable } from '@/data/resume' + +export function DownloadResume() { + if (!resumeAvailable) return null + + return ( + <div style={{ marginTop: '32px' }}> + <a href="/resume.pdf" download className="contact-link" style={{ display: 'flex', alignItems: 'center', gap: '12px', padding: '12px 20px', borderRadius: '8px', textDecoration: 'none', color: 'var(--text-primary)', border: '1px solid var(--border)' }}> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" width="24" height="24"> + <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /> + <polyline points="7 10 12 15 17 10" /> + <line x1="12" y1="15" x2="12" y2="3" /> + </svg> + <div> + <div style={{ fontWeight: 500, color: 'var(--text-primary)' }}>Download Resume</div> + <div style={{ fontSize: '14px', color: 'var(--text-muted)' }}>PDF</div> + </div> + </a> + </div> + ) +} diff --git a/src/components/sections/Experience.tsx b/src/components/sections/Experience.tsx index b393e77..f5feeb0 100644 --- a/src/components/sections/Experience.tsx +++ b/src/components/sections/Experience.tsx @@ -1,56 +1,106 @@ -import { experiences } from '@/data/experience' +import { motion } from "motion/react" +import { experiences } from "@/data/experience" +import { InView } from "@/components/ui/InView" export function Experience() { return ( - <section className="section container-content" aria-labelledby="experience-heading"> - <h2 id="experience-heading" style={{ marginBottom: '48px' }}> - Experience - </h2> - <div className="timeline"> - {experiences.map((exp) => ( - <div key={exp.id} className="timeline-entry"> - <div className="timeline-marker" /> - <div className="timeline-header"> - <div className="timeline-title">{exp.title}</div> - <div className="timeline-company">{exp.company}</div> - <div className="timeline-duration">{exp.duration}</div> - {exp.location && ( - <div className="timeline-duration">{exp.location}</div> - )} - </div> - <ul className="timeline-responsibilities"> - {exp.responsibilities.map((r) => ( - <li key={r}>{r}</li> - ))} - </ul> - {exp.achievements?.map((achievement) => ( - <div key={achievement.id} className="achievement"> - <div className="achievement-title">{achievement.title}</div> - <div className="achievement-context">{achievement.context}</div> - <div style={{ fontSize: '14px', color: 'var(--text-secondary)', marginBottom: '8px' }}> - {achievement.impact} - </div> - {achievement.metrics && achievement.metrics.length > 0 && ( - <div style={{ marginBottom: '8px' }}> - {achievement.metrics.map((m) => ( - <span key={m} className="achievement-metric"> - {m} + <InView> + <motion.section + className="section container-wide" + aria-labelledby="experience-heading" + initial="hidden" + whileInView="visible" + viewport={{ once: true, amount: 0.1 }} + variants={{ + hidden: { opacity: 0 }, + visible: { + opacity: 1, + transition: { staggerChildren: 0.15 }, + }, + }} + > + <motion.h2 + id="experience-heading" + style={{ marginBottom: "48px" }} + variants={{ + hidden: { opacity: 0, y: 30 }, + visible: { opacity: 1, y: 0, transition: { duration: 0.5 } }, + }} + > + Experience + </motion.h2> + <div style={{ maxWidth: '700px' }}> + <div className="timeline"> + {experiences.map((exp, i) => ( + <motion.div + key={exp.id} + className="timeline-entry" + variants={{ + hidden: { opacity: 0, y: 30 }, + visible: { + opacity: 1, + y: 0, + transition: { duration: 0.5, delay: i * 0.15 }, + }, + }} + whileHover={{ scale: 1.02, y: -4 }} + whileTap={{ scale: 0.98 }} + > + <div className="timeline-marker" /> + <div className="timeline-header"> + <div className="timeline-title">{exp.title}</div> + <div className="timeline-company">{exp.company}</div> + <div className="timeline-duration">{exp.duration}</div> + {exp.location && ( + <div className="timeline-duration">{exp.location}</div> + )} + </div> + <ul className="timeline-responsibilities"> + {exp.responsibilities.map((r) => ( + <li key={r}>{r}</li> + ))} + </ul> + {exp.achievements?.map((achievement) => ( + <div key={achievement.id} className="achievement"> + <div className="achievement-title"> + {achievement.title} + </div> + <div className="achievement-context"> + {achievement.context} + </div> + <div + style={{ + fontSize: "14px", + color: "var(--text-secondary)", + marginBottom: "8px", + }} + > + {achievement.impact} + </div> + {achievement.metrics && + achievement.metrics.length > 0 && ( + <div style={{ marginBottom: "8px" }}> + {achievement.metrics.map((m) => ( + <span key={m} className="achievement-metric"> + {m} + </span> + ))} + </div> + )} + <div className="achievement-techs"> + {achievement.technologies.map((tech) => ( + <span key={tech} className="tag"> + {tech} </span> ))} </div> - )} - <div className="achievement-techs"> - {achievement.technologies.map((tech) => ( - <span key={tech} className="tag"> - {tech} - </span> - ))} </div> - </div> - ))} - </div> - ))} - </div> - </section> + ))} + </motion.div> + ))} + </div> + </div> + </motion.section> + </InView> ) } diff --git a/src/components/sections/Expertise.tsx b/src/components/sections/Expertise.tsx index 141d1d4..dac1789 100644 --- a/src/components/sections/Expertise.tsx +++ b/src/components/sections/Expertise.tsx @@ -1,24 +1,54 @@ -import { SectionHeading } from '@/components/ui/SectionHeading' -import { skillGroups } from '@/data/skills' +import { motion } from "motion/react" +import { SectionHeading } from "@/components/ui/SectionHeading" +import { skillGroups } from "@/data/skills" +import { InView } from "@/components/ui/InView" export function Expertise() { return ( - <section className="section container-wide" aria-labelledby="expertise-heading"> - <SectionHeading title="Core Expertise" /> - <div className="expertise-grid"> - {skillGroups.map((group) => ( - <div key={group.title} className="expertise-card"> - <h3>{group.title}</h3> - <ul className="expertise-skills"> - {group.skills.map((skill) => ( - <li key={skill} className="expertise-skill"> - {skill} - </li> - ))} - </ul> - </div> - ))} - </div> - </section> + <InView> + <motion.section + className="section container-wide" + aria-labelledby="expertise-heading" + initial="hidden" + whileInView="visible" + viewport={{ once: true, amount: 0.1 }} + variants={{ + hidden: { opacity: 0 }, + visible: { + opacity: 1, + transition: { staggerChildren: 0.1 }, + }, + }} + > + <SectionHeading title="Core Expertise" /> + <div className="expertise-grid"> + {skillGroups.map((group, i) => ( + <motion.div + key={group.title} + className="expertise-card" + variants={{ + hidden: { opacity: 0, y: 30 }, + visible: { + opacity: 1, + y: 0, + transition: { duration: 0.5, delay: i * 0.1 }, + }, + }} + whileHover={{ scale: 1.05, y: -2 }} + whileTap={{ scale: 0.98 }} + > + <h3>{group.title}</h3> + <ul className="expertise-skills"> + {group.skills.map((skill) => ( + <li key={skill} className="expertise-skill"> + {skill} + </li> + ))} + </ul> + </motion.div> + ))} + </div> + </motion.section> + </InView> ) } diff --git a/src/components/sections/Hero.tsx b/src/components/sections/Hero.tsx index 1c48da1..3b566dc 100644 --- a/src/components/sections/Hero.tsx +++ b/src/components/sections/Hero.tsx @@ -1,12 +1,15 @@ -import { Button } from '@/components/ui/Button' -import { SocialLinks } from '@/components/ui/SocialLinks' -import { profile } from '@/data/profile' +import { motion, useScroll, useTransform } from "motion/react" +import { InView } from "@/components/ui/InView" +import { resumeAvailable } from "@/data/resume" +import { Button } from "@/components/ui/Button" +import { SocialLinks } from "@/components/ui/SocialLinks" +import { profile } from "@/data/profile" const socialLinks = [ { - label: 'GitHub', + label: "GitHub", href: profile.githubUrl, - 'aria-label': 'View GitHub profile', + "aria-label": "View GitHub profile", icon: ( <svg viewBox="0 0 24 24" fill="currentColor" width="20" height="20"> <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" /> @@ -14,9 +17,9 @@ const socialLinks = [ ), }, { - label: 'LinkedIn', + label: "LinkedIn", href: profile.linkedinUrl, - 'aria-label': 'View LinkedIn profile', + "aria-label": "View LinkedIn profile", icon: ( <svg viewBox="0 0 24 24" fill="currentColor" width="20" height="20"> <path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z" /> @@ -24,9 +27,9 @@ const socialLinks = [ ), }, { - label: 'Email', + label: "Email", href: `mailto:${profile.email}`, - 'aria-label': 'Send email', + "aria-label": "Send email", icon: ( <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" width="20" height="20"> <rect x="2" y="4" width="20" height="16" rx="2" /> @@ -37,57 +40,84 @@ const socialLinks = [ ] export function Hero() { + const { scrollY } = useScroll() + const y = useTransform(scrollY, [0, 300], [0, -80]) + const opacity = useTransform(scrollY, [0, 200], [1, 0.3]) return ( - <section className="hero container-wide" aria-labelledby="hero-heading"> - <div className="hero-content"> - <h1 id="hero-heading" className="hero-name"> + <InView> + <motion.section + className="hero container-wide" + initial={{ opacity: 0 }} + animate={{ opacity: 1 }} + transition={{ duration: 0.3 }} + aria-labelledby="hero-heading" + > + <motion.div + className="hero-content" + style={{ opacity }} + initial={{ opacity: 0, x: -30 }} + animate={{ opacity: 1, x: 0 }} + transition={{ duration: 0.6, delay: 0.2 }} + > + <motion.h1 + id="hero-heading" + className="hero-name" + initial={{ opacity: 0, y: 20 }} + animate={{ opacity: 1, y: 0 }} + transition={{ duration: 0.5, delay: 0.3 }} + > {profile.name} - </h1> - <p className="hero-title">{profile.title}</p> - <p className="hero-tagline">{profile.tagline}</p> - <div className="hero-cta"> + </motion.h1> + <motion.p + className="hero-title" + initial={{ opacity: 0, y: 20 }} + animate={{ opacity: 1, y: 0 }} + transition={{ duration: 0.5, delay: 0.4 }} + > + {profile.title} + </motion.p> + <motion.p + className="hero-tagline" + initial={{ opacity: 0, y: 20 }} + animate={{ opacity: 1, y: 0 }} + transition={{ duration: 0.5, delay: 0.5 }} + > + {profile.tagline} + </motion.p> + <motion.div + className="hero-cta" + initial={{ opacity: 0, y: 20 }} + animate={{ opacity: 1, y: 0 }} + transition={{ duration: 0.5, delay: 0.6 }} + > <Button href="/projects" variant="primary"> View Projects </Button> + {resumeAvailable && ( + <Button href="/resume.pdf" variant="secondary" target="_blank"> + Download Resume + </Button> + )} <Button href="/contact" variant="secondary"> Contact Me </Button> - </div> + </motion.div> <SocialLinks links={socialLinks} /> - </div> - <div className="hero-visual"> - <div className="hero-graphic"> - <svg viewBox="0 0 400 400" fill="none" xmlns="http://www.w3.org/2000/svg"> - {/* Abstract system diagram */} - <circle cx="200" cy="200" r="160" stroke="var(--border)" strokeWidth="1" /> - <circle cx="200" cy="200" r="100" stroke="var(--border)" strokeWidth="1" /> - <circle cx="200" cy="200" r="40" stroke="var(--accent)" strokeWidth="2" opacity="0.6" /> - - {/* Nodes */} - <circle cx="200" cy="80" r="8" fill="var(--accent)" opacity="0.8" /> - <circle cx="320" cy="200" r="8" fill="var(--accent)" opacity="0.8" /> - <circle cx="200" cy="320" r="8" fill="var(--accent)" opacity="0.8" /> - <circle cx="80" cy="200" r="8" fill="var(--accent)" opacity="0.8" /> - - {/* Connections */} - <line x1="200" y1="88" x2="200" y2="160" stroke="var(--accent)" strokeWidth="1" opacity="0.4" /> - <line x1="312" y1="200" x2="240" y2="200" stroke="var(--accent)" strokeWidth="1" opacity="0.4" /> - <line x1="200" y1="312" x2="200" y2="240" stroke="var(--accent)" strokeWidth="1" opacity="0.4" /> - <line x1="88" y1="200" x2="160" y2="200" stroke="var(--accent)" strokeWidth="1" opacity="0.4" /> - - {/* Diagonal connections */} - <line x1="206" y1="86" x2="314" y2="194" stroke="var(--accent)" strokeWidth="0.5" opacity="0.2" /> - <line x1="314" y1="206" x2="206" y2="314" stroke="var(--accent)" strokeWidth="0.5" opacity="0.2" /> - <line x1="194" y1="314" x2="86" y2="206" stroke="var(--accent)" strokeWidth="0.5" opacity="0.2" /> - <line x1="86" y1="194" x2="194" y2="86" stroke="var(--accent)" strokeWidth="0.5" opacity="0.2" /> - - {/* Center label */} - <text x="200" y="205" textAnchor="middle" fill="var(--accent)" fontSize="14" fontFamily="monospace"> - core - </text> - </svg> - </div> - </div> - </section> + </motion.div> + <motion.div + className="hero-visual" + style={{ y }} + initial={{ opacity: 0, x: 30 }} + animate={{ opacity: 1, x: 0 }} + transition={{ duration: 0.6, delay: 0.4 }} + > + <img + src="/profile-photo.webp" + alt="Profile photo" + className="hero-photo" + /> + </motion.div> + </motion.section> + </InView> ) } diff --git a/src/components/sections/Projects.tsx b/src/components/sections/Projects.tsx index 6f5815d..d3f18e2 100644 --- a/src/components/sections/Projects.tsx +++ b/src/components/sections/Projects.tsx @@ -1,60 +1,105 @@ -import { Badge } from '@/components/ui/Badge' -import { projects } from '@/data/projects' +import { Link } from "react-router" +import { motion } from "motion/react" +import { Badge } from "@/components/ui/Badge" +import { projects } from "@/data/projects" +import { InView } from "@/components/ui/InView" +const MotionLink = motion.create(Link) const categoryLabels: Record<string, string> = { - 'software-engineering': 'Software Engineering', - logistics: 'Logistics', - 'ai-ml': 'AI / ML', - 'computer-vision': 'Computer Vision', - architecture: 'Architecture', - experiment: 'Experiment', + "software-engineering": "Software Engineering", + logistics: "Logistics", + "ai-ml": "AI / ML", + "computer-vision": "Computer Vision", + architecture: "Architecture", + experiment: "Experiment", } export function Projects() { const featured = projects.filter((p) => p.featured).slice(0, 4) return ( - <section className="section container-wide" aria-labelledby="projects-heading"> - <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', marginBottom: '48px' }}> - <h2 id="projects-heading">Featured Projects</h2> - <a href="/projects" style={{ fontSize: '14px', fontWeight: 500, color: 'var(--accent)' }}> - View All → - </a> - </div> - <div className="projects-grid"> - {featured.map((project) => ( - <a - key={project.id} - href={`/projects/${project.id}`} - className="project-card" + <InView> + <motion.section + className="section container-wide" + aria-labelledby="projects-heading" + initial="hidden" + whileInView="visible" + viewport={{ once: true, amount: 0.1 }} + variants={{ + hidden: { opacity: 0 }, + visible: { + opacity: 1, + transition: { staggerChildren: 0.1 }, + }, + }} + > + <motion.div + style={{ + display: "flex", + justifyContent: "space-between", + alignItems: "baseline", + marginBottom: "48px", + }} + variants={{ + hidden: { opacity: 0, y: 30 }, + visible: { opacity: 1, y: 0, transition: { duration: 0.5 } }, + }} + > + <h2 id="projects-heading">Featured Projects</h2> + <MotionLink + to="/projects" + style={{ fontSize: "14px", fontWeight: 500, color: "var(--accent)" }} + whileHover={{ scale: 1.05 }} + whileTap={{ scale: 0.95 }} > - <div className="project-card-header"> - <h3>{project.title}</h3> - <Badge variant="outline"> - {categoryLabels[project.category] || project.category} - </Badge> - </div> - <p className="project-card-summary">{project.summary}</p> - <div className="project-card-techs"> - {project.technologies.slice(0, 4).map((tech) => ( - <span key={tech} className="tag"> - {tech} - </span> - ))} - </div> - {project.metrics && project.metrics.length > 0 && ( - <div className="project-card-metrics"> - {project.metrics.map((m) => ( - <span key={m} className="achievement-metric"> - {m} + View All → + </MotionLink> + </motion.div> + <div className="projects-grid"> + {featured.map((project, i) => ( + <MotionLink + key={project.id} + to={`/projects/${project.id}`} + className="project-card" + variants={{ + hidden: { opacity: 0, y: 30 }, + visible: { + opacity: 1, + y: 0, + transition: { duration: 0.5, delay: i * 0.1 }, + }, + }} + whileHover={{ scale: 1.02, y: -4 }} + whileTap={{ scale: 0.98 }} + > + <div className="project-card-header"> + <h3>{project.title}</h3> + <Badge variant="outline"> + {categoryLabels[project.category] || project.category} + </Badge> + </div> + <p className="project-card-summary">{project.summary}</p> + <div className="project-card-techs"> + {project.technologies.slice(0, 4).map((tech) => ( + <span key={tech} className="tag"> + {tech} </span> ))} </div> - )} - <span className="project-card-cta">View Details →</span> - </a> - ))} - </div> - </section> + {project.metrics && project.metrics.length > 0 && ( + <div className="project-card-metrics"> + {project.metrics.map((m) => ( + <span key={m} className="achievement-metric"> + {m} + </span> + ))} + </div> + )} + <span className="project-card-cta">View Details →</span> + </MotionLink> + ))} + </div> + </motion.section> + </InView> ) } diff --git a/src/components/ui/Button.tsx b/src/components/ui/Button.tsx index 8dc78d5..b938894 100644 --- a/src/components/ui/Button.tsx +++ b/src/components/ui/Button.tsx @@ -1,47 +1,97 @@ -import { forwardRef } from 'react' -import type { ComponentPropsWithoutRef } from 'react' +import { Link } from "react-router" +import { motion } from "motion/react" +import { forwardRef } from "react" +const MotionLink = motion.create(Link) +import type { ComponentPropsWithoutRef } from "react" -type ButtonVariant = 'primary' | 'secondary' | 'ghost' -type ButtonSize = 'sm' | 'md' | 'lg' +type ButtonVariant = "primary" | "secondary" | "ghost" +type ButtonSize = "sm" | "md" | "lg" -interface ButtonProps extends ComponentPropsWithoutRef<'button'> { +interface ButtonProps extends ComponentPropsWithoutRef<"button"> { variant?: ButtonVariant size?: ButtonSize href?: string - children: React.ReactNode + download?: boolean + target?: string } const variantClasses: Record<ButtonVariant, string> = { - primary: 'btn btn-primary', - secondary: 'btn btn-secondary', - ghost: 'btn btn-ghost', + primary: "btn btn-primary", + secondary: "btn btn-secondary", + ghost: "btn btn-ghost", } const sizeClasses: Record<ButtonSize, string> = { - sm: 'btn-sm', - md: '', - lg: 'btn-lg', + sm: "btn-sm", + md: "", + lg: "btn-lg", } export const Button = forwardRef< HTMLButtonElement | HTMLAnchorElement, ButtonProps ->(({ variant = 'primary', size = 'md', href, className = '', children, ...props }, ref) => { - const classes = `${variantClasses[variant]} ${sizeClasses[size]} ${className}`.trim() +>( + ( + { + variant = "primary", + size = "md", + href, + className = "", + children, + ...props + }, + ref + ) => { + const classes = `${variantClasses[variant]} ${sizeClasses[size]} ${className}`.trim() + + if (href) { + const isRoute = href.startsWith("/") + const safeProps = { ...props } + if (isRoute) { + delete (safeProps as Record<string, unknown>)["download"] + } + + if (isRoute) { + return ( + <MotionLink + to={href} + className={classes} + ref={ref as React.Ref<HTMLAnchorElement>} + whileTap={{ scale: 0.95 }} + {...(safeProps as Omit< + React.AnchorHTMLAttributes<HTMLAnchorElement>, + keyof ButtonProps | "to" + >)} + > + {children} + </MotionLink> + ) + } + + return ( + <motion.a + href={href} + className={classes} + ref={ref as React.Ref<HTMLAnchorElement>} + whileTap={{ scale: 0.95 }} + {...(props as Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof ButtonProps>)} + > + {children} + </motion.a> + ) + } - if (href) { return ( - <a href={href} className={classes} ref={ref as React.Ref<HTMLAnchorElement>} {...(props as React.AnchorHTMLAttributes<HTMLAnchorElement>)}> + <motion.button + className={classes} + ref={ref as React.Ref<HTMLButtonElement>} + whileTap={{ scale: 0.95 }} + {...(props as Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof ButtonProps>)} + > {children} - </a> + </motion.button> ) } +) - return ( - <button className={classes} ref={ref as React.Ref<HTMLButtonElement>} {...props}> - {children} - </button> - ) -}) - -Button.displayName = 'Button' +Button.displayName = "Button" diff --git a/src/components/ui/InView.tsx b/src/components/ui/InView.tsx new file mode 100644 index 0000000..aedc2d6 --- /dev/null +++ b/src/components/ui/InView.tsx @@ -0,0 +1,30 @@ +import { motion, type MotionProps } from "motion/react" +import type { ReactNode } from "react" + +interface InViewProps extends Omit<MotionProps, "children"> { + children: ReactNode + delay?: number + threshold?: number + className?: string +} + +export function InView({ + children, + delay = 0, + threshold = 0.1, + className, + ...props +}: InViewProps) { + return ( + <motion.div + className={className} + initial={{ opacity: 0, y: 30 }} + whileInView={{ opacity: 1, y: 0 }} + viewport={{ once: true, amount: threshold }} + transition={{ duration: 0.5, delay }} + {...props} + > + {children} + </motion.div> + ) +} diff --git a/src/components/ui/RollingTextLink.tsx b/src/components/ui/RollingTextLink.tsx new file mode 100644 index 0000000..57f7f77 --- /dev/null +++ b/src/components/ui/RollingTextLink.tsx @@ -0,0 +1,122 @@ +import { Link } from "react-router" +import { motion, useReducedMotion } from "motion/react" +import { useRef, useState } from "react" + +const outgoingVariants = { + rest: { transform: "translateY(0%)" }, + active: { transform: "translateY(100%)" }, +} + +const incomingVariants = { + rest: { transform: "translateY(-100%)" }, + active: { transform: "translateY(0%)" }, +} + +const transition = { + duration: 0.3, + ease: [0.338, 0.015, 0.395, 0.959] as const, +} + +interface RollingTextLinkProps { + to: string + className?: string + onClick?: () => void + children: React.ReactNode +} + +export function RollingTextLink({ to, className, onClick, children }: RollingTextLinkProps) { + const reduceMotion = useReducedMotion() + const [active, setActive] = useState(false) + const activeRef = useRef(false) + const animating = useRef(false) + const pendingRequest = useRef<boolean | null>(null) + const hovered = useRef(false) + const focused = useRef(false) + + const updateActive = (next: boolean) => { + activeRef.current = next + setActive(next) + } + + const requestActive = (next: boolean) => { + if (reduceMotion) return + + if (next === activeRef.current) { + pendingRequest.current = null + return + } + + if (animating.current) { + pendingRequest.current = next + return + } + + animating.current = true + updateActive(next) + } + + const completeAnimation = () => { + if (!animating.current) return + animating.current = false + + if (pendingRequest.current !== null && pendingRequest.current !== activeRef.current) { + const next = pendingRequest.current + pendingRequest.current = null + animating.current = true + updateActive(next) + } else { + pendingRequest.current = null + } + } + + return ( + <Link + to={to} + className={className} + onClick={onClick} + onPointerEnter={() => { + hovered.current = true + requestActive(true) + }} + onPointerLeave={() => { + hovered.current = false + requestActive(focused.current) + }} + onFocus={() => { + focused.current = true + requestActive(true) + }} + onBlur={() => { + focused.current = false + requestActive(hovered.current) + }} + > + <span style={{ position: "relative", display: "inline-block", overflow: "hidden" }}> + <motion.span + style={{ display: "block", whiteSpace: "nowrap" }} + variants={outgoingVariants} + initial="rest" + animate={active ? "active" : "rest"} + onAnimationComplete={completeAnimation} + transition={transition} + > + {children} + </motion.span> + <motion.span + style={{ + display: "block", + whiteSpace: "nowrap", + position: "absolute", + inset: 0, + }} + variants={incomingVariants} + initial="rest" + animate={active ? "active" : "rest"} + transition={transition} + > + {children} + </motion.span> + </span> + </Link> + ) +} diff --git a/src/components/ui/SocialLinks.tsx b/src/components/ui/SocialLinks.tsx index 5c356be..63f1be6 100644 --- a/src/components/ui/SocialLinks.tsx +++ b/src/components/ui/SocialLinks.tsx @@ -1,8 +1,10 @@ +import { motion } from "motion/react" + interface SocialLink { label: string href: string icon: React.ReactNode - 'aria-label': string + "aria-label": string } interface SocialLinksProps { @@ -10,21 +12,23 @@ interface SocialLinksProps { className?: string } -export function SocialLinks({ links, className = '' }: SocialLinksProps) { +export function SocialLinks({ links, className = "" }: SocialLinksProps) { return ( <div className={`social-links ${className}`}> {links.map((link) => ( - <a + <motion.a key={link.label} href={link.href} target="_blank" rel="noopener noreferrer" className="social-link" - aria-label={link['aria-label']} + aria-label={link["aria-label"]} + whileHover={{ scale: 1.1 }} + whileTap={{ scale: 0.9 }} > {link.icon} <span>{link.label}</span> - </a> + </motion.a> ))} </div> ) diff --git a/src/data/profile.ts b/src/data/profile.ts index 8082205..d67ddce 100644 --- a/src/data/profile.ts +++ b/src/data/profile.ts @@ -1,7 +1,7 @@ import type { Profile } from "@/types"; export const profile: Profile = { - name: "Your Name", + name: "Dong Nguyen", title: "Senior Software Engineer", tagline: "Building scalable software systems,\nintelligent logistics solutions,\nand practical AI applications.", diff --git a/src/data/resume.ts b/src/data/resume.ts new file mode 100644 index 0000000..3fde682 --- /dev/null +++ b/src/data/resume.ts @@ -0,0 +1 @@ +export const resumeAvailable = true diff --git a/src/index.css b/src/index.css index 896a5b8..47ccbae 100644 --- a/src/index.css +++ b/src/index.css @@ -215,6 +215,21 @@ pre code { .section { padding: 48px 0; } + .container-wide, + .container-content, + .container-narrow { + padding-left: 32px; + padding-right: 32px; + } +} + +@media (min-width: 769px) and (max-width: 1200px) { + .container-wide, + .container-content, + .container-narrow { + padding-left: 40px; + padding-right: 40px; + } } /* Scroll reveal animation */ @@ -229,6 +244,7 @@ pre code { } } + .animate-in { animation: fadeInUp var(--transition-slow) ease forwards; } diff --git a/src/main.tsx b/src/main.tsx index bef5202..317fe21 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,8 +1,13 @@ +import { motion } from 'motion/react' import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' import './index.css' import App from './App.tsx' +// motion v14 has motion.config for reducedMotion but TS types don't expose it +const motionWithConfig = motion as any +motionWithConfig.config.reducedMotion = 'user' + createRoot(document.getElementById('root')!).render( <StrictMode> <App /> diff --git a/src/pages/ContactPage.tsx b/src/pages/ContactPage.tsx index effc2da..63c9fd1 100644 --- a/src/pages/ContactPage.tsx +++ b/src/pages/ContactPage.tsx @@ -1,3 +1,4 @@ +import { DownloadResume } from '@/components/sections/DownloadResume' import { profile } from '@/data/profile' export function ContactPage() { @@ -36,6 +37,7 @@ export function ContactPage() { </div> </a> </div> + <DownloadResume /> </section> ) } diff --git a/src/pages/ProjectDetailPage.tsx b/src/pages/ProjectDetailPage.tsx index d275658..338ef87 100644 --- a/src/pages/ProjectDetailPage.tsx +++ b/src/pages/ProjectDetailPage.tsx @@ -1,4 +1,4 @@ -import { useParams, Link } from 'react-router-dom' +import { useParams, Link } from 'react-router' import { Badge } from '@/components/ui/Badge' import { Tag } from '@/components/ui/Tag' import { projects } from '@/data/projects'