// Header — fixed nav (logo left, menu + CTA right) // 전 페이지 공용. props: // active — 'home' | 'service' | 'case' // onCtaClick — 있으면 CTA가 이걸 호출, 없으면 랜딩 #cta로 이동 const HOME_HREF = '/'; const Header = ({ onCtaClick, active = 'home', theme = 'dark' }) => { const [scrolled, setScrolled] = React.useState(false); const [menuOpen, setMenuOpen] = React.useState(false); React.useEffect(() => { const onScroll = () => setScrolled(window.scrollY > 8); window.addEventListener('scroll', onScroll, { passive: true }); return () => window.removeEventListener('scroll', onScroll); }, []); const navItems = [ { label: '서비스', href: 'service.html', key: 'service' }, { label: '성과 사례', href: 'case.html', key: 'case' }, ]; const handleCta = () => { setMenuOpen(false); if (onCtaClick) onCtaClick(); else window.location.href = HOME_HREF + '#cta'; }; // 스크롤 상태이거나 모바일 메뉴가 열려 있으면 어두운 글자 / 흰 배경 const solid = scrolled || menuOpen; // 밝은 배경 페이지(홈)는 스크롤 전에도 어두운 글자 const darkText = solid || theme === 'light'; return (
{/* Logo */} { if (active === 'home') { e.preventDefault(); window.scrollTo({ top: 0, behavior: 'smooth' }); } }} style={{ display: 'flex', alignItems: 'center', gap: '0.625rem' }}> Sync-On Sync-On {/* 데스크탑 — nav + CTA */}
{/* 모바일 — 햄버거 버튼 */}
{/* 모바일 슬라이드 메뉴 */}
{navItems.map((it) => { const isActive = it.key === active; return ( setMenuOpen(false)} style={{ fontSize: '1.0625rem', fontWeight: isActive ? 700 : 500, color: isActive ? 'var(--orange-500)' : 'var(--navy-800)', padding: '0.875rem 0.25rem', borderBottom: '0.5px solid var(--line-100)' }}>{it.label}); })}
); }; window.Header = Header;