mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
- Extract SunIcon/MoonIcon from the bar theme control into src/components/ui/icons.tsx (exact geometry and attributes, so the bar renders identically) - MobileMenu Mode row: Dark option draws MoonIcon, Light draws SunIcon in the .mobile-menu-icon-option square the Language and Theme color rows use, aria-pressed + translated aria-label/title - Delete .mobile-menu-segment-option (3 rule groups) from App.css — last user gone - AGENTS.md picker paragraph, spec-v3-mobile-navigation.md (Q18 + progress row), spec-v3-i18n.md cross-reference updated
21 KiB
21 KiB
Agent Guidelines — portfolio
Project
Personal engineering portfolio — multi-page SPA built with React + TypeScript + Vite. Data-driven content from src/data/, styled with CSS variables supporting dark/light themes. Motion animations via motion/react. Bilingual resume generation (EN/VI).
Tech Stack
| Layer | Tool |
|---|---|
| Framework | React 19 |
| Language | TypeScript 6 (bundler mode, verbatimModuleSyntax, noEmit) |
| Bundler | Vite 8 |
| Router | React Router v8 (react-router package, pinned 8.4.0) |
| Animation | motion ^14.0.0 (motion/react ESM entrypoint) |
| Linter | Oxlint 1 (plugins: react, typescript, oxc) |
| Resume generation | playwright ^1.64.0, tsx ^4.23.15 |
| Package manager | pnpm |
Commands
| Command | Description |
|---|---|
pnpm dev |
Start dev server with HMR |
pnpm build |
Type-check (tsc -b), build for production, then generate dist/sitemap.xml |
pnpm build:resume |
Generate resume PDF (default EN) via Playwright |
pnpm build:resume-all |
Generate bilingual resume PDFs (EN + VI) |
pnpm lint |
Run Oxlint |
pnpm sitemap |
Regenerate dist/sitemap.xml on its own (also run by pnpm build) |
pnpm preview |
Preview production build locally |
Routing
App.tsxwraps<BrowserRouter>→<Layout>→<Routes>(NOT nested<Route element>— causeschildrennot to pass)- Layout:
<Navigation>(top) →<main id="main-content">→<Footer>(bottom) - All internal navigation MUST use
<Link>/<NavLink>, never<a href>(causes full page reload) - Footer internal links also use
<Link>; external links (GitHub, LinkedIn, email) keep<a>withtarget="_blank" - Route-level splitting:
HomePageis imported eagerly because it owns the LCP; the other six pages load throughReact.lazyinside one<Suspense fallback={null}>boundary inApp.tsx. Pages export named components, so each factory maps the named export todefault
Pages
| Route | Component | Section |
|---|---|---|
/ |
HomePage |
Hero + About + Expertise + Experience + Projects + Contact |
/about |
AboutPage |
Full about section |
/experience |
ExperiencePage |
Timeline |
/projects |
ProjectsListPage |
All projects grid |
/projects/:id |
ProjectDetailPage |
Single project |
/contact |
ContactPage |
Contact info |
/philosophy |
PhilosophyPage |
Engineering philosophy |
Theming
- Two independent axes on
<html>: lightness (Theme) and color (Palette), both written during render before paint src/hooks/useTheme.tsx—ThemeProvider+useThemehook, carries both axes- Simple toggle:
'dark'↔'light'(nosystemvariant);resolvedTheme— runtime resolved value (always'dark'or'light') data-themeattribute +localStoragekeyportfolio-themetype Palette = 'red' | 'blue'(src/types/index.ts), labels/hints insrc/data/palettes.ts(paletteIds,paletteMeta); defaultreddata-paletteattribute +localStoragekeyportfolio-palette;index.html's init script writes both attributes before paint- Palette overrides in
src/index.cssare:root[data-theme='dark'][data-palette='blue']/:root[data-theme='light'][data-palette='blue'](specificity 0,3,0 — they beat the base blocks regardless of order); no blue variant exists in theprefers-color-schemebridge, because the init script always writesdata-palette - Accent has two tiers:
--accent/--accent-hover/--accent-activeare the bright signal colours (links, underlines, borders, glows) and the fill of the pale accent surfaces (palette-option hover,.tag-accent,.back-to-top, resume summary bar);--accent-solid/-hover/-activeplus--text-on-accent-solidare the deeper fill and light text used by.btn-primaryand.badge-accent, which is what lets a dark-mode button carry light text. The solid family is declared in all five blocks ofsrc/index.css(dark red, light red, dark blue, light blue, theprefers-color-schemebridge); the two light blocks duplicate the plain accent values verbatim, so light mode does not move. Spec:docs/design/specs/v3/spec-v3-nav-cta-enhancements.md - Picker, two renderings, both present at every width: the bar uses
src/components/layout/ThemePaletteMenu.tsx— icon-only trigger (nav-control nav-palette-trigger, a 20px half-circle swatch: active palette's accent on the left,--swatch-emptyon the right; no text, no chevron; the name lives inaria-label, the hint intitle) opening the#palette-menupanel. The sheet renders its own Theme color row insideMobileMenu.tsxfrompaletteIds+paletteMetaas.mobile-menu-icon-optionbuttons — the 44px icon-only square the Language row shares; the Mode row renders the same squares with the bar's own mode line art —MoonIconfor dark,SunIconfor light, both fromsrc/components/ui/icons.tsxand shared with the bar's theme control — each option naming its mode inaria-label/title.ThemePaletteMenuhas novariantprop and is never mounted in the sheet - Preview chips are theme-aware:
--preview-red-accent/--preview-blue-accentare declared per theme —:rootdark pair,:root[data-theme='light']light pair, repeated in theprefers-color-schemebridge — and mirror that block's--accent, so a submenu dot and the bar swatch's accent half are the same colour in the same theme. Each chip names its own palette throughdata-preview, so the two[data-palette='blue']blocks declare no preview token;--swatch-emptystays one constant. Spec:docs/design/specs/v3/spec-v3-nav-swatch-and-hamburger.md - Bar controls share one chrome:
.nav-controlcovers the language toggle, the mode toggle and the palette trigger (44px bordered box, accent border + icon on hover/open, one:focus-visible). The hamburger leads the bar at every width it appears:.nav-brand(display: flex; gap: 4px— its icons carry no borders, so the spacing reads between glyphs: 4px between 44px targets is 24px between the 24px glyphs, a tight brand cluster while hover fills and 2px-offset focus rings stay clear) holds it first and the brand home icon right after, at the bar's left edge —.nav-logois a 24px stroke house in a 44px target, a<Link to="/">named by the translatedstrings.nav.homelabel with the svgaria-hidden, so it carries its own:focus-visiblering. Third in the brand group is the resume entry —src/components/layout/ResumeNavButton.tsx, anav-control nav-resume-trigger44px target that carries no border (border-color: transparentat rest, on hover and while open, because it sits beside the borderless home icon; the hover fill and the:focus-visiblering stay; its glyph is--accentat every state — rest, hover, open — so the entry always carries the active theme's signal colour and follows the palette switch), holdingResumeIcon size={24}— the same 24px the home glyph beside it uses, so the two brand icons share a size inside their 44px targets — the resume document glyph frompublic/cv-icon.svg, the owner's 30-grid CV artwork adapted to the bar's 24-grid (spec follow-up 19): a page outline split on the left edge by a visible dash (M14 2 H6 a2 2 0 0 0 -2 2 V6+M4 10 V12+M4 16 v4 a2 2 0 0 0 2 2 h12 a2 2 0 0 0 2 -2 V8 L14 2; 4px endpoint gaps stay open under 2px round caps), a folded corner (M14 2 v4 a2 2 0 0 0 2 2 h4), and stroked CV lettering replacing the content lines (M9.5 12 A3 3 0 0 0 9.5 18+M12.5 12 L15 18 L17.5 12), in the bar's 2px stroke language; at 1:1 the strokes are exactly 2px and the lettering reads clearly in both themes. Named bystrings.nav.resume,aria-haspopup="dialog"on its own#resume-modal-nav;.nav-resumeis the wrapper that ties trigger to dialog and is whatuseClickOutsidewatches..nav-actionsthen carries the three appearance controls in that order (language, mode, theme color) at the right end, their bordered boxes keeping the 16px gap. The sheet's Appearance group follows the same order (Language row, Mode row, Theme color row). Six controls now share the bar at ≤1024px:@media (max-width: 420px)keeps 16px padding and drops only the action gap to 8px — the brand group stays at 4px at every width —@media (max-width: 360px)drops the padding to 12px — 40 + 44×5 = 260px of controls plus 2×4px brand gaps plus 2×8px action gaps = 284px inside 296px, and every target stays 44px - Language control is icon-only in both renderings —
src/components/ui/LanguageIcon.tsxdraws both languages as line art in the bar's stroke language (currentColor, no fills): English a 20px globe (circle r=10 + equator + meridian ellipse, 2px round joins, so it follows the control's hover accent), Tiếng Việt a flag outline (21×17.5 bandrx=2at 1.5/3.25 — drawn 23×19.5 against the globe's 22×22; width is already at the limit, so the size step came from height, which drags the constitutional 2:3 to 1.2 — with a centred five-point mullet at r=3.6, deliberately smaller than the flag's own 0.6 × height construction, stroked 1.5px round joins so its interior stays open). The bar'snav-control lang-toggleshows the language it switches TO (lang === 'en' ? 'vi' : 'en'): translated action inaria-label, the target's own-language name intitle..lang-togglenow carries no CSS rules of its own — it marks the button in the DOM and nothing else. The sheet's Language row uses.mobile-menu-icon-optionsquares witharia-pressedand the own-languagearia-label/title. Spec:docs/design/specs/v3/spec-v3-i18n.md
Data Layer
src/data/profile.ts— name, title, bio, links, social handles (githubHandle,linkedinHandle,telegramHandle), messaging URLs (telegramUrl) — the Contact cards render@{profile.githubHandle}, never a literalsrc/data/skills.ts— skill groups → skillssrc/data/experience.ts— work history entries; optionalvariant: 'current' | 'gap'selects the timeline decoration (live node / career break)src/data/projects.ts— project cards with categoriessrc/data/resume.ts— resume availability, supported languages, URL generation, andresumeQr(the{id, file, label}descriptors the resume header renders as QR codes)src/data/navigation.ts—navPaths(bar + sheet order: Home, About, Experience, Projects, Contact, Philosophy),footerPathssrc/data/social.ts— social tiles as{id, href, external}(github, linkedin, email, telegram);emailis amailto:link withexternal: false, so it renders notarget/relsrc/i18n/strings.ts— every chrome string as{en, vi}; the sheet's group labels, the Mode options, the language names (langEn/langVi, each named in its own language) and the language action labels (langSwitch,switchTo) live instrings.nav, the socialaria-labels instrings.socialsrc/data/site.ts—siteUrl(the canonical origin) andsiteName; every absolute URL the site publishes — canonical, Open Graph, JSON-LD,robots.txt,sitemap.xml— derives from itsrc/i18n/field.ts—field(lang, value, valueEn)is a plain function, not a hook:langis read once at component top level withuseLanguage(), so bilingual selection is legal inside.map()callbacks. Convention:valueis Vietnamese,valueEnEnglish
Component Structure
src/
components/
layout/ — Layout.tsx, Navigation.tsx, MobileMenu.tsx, Footer.tsx, ThemePaletteMenu.tsx, ResumeNavButton.tsx
sections/ — Hero, About, Expertise, Experience, Projects, Contact, HeroParticles, DownloadResume (the hero lazer CTA; it gates itself on `resumeAvailable`)
ui/ — Badge, Button, ContactLinks, LanguageIcon, ResumeDialog, SectionHeading, SocialLinks, Tag, Typewriter, InView, RollingTextLink, BackToTop, icons
data/ — profile, skills, experience, projects, resume, palettes, navigation, social, site (TS modules)
hooks/ — useTheme.tsx, useLanguage.tsx, useClickOutside.ts, useResumeDialog.ts
pages/ — HomePage, AboutPage, ExperiencePage, ProjectsListPage, ProjectDetailPage, PhilosophyPage, ContactPage
types/ — shared TypeScript interfaces
Motion & Animation
motion/reactv14 — ESM-first entrypoint (NOTframer-motion)- Section entrance recipe — every section (
Hero,About,Expertise,Experience,Projects,Contact) and every standalone page:InViewwrapping amotion.sectionwithinitial="hidden" whileInView="visible",viewport={{ once: true, amount: 0.1 }}andvariantshidden: { opacity: 0 }/visible: { opacity: 1, transition: { duration: 0.5 } } - Item recipe (timeline entries, philosophy/expertise/project cards, hero content blocks, contact links, project-detail blocks):
motion.*withinitial={{ opacity: 0, y: 24 }},whileInView={{ opacity: 1, y: 0 }},viewport={{ once: true, amount: 0.2 }},transition={{ duration: 0.45, ease: 'easeOut', delay: i * 0.08 }} - Hover/press recipe — motion owns the transform, CSS
:hoveronly colour/border/shadow: cards and links (.project-card,.expertise-card,.philosophy-card,.contact-link) usewhileHover={{ scale: 1.02, y: -4 }}+whileTap={{ scale: 0.98 }};ButtonuseswhileHover={{ y: -2 }}+whileTap={{ scale: 0.95 }};.social-linktiles usescale: 1.1/0.9. A motion-animated element never carries a CSStransformortransition: all InView.tsx— viewport intersection observer motion componentRollingTextLink.tsx— animated text-scrolling navigation linkBackToTop.tsx— scroll-to-top floating button with AnimatePresenceHeroParticles.tsx— decorative particle background (uses AnimatePresence)- Palette swatch rotation —
ThemePaletteMenu.tsxrenders the swatch as amotion.spanwhoserotatetarget is 90° while the#palette-menusubmenu is open and 0° otherwise; reduced motion comes from the globalmotion.config.reducedMotion = 'user'inmain.tsx, so no per-component branch
External Assets
public/fonts/— Source Sans 3 woff2 (Regular, Medium, Semibold, Bold); used by the resume generator only — the SPA renderssystem-uipublic/resume-template.html— HTML template for resume PDF generationpublic/resume-logos/— official company logo SVGs (Lazada, SAP from Wikimedia Commons), embedded in the resume timeline viaExperienceEntry.logopublic/resume-qr/— owner-supplied QR images (telegram.jpg,zalo.jpg) embedded in the resume header viaresumeQrinsrc/data/resume.ts; committed like the other resume assets, so CI renders the QR block too — a missing file prints a warning and that QR is skippedpublic/profile-photo.webp— profile photopublic/robots.txt— allow-all crawler rules plus theSitemap:pointer to the canonical originpublic/cv-icon.svg— canonical CV document glyph (24 grid, 2pxcurrentColorstroke, no fills): a split page outline with a visible left-edge dash, a folded corner, and stroked CV lettering;ResumeIconinsrc/components/ui/icons.tsxinlines the same geometry because the bar icon must inherit the control's colour — an<img>resolvescurrentColorto black and cannot follow the theme
Scripts
scripts/generate-resume.ts— Playwright-based PDF resume generator (bilingual en/vi)scripts/generate-sitemap.ts— writesdist/sitemap.xmlfromsrc/data/site.ts,navPathsand the project list; fails ifdist/is missing or ifdist/index.htmlno longer containssiteUrl
Deployment
- Deployment is triggered automatically by gitea workflow
.gitea/workflows/deploy.yml - Three jobs:
build(pnpm build→dist/artifact) →generate-resume(pnpm tsx scripts/generate-resume.ts --lang=en, then--lang=vi) →deployrsyncsdist/, both PDFs included, to/opt/stacks/dong-site/dist/ nginx.conf— production Nginx SPA routing + caching configdocker-compose.yaml— Docker service for local nginx deployment
.gitea/
└── workflows/
└── deploy.yml
nginx.conf
docker-compose.yaml
CSS Architecture
src/index.css— CSS variables (:rootdark default,[data-theme="light"], plus aprefers-color-scheme: lightbridge), global resets, typography scalesrc/App.css— component-level styles (Navigation, Footer, page sections)- No CSS library — plain CSS with variables for theming
#main-contentin Layout hasstyle={{ flex: 1 }}(parent#rootisdisplay: flex; flex-direction: column)
Typography
- Scale tokens in
src/index.css:--text-body: 18px,--text-lede: 20px,--text-meta: 15px,--leading-body: 1.65,--measure-prose: 600px,--measure-page: 680px - Global:
p=--text-body/--leading-body;h321px,h418px,h516px,h615px - Two measures:
.prose(600px) for long-form narrative,.prose-wide(680px, body steps up to--text-lede) for page-length prose. A lead paragraph uses.prose-lede(600px), or.prose-lede lede-wide(680px) when it sits next to a full-width grid. Non-prose columns use.page-body(--measure-page); titles inside a column use.subheading - Cards and grids take the full container width; text columns do not.
/aboutand the homepage About section usecontainer-widewith.philosophy-gridat 3 columns (2 at ≤1024px, 1 at ≤768px), the same model as.expertise-grid - Body copy sizes come from the tokens; 12-14px literals are reserved for chrome (tags, badges, pills, footer, duration labels)
- Components MUST NOT set
fontSize/lineHeightinline — use the classes above - Font stack is
system-ui: no webfont is loaded by the SPA. The Source Sans 3 woff2 files inpublic/fonts/are consumed only byscripts/generate-resume.ts - Spec:
docs/design/specs/v3/spec-v3-typography.md
Known Issues & Gotchas
- React Router v8 routing: Use
<Layout><Routes>...</Routes></Layout>, NOT<Route element={<Layout />}>with nested routes — the latter doesn't passchildrencorrectly - Import path: All router imports use
react-router(notreact-router-dom) — e.g.,import { Link, useLocation } from 'react-router' - Animation imports: Use
motion/react(v14 ESM), NOTframer-motion— e.g.,import { motion, AnimatePresence } from 'motion/react' - Footer/Nav links: Must use
<Link to>, not<a href>for client-side navigation - Bilingual plumbing is done, the content is not:
field(lang, value, valueEn)resolves correctly, but most content has no second language —skills.tsgroup titles are identical in both languages,projects.tstitles differ for 1 of 4 projects, androle/technologies/metrics/duration/companyinexperience.tshave no*Envariants at all. Translating means adding data, never changing a component lazy()needs a default export: pages export named components, so each factory must map{ default: m.XPage }— a bareimport('@/pages/XPage')failstscwithTS2322: Property 'default' is missing. There is nosrc/pages/index.tsbarrel: importing it would pull every route back into the entry chunk- A locked
dist/resume*.pdfblocks the build: while a generated PDF is open in a viewer,pnpm build:resume-allfails withEBUSYon that file andpnpm buildfails too (viteemptyDir→EPERM). Close the viewer first
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) |
specs/v3/spec-v3-*.md |
v3 feature specs (theme colors, theme switch, theme palette switch, palette reference, UI enhancements, mobile navigation, nav & CTA enhancements, nav swatch & hamburger, typography, i18n, resume improvements, resume redesign, review fixes) |
Read spec.md first for product context. Read spec-v2.md for current feature scope.
Specification Rules
When proposing or implementing changes, always include these 3 sections:
1. Implementation Details
- Describe every code step: what to write, edit, or delete
- List new imports, functions, props, state, CSS classes
- Identify edge cases and error handling
2. Affected Files
- File + line range to edit:
src/foo.ts:42-57 - New file to create:
src/bar.ts - File to delete:
src/dead.ts
3. Progress Tracking
- Update relevant spec with status:
TODO/IN_PROGRESS/DONE - Record which acceptance criteria were verified
- Format: checklist in spec or inline code comments
Code Style & Linting
- TypeScript:
verbatimModuleSyntax,noUnusedLocals,noUnusedParameters,noFallthroughCasesInSwitch - Oxlint:
react/rules-of-hooks= error,react/only-export-components= warn - No framework-specific CSS library — plain CSS with CSS variables
- Data-driven: all content from TS modules, not hardcoded in JSX