Completes the front-end shell with footer, status pages and SEO
Adds the footer, back-to-top button, skip link, placeholder routes, 404 and error pages inside the shell, plus per-page SEO from a single page registry (canonical URLs, Open Graph image, JSON-LD, generated sitemap.xml and robots.txt). Theme tokens and recipes replace repeated styling, the hero loads only the active and neighbouring slides, and the e-mail address is joined in the browser to keep it out of the HTML and bundle. Adds Vitest with property-based (fast-check) and axe tests, ESLint, security headers for dev and preview, Lighthouse CI and a `pnpm check` script that runs all quality gates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { useEffect } from 'react';
|
||||
import { Box, chakra, Stack } from '@chakra-ui/react';
|
||||
import { Link } from '@tanstack/react-router';
|
||||
import navItems from './navItems';
|
||||
|
||||
const ChakraLink = chakra(Link);
|
||||
import { Box, Stack } from '@chakra-ui/react';
|
||||
import { mainNav } from '@/navigation';
|
||||
import RouterLink from '../RouterLink';
|
||||
|
||||
type MobileNavProps = {
|
||||
id: string;
|
||||
@@ -37,7 +35,7 @@ export default function MobileNav({ id, open, onClose }: MobileNavProps) {
|
||||
insetX={0}
|
||||
bottom={0}
|
||||
// Net onder de balk, zodat de schaduw van de balk erover valt
|
||||
zIndex="calc({zIndex.docked} - 1)"
|
||||
zIndex="mobileNav"
|
||||
display={{ base: 'flex', lg: 'none' }}
|
||||
flexDirection="column"
|
||||
justifyContent="center"
|
||||
@@ -54,9 +52,9 @@ export default function MobileNav({ id, open, onClose }: MobileNavProps) {
|
||||
>
|
||||
<nav aria-label="Mobiel menu">
|
||||
<Stack as="ul" gap={5} listStyleType="none">
|
||||
{navItems.map((item) => (
|
||||
{mainNav.map((item) => (
|
||||
<li key={item.to}>
|
||||
<ChakraLink
|
||||
<RouterLink
|
||||
to={item.to}
|
||||
onClick={onClose}
|
||||
display="block"
|
||||
@@ -66,7 +64,7 @@ export default function MobileNav({ id, open, onClose }: MobileNavProps) {
|
||||
_currentPage={{ color: 'accent' }}
|
||||
>
|
||||
{item.label}
|
||||
</ChakraLink>
|
||||
</RouterLink>
|
||||
</li>
|
||||
))}
|
||||
</Stack>
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import { chakra } from '@chakra-ui/react';
|
||||
import { Link } from '@tanstack/react-router';
|
||||
import RouterLink from '../RouterLink';
|
||||
|
||||
const ChakraLink = chakra(Link);
|
||||
|
||||
type NavLinkProps = React.ComponentProps<typeof ChakraLink>;
|
||||
type NavLinkProps = React.ComponentProps<typeof RouterLink>;
|
||||
|
||||
export default function NavLink({ children, ...props }: NavLinkProps) {
|
||||
return (
|
||||
<ChakraLink
|
||||
<RouterLink
|
||||
textStyle="eyebrow"
|
||||
fontWeight="300"
|
||||
position="relative"
|
||||
@@ -38,6 +35,6 @@ export default function NavLink({ children, ...props }: NavLinkProps) {
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</ChakraLink>
|
||||
</RouterLink>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { screen, within } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import NavigationBar from './NavigationBar';
|
||||
|
||||
describe('NavigationBar', () => {
|
||||
it('heeft het logo als link naar home', async () => {
|
||||
await renderWithProviders(<NavigationBar />, { path: '/portfolio' });
|
||||
expect(
|
||||
screen.getByRole('link', {
|
||||
name: 'Andrea Slop Fotografie, naar de homepage',
|
||||
}),
|
||||
).toHaveAttribute('href', '/');
|
||||
});
|
||||
|
||||
it('toont het hoofdmenu in de vaste volgorde', async () => {
|
||||
const { container } = await renderWithProviders(<NavigationBar />);
|
||||
const nav = screen.getByRole('navigation', { name: 'Hoofdmenu' });
|
||||
expect(
|
||||
within(nav)
|
||||
.getAllByRole('link', { hidden: true })
|
||||
.map((link) => link.textContent),
|
||||
).toEqual([
|
||||
'Home',
|
||||
'Over mij',
|
||||
'Portfolio',
|
||||
'Soorten fotoshoots',
|
||||
'Contact',
|
||||
]);
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('heeft een menuknop met een toegankelijke naam', async () => {
|
||||
await renderWithProviders(<NavigationBar />);
|
||||
expect(screen.getByTestId('nav-menu-toggle')).toHaveAccessibleName(
|
||||
'Menu openen',
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -3,13 +3,13 @@ import {
|
||||
HStack,
|
||||
chakra,
|
||||
Image,
|
||||
Box,
|
||||
Container,
|
||||
useBreakpointValue,
|
||||
} from '@chakra-ui/react';
|
||||
import NavLink from './NavLink';
|
||||
import MobileNav from './MobileNav';
|
||||
import navItems from './navItems';
|
||||
import { mainNav } from '@/navigation';
|
||||
import RouterLink from '../RouterLink';
|
||||
import useScrolledPast from '@/hooks/useScrolledPast';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useRouterState } from '@tanstack/react-router';
|
||||
@@ -19,7 +19,7 @@ import logoLight from '../../assets/logo-light.png';
|
||||
import logoDark from '../../assets/logo-dark.png';
|
||||
|
||||
export default function NavigationBar() {
|
||||
let [open, setOpen] = useState(false);
|
||||
const [open, setOpen] = useState(false);
|
||||
const closeMenu = useCallback(() => setOpen(false), []);
|
||||
|
||||
// Het mobiele menu bestaat alleen onder lg; wordt het scherm breder, dan
|
||||
@@ -47,7 +47,7 @@ export default function NavigationBar() {
|
||||
position="fixed"
|
||||
top={0}
|
||||
insetX={0}
|
||||
zIndex="docked"
|
||||
zIndex="header"
|
||||
// Zelfde hoogte als waar de hero-content onder begint; kleiner na scrollen
|
||||
h={pastHero ? 'header.sticky' : 'header'}
|
||||
display="flex"
|
||||
@@ -69,7 +69,11 @@ export default function NavigationBar() {
|
||||
alignItems="center"
|
||||
justifyContent="space-between"
|
||||
>
|
||||
<Box
|
||||
<RouterLink
|
||||
to="/"
|
||||
aria-label="Andrea Slop Fotografie, naar de homepage"
|
||||
data-testid="nav-logo-link"
|
||||
display="block"
|
||||
flexBasis="auto"
|
||||
flexGrow={1}
|
||||
flexShrink={0}
|
||||
@@ -84,17 +88,22 @@ export default function NavigationBar() {
|
||||
transitionTimingFunction="smooth"
|
||||
>
|
||||
{/* Twee logo's, zodat de kleur per schermbreedte kan wisselen */}
|
||||
{/* De link heeft de naam; de logo's zelf zijn decoratief */}
|
||||
<Image
|
||||
src={logoDark}
|
||||
alt="Andrea Slop Fotografie"
|
||||
alt=""
|
||||
htmlWidth={500}
|
||||
htmlHeight={500}
|
||||
display={overlay('block', 'none')}
|
||||
/>
|
||||
<Image
|
||||
src={logoLight}
|
||||
alt="Andrea Slop Fotografie"
|
||||
alt=""
|
||||
htmlWidth={500}
|
||||
htmlHeight={500}
|
||||
display={overlay('none', 'block')}
|
||||
/>
|
||||
</Box>
|
||||
</RouterLink>
|
||||
<chakra.nav
|
||||
aria-label="Hoofdmenu"
|
||||
flexBasis="100%"
|
||||
@@ -109,7 +118,7 @@ export default function NavigationBar() {
|
||||
// Op mobiel staan de links in het hamburgermenu
|
||||
display={{ base: 'none', lg: 'flex' }}
|
||||
>
|
||||
{navItems.map((item) => (
|
||||
{mainNav.map((item) => (
|
||||
<chakra.li key={item.to}>
|
||||
<NavLink to={item.to}>
|
||||
{item.label}
|
||||
@@ -135,15 +144,17 @@ export default function NavigationBar() {
|
||||
data-open={menuOpen || undefined}
|
||||
// Op desktop opent deze knop straks het info-menu (side area)
|
||||
display={{ base: 'block', lg: 'none' }}
|
||||
data-testid="nav-menu-toggle"
|
||||
position="relative"
|
||||
w="32px"
|
||||
h="32px"
|
||||
// 44px: minimaal klikdoel op touch (BR-RWD-04)
|
||||
w="44px"
|
||||
h="44px"
|
||||
cursor="pointer"
|
||||
zIndex="modal"
|
||||
zIndex="menuToggle"
|
||||
css={{
|
||||
'& > span': {
|
||||
position: 'absolute',
|
||||
left: '4px',
|
||||
left: '10px',
|
||||
width: '24px',
|
||||
height: '2px',
|
||||
bg: 'currentColor',
|
||||
@@ -151,22 +162,22 @@ export default function NavigationBar() {
|
||||
transition:
|
||||
'transform 0.3s ease, opacity 0.2s ease, top 0.3s ease',
|
||||
},
|
||||
'& > span:nth-of-type(1)': { top: '9px' },
|
||||
'& > span:nth-of-type(2)': { top: '15px' },
|
||||
'& > span:nth-of-type(3)': { top: '21px' },
|
||||
'& > span:nth-of-type(1)': { top: '15px' },
|
||||
'& > span:nth-of-type(2)': { top: '21px' },
|
||||
'& > span:nth-of-type(3)': { top: '27px' },
|
||||
|
||||
// open kruisje
|
||||
'&[data-open] > span:nth-of-type(1)': {
|
||||
top: '15px',
|
||||
top: '21px',
|
||||
transform: 'rotate(45deg)',
|
||||
},
|
||||
'&[data-open] > span:nth-of-type(2)': {
|
||||
opacity: 0,
|
||||
top: '15px',
|
||||
top: '21px',
|
||||
transform: 'rotate(45deg)',
|
||||
},
|
||||
'&[data-open] > span:nth-of-type(3)': {
|
||||
top: '15px',
|
||||
top: '21px',
|
||||
transform: 'rotate(-45deg)',
|
||||
},
|
||||
}}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
// Menu-items, gedeeld door de desktopnavigatie en het mobiele menu
|
||||
const navItems = [
|
||||
{ to: '/', label: 'Home' },
|
||||
{ to: '/over-mij', label: 'Over mij' },
|
||||
] as const;
|
||||
|
||||
export default navItems;
|
||||
Reference in New Issue
Block a user