Adds the Contact page
The contact page in the approved layout: the form next to a photo with the contact card on wide screens, and the card with a small portrait above the form on phones, where the large photo is never downloaded. /contact?pakket= preselects a package. The page is indexed, with its own title, description, preview image and ContactPage structured data. Over mij and Soorten fotoshoots now link to /contact. The green button gets a darker background, so its white text meets the contrast minimum. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import ContactAside, { ASIDE_MEDIA } from './ContactAside';
|
||||
|
||||
const image = {
|
||||
src: '/contact.jpg',
|
||||
alt: 'Andrea met haar camera',
|
||||
width: 840,
|
||||
height: 1050,
|
||||
};
|
||||
|
||||
describe('ContactAside', () => {
|
||||
it('offers the photo only to wide screens, with priority', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
<ContactAside image={image}>
|
||||
<p>Kaart</p>
|
||||
</ContactAside>,
|
||||
);
|
||||
const source = container.querySelector('picture source');
|
||||
expect(source).toHaveAttribute('media', ASIDE_MEDIA);
|
||||
expect(source).toHaveAttribute('srcset', '/contact.jpg');
|
||||
|
||||
// Hidden in jsdom: it has no screen width, so the base display wins
|
||||
const photo = screen.getByRole('img', {
|
||||
name: image.alt,
|
||||
hidden: true,
|
||||
});
|
||||
// Phones get a tiny inline image, never the photo itself
|
||||
expect(photo.getAttribute('src')).toMatch(/^data:image\/gif/);
|
||||
expect(photo).toHaveAttribute('fetchpriority', 'high');
|
||||
expect(photo).toHaveAttribute('width', '840');
|
||||
expect(photo).toHaveAttribute('height', '1050');
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('lays the card over the photo', async () => {
|
||||
await renderWithProviders(
|
||||
<ContactAside image={image}>
|
||||
<p>Kaart</p>
|
||||
</ContactAside>,
|
||||
);
|
||||
expect(screen.getByTestId('contact-aside')).toContainElement(
|
||||
screen.getByText('Kaart'),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Box, chakra, Image } from '@chakra-ui/react';
|
||||
import type { ContentImage } from '@/content/types';
|
||||
|
||||
// The media query from where the aside shows (theme breakpoint lg)
|
||||
export const ASIDE_MEDIA = '(min-width: 64em)';
|
||||
|
||||
// A transparent 1×1 GIF: what phones get instead of the photo
|
||||
const NO_PHOTO =
|
||||
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||
|
||||
type ContactAsideProps = {
|
||||
image: ContentImage;
|
||||
// The contact card, laid over the bottom of the photo
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
// The right column of the contact page on wide screens: the photo with the
|
||||
// contact card overlapping its bottom edge (mockup 1a, BR-CP-06..09).
|
||||
// Hidden below lg; there the picture's source does not apply, so phones
|
||||
// never download the photo. On wide screens it is the largest paint, so it
|
||||
// loads straight away with high priority.
|
||||
export default function ContactAside({ image, children }: ContactAsideProps) {
|
||||
return (
|
||||
<Box
|
||||
display={{ base: 'none', lg: 'block' }}
|
||||
position="relative"
|
||||
// Room below the photo for the part of the card that sticks out
|
||||
pb="7rem"
|
||||
data-testid="contact-aside"
|
||||
>
|
||||
<chakra.picture display="block">
|
||||
<source media={ASIDE_MEDIA} srcSet={image.src} />
|
||||
<Image
|
||||
src={NO_PHOTO}
|
||||
alt={image.alt}
|
||||
htmlWidth={image.width}
|
||||
htmlHeight={image.height}
|
||||
fetchPriority="high"
|
||||
decoding="async"
|
||||
display="block"
|
||||
w="100%"
|
||||
h="auto"
|
||||
aspectRatio="4 / 5"
|
||||
objectFit="cover"
|
||||
// Shown until the photo arrives
|
||||
bg="paper.deep"
|
||||
data-testid="contact-aside-photo"
|
||||
/>
|
||||
</chakra.picture>
|
||||
<Box position="absolute" left={6} right={6} bottom={0}>
|
||||
{children}
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user