Files
Portfolio-Codex/templates/navbar.php
2026-02-04 16:54:25 +01:00

84 lines
3.7 KiB
PHP

<?php
/**
* Template Navbar
* Variables disponibles :
* - $currentPage (string) : identifiant de la page active
*/
$currentPage = $currentPage ?? 'home';
$navLinks = [
['id' => 'home', 'label' => 'Accueil', 'url' => '/'],
['id' => 'projects', 'label' => 'Projets', 'url' => '/projets'],
['id' => 'skills', 'label' => 'Compétences', 'url' => '/competences'],
['id' => 'about', 'label' => 'Me Découvrir', 'url' => '/a-propos'],
['id' => 'contact', 'label' => 'Me contacter', 'url' => '/contact', 'isCta' => true],
];
?>
<header id="navbar" class="fixed top-0 left-0 right-0 z-50 bg-background/95 backdrop-blur-sm border-b border-border/50 transition-shadow duration-300">
<nav class="container-content" aria-label="Navigation principale">
<div class="flex items-center justify-between h-16 lg:h-20">
<a href="/" class="text-xl font-bold text-text-primary hover:text-primary transition-colors">
Portfolio
</a>
<ul class="hidden lg:flex items-center gap-1">
<?php foreach ($navLinks as $link): ?>
<?php if (!empty($link['isCta'])): ?>
<li class="ml-4">
<a href="<?= $link['url'] ?>" class="btn-primary text-sm">
<?= $link['label'] ?>
</a>
</li>
<?php else: ?>
<li>
<a href="<?= $link['url'] ?>"
class="nav-link <?= $currentPage === $link['id'] ? 'nav-link-active' : '' ?>">
<?= $link['label'] ?>
</a>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<button
id="mobile-menu-toggle"
class="lg:hidden p-2 text-text-primary hover:text-primary transition-colors"
aria-label="Ouvrir le menu"
aria-expanded="false"
aria-controls="mobile-menu"
>
<svg class="w-6 h-6 hamburger-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"/>
</svg>
<svg class="w-6 h-6 close-icon hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
</button>
</div>
<div id="mobile-menu" class="lg:hidden hidden" aria-hidden="true">
<ul class="py-4 space-y-2 border-t border-border">
<?php foreach ($navLinks as $link): ?>
<?php if (!empty($link['isCta'])): ?>
<li class="pt-2 border-t border-border mt-2">
<a href="<?= $link['url'] ?>" class="btn-primary w-full justify-center">
<?= $link['label'] ?>
</a>
</li>
<?php else: ?>
<li>
<a href="<?= $link['url'] ?>"
class="block py-3 px-4 rounded-lg <?= $currentPage === $link['id'] ? 'bg-surface text-primary' : 'text-text-secondary hover:bg-surface hover:text-text-primary' ?> transition-colors">
<?= $link['label'] ?>
</a>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
</nav>
</header>
<div class="h-16 lg:h-20"></div>