feat: add NavBar component with site name, Posts link, and responsive layout
Created NavBar.astro component with: - Site name link 'Crash Test Dev' and Posts nav link with active state detection - aria-label='Site navigation' and aria-current='page' accessibility attributes - Responsive stacking at 599px breakpoint - Design token-based styling (structure font, border-subtle, etc.) - Updated index.astro to include NavBar in nav slot - Added comprehensive build-output tests (24 assertions) Generated with Amplifier Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
---
|
||||
const currentPath = Astro.url.pathname;
|
||||
const base = import.meta.env.BASE_URL;
|
||||
|
||||
const navLinks = [
|
||||
{ label: 'Posts', href: base },
|
||||
];
|
||||
|
||||
function isActive(href: string): boolean {
|
||||
return currentPath === href || currentPath.startsWith(base + 'posts/');
|
||||
}
|
||||
---
|
||||
|
||||
<nav aria-label="Site navigation">
|
||||
<div class="nav-inner">
|
||||
<a href={base} class="site-name">Crash Test Dev</a>
|
||||
<div class="nav-links">
|
||||
{navLinks.map((link) => (
|
||||
<a
|
||||
href={link.href}
|
||||
class:list={['nav-link', { active: isActive(link.href) }]}
|
||||
aria-current={isActive(link.href) ? 'page' : undefined}
|
||||
>
|
||||
{link.label}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<style>
|
||||
nav {
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
position: static;
|
||||
}
|
||||
|
||||
.nav-inner {
|
||||
max-width: var(--width-container);
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
padding-left: var(--gutter);
|
||||
padding-right: var(--gutter);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.site-name {
|
||||
font-family: var(--font-structure);
|
||||
font-size: var(--type-base);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
letter-spacing: -0.01em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.site-name:hover {
|
||||
color: var(--accent-primary);
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
display: flex;
|
||||
gap: var(--space-4);
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
font-family: var(--font-structure);
|
||||
font-size: var(--type-sm);
|
||||
font-weight: 400;
|
||||
color: var(--text-secondary);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.nav-link.active {
|
||||
font-weight: 500;
|
||||
color: var(--text-primary);
|
||||
text-decoration: underline;
|
||||
text-decoration-color: var(--accent-primary);
|
||||
text-decoration-thickness: 2px;
|
||||
text-underline-offset: 6px;
|
||||
}
|
||||
|
||||
@media (max-width: 599px) {
|
||||
.nav-inner {
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
gap: var(--space-3);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user