Herstructureer src/ naar feature-based folderstructuur
Continuous Integration / config (pull_request) Successful in 10s
Continuous Integration / prepare (pull_request) Successful in 1m26s
Continuous Integration / build-production (pull_request) Skipped
Continuous Integration / build (pull_request) Successful in 2m6s
Continuous Integration / test (pull_request) Successful in 2m2s
Continuous Integration / deploy-production (pull_request) Skipped
Deploy / deploy (pull_request) Successful in 38s
Continuous Integration / deploy-test (pull_request) Successful in 39s
Continuous Integration / config (pull_request) Successful in 10s
Continuous Integration / prepare (pull_request) Successful in 1m26s
Continuous Integration / build-production (pull_request) Skipped
Continuous Integration / build (pull_request) Successful in 2m6s
Continuous Integration / test (pull_request) Successful in 2m2s
Continuous Integration / deploy-production (pull_request) Skipped
Deploy / deploy (pull_request) Successful in 38s
Continuous Integration / deploy-test (pull_request) Successful in 39s
Volgt de aanpak uit het React 2025 folder structure artikel en het
SlpModularCms/frontend referentieproject: components/{layout,ui,shared},
features/landing/{components,data,hooks,pages,__tests__}, en lib/ voor
de query client. routes/index.tsx wordt een dunne wrapper rond de nieuwe
features/landing/pages/LandingPage.tsx.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
export function Footer() {
|
||||
return (
|
||||
<footer className="border-t border-line py-7 text-[0.85rem] text-muted">
|
||||
<div className="mx-auto flex max-w-[1080px] flex-wrap justify-between gap-2.5 px-6">
|
||||
<span>© 2026 SLP Software</span>
|
||||
<span className="font-mono">slp.Bouw(uwIdee);</span>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import { useState } from 'react';
|
||||
import { navLinks } from '../../features/landing/data/content';
|
||||
import { ThemeToggle } from '../ui/ThemeToggle';
|
||||
import { handleAnchorClick } from '../../utils/scrollToHash';
|
||||
|
||||
export function Nav() {
|
||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||
|
||||
function handleMobileLinkClick(event: React.MouseEvent<HTMLAnchorElement>, href: string) {
|
||||
handleAnchorClick(event, href);
|
||||
setIsMenuOpen(false);
|
||||
}
|
||||
|
||||
return (
|
||||
<nav className="sticky top-0 z-50 border-b border-line bg-bg/80 backdrop-blur-md">
|
||||
<div className="mx-auto flex h-16 max-w-[1080px] items-center justify-between px-6">
|
||||
<a
|
||||
href="#top"
|
||||
onClick={(event) => handleAnchorClick(event, '#top')}
|
||||
className="font-mono text-base font-bold tracking-wide text-text"
|
||||
>
|
||||
SLP<span className="text-accent">.</span>Software
|
||||
</a>
|
||||
<ul className="flex items-center gap-7">
|
||||
{navLinks.map((link) =>
|
||||
link.isCta ? (
|
||||
<li key={link.href} className="hidden sm:block">
|
||||
<a
|
||||
href={link.href}
|
||||
onClick={(event) => handleAnchorClick(event, link.href)}
|
||||
className="font-mono rounded-lg border border-accent-line bg-accent-soft px-4 py-2 text-sm font-medium text-text"
|
||||
data-testid="nav-cta-link"
|
||||
>
|
||||
{link.label}
|
||||
</a>
|
||||
</li>
|
||||
) : (
|
||||
<li key={link.href} className="hidden sm:block">
|
||||
<a
|
||||
href={link.href}
|
||||
onClick={(event) => handleAnchorClick(event, link.href)}
|
||||
className="text-sm font-medium text-muted transition-colors hover:text-text"
|
||||
>
|
||||
{link.label}
|
||||
</a>
|
||||
</li>
|
||||
),
|
||||
)}
|
||||
<li>
|
||||
<ThemeToggle />
|
||||
</li>
|
||||
<li className="sm:hidden">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsMenuOpen((open) => !open)}
|
||||
aria-label={isMenuOpen ? 'Sluit menu' : 'Open menu'}
|
||||
aria-expanded={isMenuOpen}
|
||||
aria-controls="mobile-nav-menu"
|
||||
data-testid="nav-mobile-toggle"
|
||||
className="flex h-8 w-8 items-center justify-center rounded-full border border-line text-text transition-colors hover:border-accent-line"
|
||||
>
|
||||
<span className="sr-only">{isMenuOpen ? 'Sluit menu' : 'Open menu'}</span>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
viewBox="0 0 24 24"
|
||||
width="18"
|
||||
height="18"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
>
|
||||
{isMenuOpen ? (
|
||||
<path d="M6 6l12 12M18 6L6 18" />
|
||||
) : (
|
||||
<path d="M4 7h16M4 12h16M4 17h16" />
|
||||
)}
|
||||
</svg>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{isMenuOpen ? (
|
||||
<ul
|
||||
id="mobile-nav-menu"
|
||||
data-testid="nav-mobile-menu"
|
||||
className="flex flex-col gap-1 border-t border-line bg-bg px-6 py-3 sm:hidden"
|
||||
>
|
||||
{navLinks.map((link) => (
|
||||
<li key={link.href}>
|
||||
<a
|
||||
href={link.href}
|
||||
onClick={(event) => handleMobileLinkClick(event, link.href)}
|
||||
className={
|
||||
link.isCta
|
||||
? 'font-mono block rounded-lg border border-accent-line bg-accent-soft px-4 py-2 text-sm font-medium text-text'
|
||||
: 'block px-1 py-2 text-sm font-medium text-muted transition-colors hover:text-text'
|
||||
}
|
||||
>
|
||||
{link.label}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Nav } from './Nav';
|
||||
import { Footer } from './Footer';
|
||||
import { UmamiAnalytics } from '../shared/UmamiAnalytics';
|
||||
import { SentryTestButton } from '../shared/SentryTestButton';
|
||||
|
||||
export function RootLayout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<div className="font-sans min-h-screen bg-bg text-text">
|
||||
<UmamiAnalytics />
|
||||
<Nav />
|
||||
{children}
|
||||
<Footer />
|
||||
<SentryTestButton />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { Nav } from '../Nav';
|
||||
import { ThemeProvider } from '../../../theme/ThemeProvider';
|
||||
|
||||
function renderNav() {
|
||||
return render(
|
||||
<ThemeProvider>
|
||||
<Nav />
|
||||
</ThemeProvider>,
|
||||
);
|
||||
}
|
||||
|
||||
describe('Nav', () => {
|
||||
beforeEach(() => {
|
||||
window.localStorage.clear();
|
||||
document.documentElement.className = '';
|
||||
});
|
||||
|
||||
it('renders all nav links including the CTA', () => {
|
||||
renderNav();
|
||||
expect(screen.getByText('Pakketten')).toBeInTheDocument();
|
||||
expect(screen.getByText('Werkwijze')).toBeInTheDocument();
|
||||
expect(screen.getByText('Over')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('nav-cta-link')).toHaveTextContent('Start project');
|
||||
});
|
||||
|
||||
it('renders the theme toggle with a Dutch accessible label', () => {
|
||||
renderNav();
|
||||
expect(screen.getByRole('button', { name: 'Wissel kleurthema' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('toggles the theme when the toggle button is clicked', () => {
|
||||
renderNav();
|
||||
const toggle = screen.getByTestId('theme-toggle-button');
|
||||
expect(toggle).toHaveAttribute('aria-pressed', 'false');
|
||||
fireEvent.click(toggle);
|
||||
expect(toggle).toHaveAttribute('aria-pressed', 'true');
|
||||
});
|
||||
|
||||
it('opens and closes the mobile menu via the toggle button', () => {
|
||||
renderNav();
|
||||
expect(screen.queryByTestId('nav-mobile-menu')).not.toBeInTheDocument();
|
||||
|
||||
const mobileToggle = screen.getByTestId('nav-mobile-toggle');
|
||||
expect(mobileToggle).toHaveAttribute('aria-expanded', 'false');
|
||||
|
||||
fireEvent.click(mobileToggle);
|
||||
expect(mobileToggle).toHaveAttribute('aria-expanded', 'true');
|
||||
const mobileMenu = screen.getByTestId('nav-mobile-menu');
|
||||
expect(mobileMenu).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(mobileToggle);
|
||||
expect(screen.queryByTestId('nav-mobile-menu')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('closes the mobile menu when a link inside it is clicked', () => {
|
||||
renderNav();
|
||||
fireEvent.click(screen.getByTestId('nav-mobile-toggle'));
|
||||
const mobileMenu = screen.getByTestId('nav-mobile-menu');
|
||||
|
||||
const link = mobileMenu.querySelector('a[href="#pakketten"]');
|
||||
expect(link).not.toBeNull();
|
||||
fireEvent.click(link as HTMLAnchorElement);
|
||||
|
||||
expect(screen.queryByTestId('nav-mobile-menu')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user