feat(nav): resume entry in the bar with a shared language dialog

ResumeNavButton is the third item in .nav-brand, right after the home icon: a 44px icon target named by strings.nav.resume, aria-haspopup=dialog on its own #resume-modal-nav, gated on resumeAvailable.

The picker markup is no longer duplicated. ResumeDialog owns the overlay, panel and resumeLanguages options and takes a dialogId, so the hero keeps #resume-modal and the bar gets #resume-modal-nav. useResumeDialog holds the state both triggers share: open flag, container/trigger/panel refs, click-outside (close guarded on openRef, because the listener is live while closed and otherwise steals focus on every page click), Escape, body-overflow lock and focus return. Panel focus moved from onAnimationComplete to a one-frame effect: AnimatePresence keeps open=true on the exiting copy, so the old handler refired at the end of the exit and stranded focus on <body>. resumeAvailable now gates the leaf components, so Hero renders <DownloadResume /> plainly.
This commit is contained in:
dong.nguyen committed 2026-10-20 00:33:28 +07:00
1 parent 25b0ead76a
commit 4f1d4ebe30
8 files changed
+224 -90

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
import { resumeAvailable } from '@/data/resume'
import { useLanguage } from '@/hooks/useLanguage'
import { useResumeDialog } from '@/hooks/useResumeDialog'
import { ResumeDialog } from '@/components/ui/ResumeDialog'
import { ResumeIcon } from '@/components/ui/icons'
import { strings } from '@/i18n/strings'
/**
* Bar entry for the resume: an icon-only `.nav-control` in the brand group, right after the home
* icon, opening the same language dialog the hero CTA opens. The icon is decorative — the
* accessible name is the translated action in `aria-label`, the hint is the `title`.
*/
export function ResumeNavButton() {
const { lang } = useLanguage()
const { open, openDialog, close, containerRef, triggerRef, panelRef } = useResumeDialog()
if (!resumeAvailable) return null
return (
<div ref={containerRef} className="nav-resume">
<button
ref={triggerRef}
type="button"
className={`nav-control nav-resume-trigger ${open ? 'open' : ''}`}
aria-haspopup="dialog"
aria-expanded={open}
aria-controls="resume-modal-nav"
aria-label={strings.nav.resume[lang]}
title={strings.common.resumeModalHint[lang]}
onClick={openDialog}
>
<ResumeIcon />
</button>
<ResumeDialog open={open} close={close} panelRef={panelRef} dialogId="resume-modal-nav" />
</div>
)
}