Duidelijkere hovers, geen zichtbare pakkettenteller, nav schakelt op md met animatie en zonder CTA in mobiel menu

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-10 16:37:28 +01:00
co-authored by Claude Sonnet 5.5
parent f47528073d
commit 0d7be249f5
11 changed files with 116 additions and 81 deletions
+38 -35
View File
@@ -5,11 +5,13 @@ import { VariantToggle } from '../ui/VariantToggle';
import { handleAnchorClick } from '../../utils/scrollToHash'; import { handleAnchorClick } from '../../utils/scrollToHash';
/** /**
* Navigation of design B: part of the brand-red header (not sticky), white text, the CTA as a * Navigation of design B: part of the brand-red header, white text, the CTA as a white block
* white block. The mobile menu (hamburger) is kept for small screens; years are not in the menu. * (desktop only). Below the `md` breakpoint a hamburger opens an animated overlay menu with the
* section links; the "Start project" CTA is not repeated there (the hero has its own buttons).
*/ */
export function Nav() { export function Nav() {
const [isMenuOpen, setIsMenuOpen] = useState(false); const [isMenuOpen, setIsMenuOpen] = useState(false);
const sectionLinks = navLinks.filter((link) => !link.isCta);
// Escape closes the mobile menu (keyboard users). // Escape closes the mobile menu (keyboard users).
useEffect(() => { useEffect(() => {
@@ -27,35 +29,35 @@ export function Nav() {
} }
return ( return (
<nav aria-label="Hoofdnavigatie" className="sticky top-0 z-40 bg-brand text-on-brand sm:static"> <nav aria-label="Hoofdnavigatie" className="sticky top-0 z-40 bg-brand text-on-brand md:static">
<div className="mx-auto flex min-h-[84px] max-w-[1280px] items-center justify-between gap-6 px-6 sm:px-8"> <div className="mx-auto flex min-h-[84px] max-w-[1280px] items-center justify-between gap-4 px-6 sm:px-8">
<a <a
href="#top" href="#top"
onClick={(event) => handleAnchorClick(event, '#top')} onClick={(event) => handleAnchorClick(event, '#top')}
className="flex items-baseline gap-2 py-2.5 no-underline" className="flex shrink-0 items-baseline gap-2 py-2.5 no-underline"
> >
<span className="text-2xl font-black tracking-tight [font-stretch:125%]">SLP</span> <span className="text-2xl font-black tracking-tight [font-stretch:125%]">SLP</span>
<span className="text-base font-normal">Software</span> <span className="text-base font-normal">Software</span>
</a> </a>
<ul className="flex items-center gap-3 sm:gap-8"> <ul className="flex items-center gap-3 md:gap-5 lg:gap-8">
{navLinks.map((link) => {navLinks.map((link) =>
link.isCta ? ( link.isCta ? (
<li key={link.href} className="hidden sm:block"> <li key={link.href} className="hidden md:block">
<a <a
href={link.href} href={link.href}
onClick={(event) => handleAnchorClick(event, link.href)} onClick={(event) => handleAnchorClick(event, link.href)}
className="inline-block bg-white px-[18px] py-[11px] text-[15px] font-bold text-brand no-underline hover:opacity-90" className="inline-block whitespace-nowrap bg-white px-[18px] py-[11px] text-[15px] font-bold text-brand no-underline transition-colors hover:bg-inv hover:text-white"
data-testid="nav-cta-link" data-testid="nav-cta-link"
> >
{link.label} {link.label}
</a> </a>
</li> </li>
) : ( ) : (
<li key={link.href} className="hidden sm:block"> <li key={link.href} className="hidden md:block">
<a <a
href={link.href} href={link.href}
onClick={(event) => handleAnchorClick(event, link.href)} onClick={(event) => handleAnchorClick(event, link.href)}
className="inline-block py-3 text-[15px] font-medium no-underline hover:opacity-85" className="inline-block whitespace-nowrap py-3 text-[15px] font-medium no-underline decoration-2 underline-offset-[10px] transition-colors hover:underline"
> >
{link.label} {link.label}
</a> </a>
@@ -68,7 +70,7 @@ export function Nav() {
<li> <li>
<VariantToggle tone="onBrand" /> <VariantToggle tone="onBrand" />
</li> </li>
<li className="sm:hidden"> <li className="md:hidden">
<button <button
type="button" type="button"
onClick={() => setIsMenuOpen((open) => !open)} onClick={() => setIsMenuOpen((open) => !open)}
@@ -76,7 +78,7 @@ export function Nav() {
aria-expanded={isMenuOpen} aria-expanded={isMenuOpen}
aria-controls="mobile-nav-menu" aria-controls="mobile-nav-menu"
data-testid="nav-mobile-toggle" data-testid="nav-mobile-toggle"
className="flex h-11 w-11 items-center justify-center rounded-full border border-white/70 text-on-brand transition-colors hover:border-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white" className="flex h-11 w-11 items-center justify-center rounded-full border border-white/70 text-on-brand transition-colors hover:border-white hover:bg-white/15 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white"
> >
<span className="sr-only">{isMenuOpen ? 'Sluit menu' : 'Open menu'}</span> <span className="sr-only">{isMenuOpen ? 'Sluit menu' : 'Open menu'}</span>
<svg <svg
@@ -99,29 +101,30 @@ export function Nav() {
</li> </li>
</ul> </ul>
</div> </div>
{isMenuOpen ? ( {/* Always mounted so it can animate; `invisible` removes it from the tab order and the
<ul accessibility tree while closed. */}
id="mobile-nav-menu" <ul
data-testid="nav-mobile-menu" id="mobile-nav-menu"
className="absolute inset-x-0 top-full z-40 flex flex-col gap-1 border-t border-white/30 bg-inv px-6 py-3 text-white shadow-[0_12px_24px_rgba(0,0,0,0.35)] sm:hidden" data-testid="nav-mobile-menu"
> data-state={isMenuOpen ? 'open' : 'closed'}
{navLinks.map((link) => ( className={`absolute inset-x-0 top-full z-40 flex flex-col gap-1 border-t border-white/30 bg-inv px-6 py-3 text-white shadow-[0_12px_24px_rgba(0,0,0,0.35)] transition-[opacity,transform,visibility] duration-200 ease-out motion-reduce:transition-none md:hidden ${
<li key={link.href}> isMenuOpen
<a ? 'visible translate-y-0 opacity-100'
href={link.href} : 'pointer-events-none invisible -translate-y-2 opacity-0'
onClick={(event) => handleMobileLinkClick(event, link.href)} }`}
className={ >
link.isCta {sectionLinks.map((link) => (
? 'mt-1 block bg-white px-4 py-3 text-[15px] font-bold text-brand no-underline' <li key={link.href}>
: 'block px-1 py-3 text-[15px] font-medium no-underline hover:opacity-85' <a
} href={link.href}
> onClick={(event) => handleMobileLinkClick(event, link.href)}
{link.label} className="block px-1 py-3 text-[15px] font-medium no-underline transition-colors hover:bg-white/10"
</a> >
</li> {link.label}
))} </a>
</ul> </li>
) : null} ))}
</ul>
</nav> </nav>
); );
} }
+43 -13
View File
@@ -18,9 +18,10 @@ describe('Nav', () => {
it('renders all nav links including the CTA', () => { it('renders all nav links including the CTA', () => {
renderNav(); renderNav();
expect(screen.getByText('Pakketten')).toBeInTheDocument(); // desktop bar + (hidden) mobile menu
expect(screen.getByText('Werkwijze')).toBeInTheDocument(); expect(screen.getAllByText('Pakketten')).toHaveLength(2);
expect(screen.getByText('Over')).toBeInTheDocument(); expect(screen.getAllByText('Werkwijze')).toHaveLength(2);
expect(screen.getAllByText('Over')).toHaveLength(2);
expect(screen.getByTestId('nav-cta-link')).toHaveTextContent('Start project'); expect(screen.getByTestId('nav-cta-link')).toHaveTextContent('Start project');
}); });
@@ -47,20 +48,30 @@ describe('Nav', () => {
expect(toggle).toHaveAttribute('aria-pressed', 'true'); expect(toggle).toHaveAttribute('aria-pressed', 'true');
}); });
it('opens and closes the mobile menu via the toggle button', () => { it('opens and closes the animated mobile menu via the toggle button', () => {
renderNav(); renderNav();
expect(screen.queryByTestId('nav-mobile-menu')).not.toBeInTheDocument(); const menu = screen.getByTestId('nav-mobile-menu');
expect(menu).toHaveAttribute('data-state', 'closed');
// Closed: hidden from the tab order and the accessibility tree.
expect(menu).toHaveClass('invisible', 'opacity-0');
const mobileToggle = screen.getByTestId('nav-mobile-toggle'); const mobileToggle = screen.getByTestId('nav-mobile-toggle');
expect(mobileToggle).toHaveAttribute('aria-expanded', 'false'); expect(mobileToggle).toHaveAttribute('aria-expanded', 'false');
fireEvent.click(mobileToggle); fireEvent.click(mobileToggle);
expect(mobileToggle).toHaveAttribute('aria-expanded', 'true'); expect(mobileToggle).toHaveAttribute('aria-expanded', 'true');
const mobileMenu = screen.getByTestId('nav-mobile-menu'); expect(menu).toHaveAttribute('data-state', 'open');
expect(mobileMenu).toBeInTheDocument(); expect(menu).toHaveClass('visible', 'opacity-100');
fireEvent.click(mobileToggle); fireEvent.click(mobileToggle);
expect(screen.queryByTestId('nav-mobile-menu')).not.toBeInTheDocument(); expect(menu).toHaveAttribute('data-state', 'closed');
});
it('animates opening and closing, but not under reduced motion', () => {
renderNav();
const menu = screen.getByTestId('nav-mobile-menu');
expect(menu).toHaveClass('transition-[opacity,transform,visibility]', 'duration-200');
expect(menu).toHaveClass('motion-reduce:transition-none');
}); });
it('shows the mobile menu as a dark overlay below the bar that does not push the page, and closes on Escape', () => { it('shows the mobile menu as a dark overlay below the bar that does not push the page, and closes on Escape', () => {
@@ -69,15 +80,35 @@ describe('Nav', () => {
const menu = screen.getByTestId('nav-mobile-menu'); const menu = screen.getByTestId('nav-mobile-menu');
expect(menu).toHaveClass('absolute', 'top-full', 'bg-inv'); expect(menu).toHaveClass('absolute', 'top-full', 'bg-inv');
fireEvent.keyDown(document, { key: 'Escape' }); fireEvent.keyDown(document, { key: 'Escape' });
expect(screen.queryByTestId('nav-mobile-menu')).not.toBeInTheDocument(); expect(menu).toHaveAttribute('data-state', 'closed');
}); });
it('keeps the bar visible while scrolling on small screens only', () => { it('does not repeat the "Start project" button in the mobile menu', () => {
renderNav();
const menu = screen.getByTestId('nav-mobile-menu');
const labels = Array.from(menu.querySelectorAll('a')).map((a) => a.textContent);
expect(labels).toEqual(['Over', 'Pakketten', 'Werkwijze']);
});
it('keeps the CTA on one line and switches to the desktop bar at the md breakpoint', () => {
renderNav();
const cta = screen.getByTestId('nav-cta-link');
expect(cta).toHaveClass('whitespace-nowrap');
expect(cta.closest('li')).toHaveClass('hidden', 'md:block');
expect(screen.getByTestId('nav-mobile-toggle').closest('li')).toHaveClass('md:hidden');
});
it('gives the CTA a clearly visible hover (inverts to black)', () => {
renderNav();
expect(screen.getByTestId('nav-cta-link')).toHaveClass('hover:bg-inv', 'hover:text-white');
});
it('keeps the bar visible while scrolling below the md breakpoint only', () => {
renderNav(); renderNav();
expect(screen.getByRole('navigation', { name: 'Hoofdnavigatie' })).toHaveClass( expect(screen.getByRole('navigation', { name: 'Hoofdnavigatie' })).toHaveClass(
'sticky', 'sticky',
'top-0', 'top-0',
'sm:static', 'md:static',
); );
}); });
@@ -85,10 +116,9 @@ describe('Nav', () => {
renderNav(); renderNav();
fireEvent.click(screen.getByTestId('nav-mobile-toggle')); fireEvent.click(screen.getByTestId('nav-mobile-toggle'));
const mobileMenu = screen.getByTestId('nav-mobile-menu'); const mobileMenu = screen.getByTestId('nav-mobile-menu');
expect(mobileMenu).toBeInTheDocument();
const link = mobileMenu.querySelector('a'); const link = mobileMenu.querySelector('a');
expect(link).not.toBeNull(); expect(link).not.toBeNull();
fireEvent.click(link as HTMLAnchorElement); fireEvent.click(link as HTMLAnchorElement);
expect(screen.queryByTestId('nav-mobile-menu')).not.toBeInTheDocument(); expect(mobileMenu).toHaveAttribute('data-state', 'closed');
}); });
}); });
@@ -36,7 +36,9 @@ describe('ErrorBoundary', () => {
); );
expect(screen.getByTestId('error-boundary-fallback')).toBeInTheDocument(); expect(screen.getByTestId('error-boundary-fallback')).toBeInTheDocument();
expect(screen.getByText('Er ging iets mis. Probeer de pagina te vernieuwen.')).toBeInTheDocument(); expect(
screen.getByText('Er ging iets mis. Probeer de pagina te vernieuwen.'),
).toBeInTheDocument();
consoleErrorSpy.mockRestore(); consoleErrorSpy.mockRestore();
}); });
@@ -53,7 +55,9 @@ describe('ErrorBoundary', () => {
expect(Sentry.captureException).toHaveBeenCalledTimes(1); expect(Sentry.captureException).toHaveBeenCalledTimes(1);
expect(Sentry.captureException).toHaveBeenCalledWith( expect(Sentry.captureException).toHaveBeenCalledWith(
expect.any(Error), expect.any(Error),
expect.objectContaining({ extra: expect.objectContaining({ componentStack: expect.any(String) }) }), expect.objectContaining({
extra: expect.objectContaining({ componentStack: expect.any(String) }),
}),
); );
consoleErrorSpy.mockRestore(); consoleErrorSpy.mockRestore();
+3 -2
View File
@@ -5,6 +5,7 @@
export type ToggleTone = 'default' | 'onBrand'; export type ToggleTone = 'default' | 'onBrand';
export const TONE_CLASSES: Record<ToggleTone, string> = { export const TONE_CLASSES: Record<ToggleTone, string> = {
default: 'border-line text-text hover:border-accent-line focus-visible:outline-accent', default: 'border-line text-text hover:border-text hover:bg-surface focus-visible:outline-accent',
onBrand: 'border-white/70 text-on-brand hover:border-white focus-visible:outline-white', onBrand:
'border-white/70 text-on-brand hover:border-white hover:bg-white/15 focus-visible:outline-white',
}; };
@@ -93,7 +93,7 @@ export function ContactFormView({ client, token, refreshToken }: ContactFormView
<button <button
type="button" type="button"
onClick={form.reset} onClick={form.reset}
className="min-h-[44px] bg-text px-[22px] py-[15px] text-[15px] font-bold text-panel" className="min-h-[44px] bg-text px-[22px] py-[15px] text-[15px] font-bold text-panel transition-colors hover:bg-brand hover:text-on-brand"
data-testid="contact-reset" data-testid="contact-reset"
> >
Nog een bericht sturen Nog een bericht sturen
@@ -149,7 +149,7 @@ export function ContactFormView({ client, token, refreshToken }: ContactFormView
<button <button
type="submit" type="submit"
disabled={form.status === 'sending'} disabled={form.status === 'sending'}
className="min-h-[44px] rounded-none bg-brand px-6 py-[18px] text-[17px] font-bold text-on-brand disabled:opacity-70" className="min-h-[44px] rounded-none bg-brand px-6 py-[18px] text-[17px] font-bold text-on-brand transition-colors hover:bg-text hover:text-bg disabled:opacity-70 disabled:hover:bg-brand disabled:hover:text-on-brand"
data-testid="contact-submit" data-testid="contact-submit"
> >
{form.status === 'sending' {form.status === 'sending'
@@ -19,8 +19,8 @@ export function FilterChips({ chips, activeId, onSelect }: FilterChipsProps) {
aria-pressed={active} aria-pressed={active}
onClick={() => onSelect(chip.id)} onClick={() => onSelect(chip.id)}
data-testid={`package-chip-${chip.id}`} data-testid={`package-chip-${chip.id}`}
className={`min-h-[44px] border-2 border-text px-5 text-[15px] font-bold ${ className={`min-h-[44px] border-2 border-text px-5 text-[15px] font-bold transition-colors ${
active ? 'bg-text text-bg' : 'bg-transparent text-text' active ? 'bg-text text-bg' : 'bg-transparent text-text hover:bg-line'
}`} }`}
> >
{chip.label} {chip.label}
+2 -2
View File
@@ -31,14 +31,14 @@ export function Hero() {
<a <a
href="#pakketten" href="#pakketten"
onClick={(event) => handleAnchorClick(event, '#pakketten')} onClick={(event) => handleAnchorClick(event, '#pakketten')}
className="bg-white px-[26px] py-[17px] text-base font-bold text-[#0e0d0d] no-underline hover:opacity-90" className="bg-white px-[26px] py-[17px] text-base font-bold text-[#0e0d0d] no-underline transition-colors hover:bg-inv hover:text-white"
> >
Bekijk pakketten Bekijk pakketten
</a> </a>
<a <a
href="#contact" href="#contact"
onClick={(event) => handleAnchorClick(event, '#contact')} onClick={(event) => handleAnchorClick(event, '#contact')}
className="border-2 border-white px-6 py-[15px] text-base font-bold text-white no-underline hover:opacity-90" className="border-2 border-white px-6 py-[15px] text-base font-bold text-white no-underline transition-colors hover:bg-white hover:text-brand"
> >
Plan een gesprek Plan een gesprek
</a> </a>
@@ -14,7 +14,7 @@ export function MailtoPanel() {
</p> </p>
<a <a
href={mailtoHref} href={mailtoHref}
className="inline-block bg-brand px-6 py-[18px] text-[17px] font-bold text-on-brand no-underline hover:opacity-90" className="inline-block bg-brand px-6 py-[18px] text-[17px] font-bold text-on-brand no-underline transition-colors hover:bg-text hover:text-bg"
data-testid="contact-mailto-button" data-testid="contact-mailto-button"
> >
Stuur een bericht Stuur een bericht
@@ -42,7 +42,7 @@ export function PackageBanner({ pkg, settings }: PackageBannerProps) {
} }
handleAnchorClick(event, '#contact'); handleAnchorClick(event, '#contact');
}} }}
className="bg-white px-[26px] py-[17px] text-base font-bold text-[#0e0d0d] no-underline hover:opacity-90" className="bg-white px-[26px] py-[17px] text-base font-bold text-[#0e0d0d] no-underline transition-colors hover:bg-brand hover:text-on-brand"
data-testid="package-banner-cta" data-testid="package-banner-cta"
> >
{cta} {cta}
@@ -51,8 +51,10 @@ export function PackageCard({ pkg }: { pkg: PackageCardData }) {
select(pkg.slug); select(pkg.slug);
handleAnchorClick(event, '#contact'); handleAnchorClick(event, '#contact');
}} }}
className={`block px-5 py-4 text-center text-base font-bold no-underline hover:opacity-90 ${ className={`block px-5 py-4 text-center text-base font-bold no-underline transition-colors ${
featured ? 'bg-white text-[#0e0d0d]' : 'bg-text text-bg' featured
? 'bg-white text-[#0e0d0d] hover:bg-inv hover:text-white'
: 'bg-text text-bg hover:bg-brand hover:text-on-brand'
}`} }`}
data-testid={`package-cta-${pkg.id}`} data-testid={`package-cta-${pkg.id}`}
> >
@@ -58,26 +58,21 @@ export function PackagesSection() {
</div> </div>
) : ( ) : (
<> <>
{loaded && ( {loaded && filter.chips ? (
<div className="mb-8 flex flex-wrap items-center justify-between gap-x-8 gap-y-4"> <div className="mb-8">
{filter.chips ? ( <FilterChips
<FilterChips chips={filter.chips}
chips={filter.chips} activeId={filter.activeId}
activeId={filter.activeId} onSelect={filter.setActive}
onSelect={filter.setActive} />
/>
) : (
<span />
)}
<p
className="text-[15px] text-muted"
aria-live="polite"
data-testid="packages-status"
>
{filter.label}
</p>
</div> </div>
)} ) : null}
{/* Not shown visually; announces the result count to screen readers when a filter changes. */}
{loaded ? (
<p className="sr-only" aria-live="polite" data-testid="packages-status">
{filter.label}
</p>
) : null}
<PackageList packages={filter.visible} loading={!loaded} resetKey={filter.activeId} /> <PackageList packages={filter.visible} loading={!loaded} resetKey={filter.activeId} />
{loaded && banner} {loaded && banner}
</> </>