Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : agentilab-web8 * File : components/layout/Header.tsx9 * Module : User Interface10 * Repository : https://git.spboucher.ai/agentilab-web11 * Project Website : Not specified12 * Created : 2026-12-0513 * Last Modified : 2026-12-0514 *15 * Author : Simon-Pierre Boucher16 * Position : Professor of Finance17 * Institution : Université du Québec en Outaouais (UQO)18 * Organization : SP Boucher19 * Website : https://spboucher.ai20 * Git : https://git.spboucher.ai21 *22 * Preferred Contact: contact@spboucher.ai23 * Development : dev@spboucher.ai24 * Support : support@spboucher.ai25 * Security/Admin : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License : Proprietary34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243import Link from 'next/link';44import type { Locale } from '@/lib/i18n/config';45import { languageTag } from '@/lib/i18n/config';46import { getCopy } from '@/lib/i18n/copy';47import { href, trail } from '@/lib/i18n/routes';48import type { RouteId } from '@/lib/i18n/routes';49import { LogoMark } from '@/components/ui/Logo';50import { SHORT_NAME } from '@/lib/site';51import { MobileNav } from './MobileNav';5253const NAV: RouteId[] = ['company', 'ecosystem', 'technologies', 'contact'];5455interface HeaderProps {56 locale: Locale;57 /** Page courante ; null sur la 404. */58 current: RouteId | null;59}6061export function LanguageSwitcher({ locale, current, className = 'lang' }: HeaderProps & { className?: string }) {62 const copy = getCopy(locale);63 const other: Locale = locale === 'fr' ? 'en' : 'fr';64 // Le sélecteur mène à la page équivalente, jamais à l’accueil par défaut.65 const target = href(current ?? 'home', other);66 return (67 <a className={className} href={target} hrefLang={languageTag[other]} lang={languageTag[other]}>68 {className === 'lang' ? (69 <>70 {/* Repère visuel « FR / EN » ; le nom accessible est la phrase complète, dans la langue de destination. */}71 <span aria-hidden="true">72 <span className={locale === 'fr' ? 'lang__on' : undefined}>FR</span>73 <span className="lang__sep"> / </span>74 <span className={locale === 'en' ? 'lang__on' : undefined}>EN</span>75 </span>76 <span className="sr-only">{copy.nav.switchToLong}</span>77 </>78 ) : (79 copy.nav.switchTo80 )}81 </a>82 );83}8485export function Header({ locale, current }: HeaderProps) {86 const copy = getCopy(locale);87 const active = current ? trail(current) : [];88 const items = NAV.map((id) => ({89 id,90 label: copy.nav[id as 'company' | 'ecosystem' | 'technologies' | 'contact'],91 href: href(id, locale),92 // La page elle-même est « page » ; une page parente reste repérable sans mentir sur la page courante.93 current: current === id ? ('page' as const) : active.includes(id) ? ('true' as const) : undefined,94 }));9596 return (97 <header className="header">98 <div className="container header__bar">99 <Link href={href('home', locale)} className="logo" aria-label={copy.nav.homeLogo}>100 <LogoMark />101 <span>{SHORT_NAME}</span>102 </Link>103 <nav className="nav" aria-label={copy.nav.primary}>104 <ul>105 {items.map((item) => (106 <li key={item.id}>107 <Link href={item.href} aria-current={item.current}>108 {item.label}109 </Link>110 </li>111 ))}112 </ul>113 </nav>114 <div className="header__end">115 <LanguageSwitcher locale={locale} current={current} />116 <MobileNav menuLabel={copy.nav.menu} openLabel={copy.nav.openMenu} closeLabel={copy.nav.closeMenu}>117 <nav aria-label={copy.nav.primary}>118 <ul>119 <li>120 <Link href={href('home', locale)} aria-current={current === 'home' ? 'page' : undefined}>121 {copy.nav.home}122 </Link>123 </li>124 {items.map((item) => (125 <li key={item.id}>126 <Link href={item.href} aria-current={item.current}>127 {item.label}128 </Link>129 </li>130 ))}131 </ul>132 <LanguageSwitcher locale={locale} current={current} className="mnav__lang" />133 </nav>134 </MobileNav>135 </div>136 </div>137 </header>138 );139}140