Adds the Contact page #9
@@ -6,8 +6,8 @@
|
||||
const origin = 'http://localhost:4173';
|
||||
|
||||
// Moet gelijk lopen met src/sitePages.ts (een test bewaakt dat)
|
||||
const indexedPaths = ['/', '/over-mij', '/soorten-fotoshoots'];
|
||||
const noindexPaths = ['/portfolio', '/contact', '/privacyverklaring'];
|
||||
const indexedPaths = ['/', '/over-mij', '/soorten-fotoshoots', '/contact'];
|
||||
const noindexPaths = ['/portfolio', '/privacyverklaring'];
|
||||
const notFoundPath = '/bestaat-niet';
|
||||
|
||||
// Homepage mobiel voorlopig 0,8: de foto's zijn nog niet responsive en de
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
+73
-8
@@ -144,10 +144,10 @@ describe('app', () => {
|
||||
).toHaveAttribute('href', '/portfolio');
|
||||
expect(
|
||||
screen.getByRole('link', { name: 'neem contact op' }),
|
||||
).toHaveAttribute('href', '/#contact');
|
||||
).toHaveAttribute('href', '/contact');
|
||||
expect(
|
||||
screen.getByRole('link', { name: 'Boek je shoot' }),
|
||||
).toHaveAttribute('href', '/#contact');
|
||||
).toHaveAttribute('href', '/contact');
|
||||
expect(
|
||||
screen.getByRole('list', { name: "Foto's" }),
|
||||
).toBeInTheDocument();
|
||||
@@ -163,6 +163,71 @@ describe('app', () => {
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('shows the contact page with its outline, cards and structured data', async () => {
|
||||
const { container } = await renderApp('/contact');
|
||||
await screen.findByRole('heading', { level: 1, name: 'Contact' });
|
||||
const main = within(screen.getByRole('main'));
|
||||
// Both cards are in the page; jsdom has no screen width, so the
|
||||
// headings are listed regardless of which layout is visible
|
||||
expect(
|
||||
main
|
||||
.getAllByRole('heading', { hidden: true })
|
||||
.map((h) => `${h.tagName} ${h.textContent}`),
|
||||
).toEqual([
|
||||
'H1 Contact',
|
||||
'H2 Direct contact',
|
||||
'H2 Stuur me een bericht',
|
||||
'H2 Direct contact',
|
||||
]);
|
||||
expect(
|
||||
screen.getByText(/ik reageer binnen 1-2 werkdagen\./),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('region', { name: 'Stuur me een bericht' }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByTestId('contact-details-narrow'),
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByTestId('contact-details-wide')).toBeInTheDocument();
|
||||
expect(
|
||||
await screen.findByTestId('contact-form-shoot', undefined, {
|
||||
timeout: 10_000,
|
||||
}),
|
||||
).toBeInTheDocument();
|
||||
|
||||
expect(document.title).toBe(
|
||||
'Contact – fotoshoot boeken in Huizen | Andrea Slop Fotografie',
|
||||
);
|
||||
expect(document.head.querySelector('meta[name="robots"]')).toBeNull();
|
||||
const types = [
|
||||
...document.querySelectorAll('script[type="application/ld+json"]'),
|
||||
].map((script) => JSON.parse(script.textContent!)['@type']);
|
||||
expect(types.sort()).toEqual(['ContactPage', 'ProfessionalService']);
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('takes over ?pakket= on the contact page and tidies the URL without moving focus', async () => {
|
||||
const { router } = await renderApp('/contact?pakket=newborn');
|
||||
expect(
|
||||
await screen.findByTestId('contact-form-shoot', undefined, {
|
||||
timeout: 10_000,
|
||||
}),
|
||||
).toHaveValue('newborn');
|
||||
await waitFor(() => expect(router.state.location.searchStr).toBe(''));
|
||||
expect(router.state.location.pathname).toBe('/contact');
|
||||
expect(document.activeElement).toBe(document.body);
|
||||
});
|
||||
|
||||
it('drops an unknown ?pakket= on the contact page', async () => {
|
||||
const { router } = await renderApp('/contact?pakket=bruiloft');
|
||||
expect(
|
||||
await screen.findByTestId('contact-form-shoot', undefined, {
|
||||
timeout: 10_000,
|
||||
}),
|
||||
).toHaveValue('');
|
||||
await waitFor(() => expect(router.state.location.searchStr).toBe(''));
|
||||
});
|
||||
|
||||
it('shows the shoot types page with its outline, links and structured data', async () => {
|
||||
const { container } = await renderApp('/soorten-fotoshoots');
|
||||
await screen.findByRole('heading', {
|
||||
@@ -193,11 +258,11 @@ describe('app', () => {
|
||||
.getAllByRole('link', { name: /^Stuur een berichtje/ })
|
||||
.map((link) => link.getAttribute('href')),
|
||||
).toEqual([
|
||||
'/?pakket=newborn#contact',
|
||||
'/?pakket=zwangerschap#contact',
|
||||
'/?pakket=gezin#contact',
|
||||
'/#contact',
|
||||
'/#contact',
|
||||
'/contact?pakket=newborn',
|
||||
'/contact?pakket=zwangerschap',
|
||||
'/contact?pakket=gezin',
|
||||
'/contact',
|
||||
'/contact',
|
||||
]);
|
||||
// Links to the filtered portfolio only once that page is live
|
||||
// (indexed); they switch on by themselves when it is
|
||||
@@ -221,7 +286,7 @@ describe('app', () => {
|
||||
).toHaveAttribute('href', '/#prijzen');
|
||||
expect(
|
||||
screen.getByRole('link', { name: 'Boek je shoot' }),
|
||||
).toHaveAttribute('href', '/#contact');
|
||||
).toHaveAttribute('href', '/contact');
|
||||
|
||||
expect(document.title).toBe(
|
||||
'Soorten fotoshoots | Andrea Slop Fotografie',
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
@@ -6,7 +6,7 @@ import {
|
||||
Link,
|
||||
VisuallyHidden,
|
||||
} from '@chakra-ui/react';
|
||||
import mailOutlined from '@iconify-icons/ant-design/mail-outlined';
|
||||
import mailFilled from '@iconify-icons/ant-design/mail-filled';
|
||||
import { Icon } from '@iconify/react/offline';
|
||||
import Eyebrow from '@/components/Eyebrow/Eyebrow';
|
||||
import socialPlatforms from '@/content/socialPlatforms';
|
||||
@@ -27,7 +27,7 @@ type ContactDetailsProps = {
|
||||
|
||||
const iconOf = (channel: ContactChannel) =>
|
||||
channel.kind === 'email'
|
||||
? mailOutlined
|
||||
? mailFilled
|
||||
: socialPlatforms[channel.platform].icon;
|
||||
|
||||
// "Direct contact": a card with the ways to reach Andrea, each an icon and a
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('AboutIntro', () => {
|
||||
).toHaveAttribute('href', '/portfolio');
|
||||
expect(
|
||||
within(section).getByRole('link', { name: 'neem contact op' }),
|
||||
).toHaveAttribute('href', '/#contact');
|
||||
).toHaveAttribute('href', '/contact');
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ describe('ShootBlock', () => {
|
||||
const link = screen.getByRole('link', {
|
||||
name: 'Stuur een berichtje over een zwangerschapsshoot',
|
||||
});
|
||||
expect(link).toHaveAttribute('href', '/?pakket=zwangerschap#contact');
|
||||
expect(link).toHaveAttribute('href', '/contact?pakket=zwangerschap');
|
||||
});
|
||||
|
||||
it('links to the contact form without a package when the shoot has none', async () => {
|
||||
@@ -58,7 +58,7 @@ describe('ShootBlock', () => {
|
||||
screen.getByRole('link', {
|
||||
name: 'Stuur een berichtje over een loveshoot',
|
||||
}),
|
||||
).toHaveAttribute('href', '/#contact');
|
||||
).toHaveAttribute('href', '/contact');
|
||||
});
|
||||
|
||||
it('only links to the portfolio once it is live', async () => {
|
||||
|
||||
@@ -26,8 +26,7 @@ const aboutContent: AboutPageContent = {
|
||||
'Nieuwsgierig naar mijn werk? Bekijk ',
|
||||
{ text: 'mijn portfolio', to: '/portfolio' },
|
||||
' of ',
|
||||
// The homepage contact section until /contact exists
|
||||
{ text: 'neem contact op', to: '/', hash: 'contact' },
|
||||
{ text: 'neem contact op', to: '/contact' },
|
||||
' voor een fotoshoot!',
|
||||
],
|
||||
],
|
||||
@@ -65,7 +64,7 @@ const aboutContent: AboutPageContent = {
|
||||
'Wanneer ik niet achter de camera sta ben ik bezig met tekenen, schilderen of lezen.',
|
||||
],
|
||||
},
|
||||
booking: { label: 'Boek je shoot', to: '/', hash: 'contact' },
|
||||
booking: { label: 'Boek je shoot', to: '/contact' },
|
||||
person: {
|
||||
name: 'Andrea Slop',
|
||||
jobTitle: 'Lifestyle fotograaf',
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { ContactPageContent } from './types';
|
||||
|
||||
// Images
|
||||
import photo from '../assets/contact/contact.jpg';
|
||||
import portrait from '../assets/contact/contact-portret.jpg';
|
||||
|
||||
// Static content of the contact page until the CMS API exists (FR-CP-01,
|
||||
// FR-CP-04, FR-CP-05)
|
||||
const contactContent: ContactPageContent = {
|
||||
head: {
|
||||
eyebrow: 'Neem contact op',
|
||||
title: 'Contact',
|
||||
intro: 'Wil je een fotoshoot boeken of meer informatie ontvangen? Stuur me een berichtje, ik reageer binnen {reactietermijn}.',
|
||||
},
|
||||
formTitle: 'Stuur me een bericht',
|
||||
detailsTitle: 'Direct contact',
|
||||
image: {
|
||||
src: photo,
|
||||
alt: 'Andrea Slop kijkt lachend over haar schouder, met haar camera in de hand, op een bospad',
|
||||
width: 840,
|
||||
height: 1050,
|
||||
},
|
||||
portrait: {
|
||||
src: portrait,
|
||||
// Decorative next to the heading; the card does not use this text
|
||||
alt: 'Andrea Slop',
|
||||
width: 144,
|
||||
height: 144,
|
||||
},
|
||||
};
|
||||
|
||||
export default contactContent;
|
||||
@@ -16,7 +16,7 @@ const shootTypesPageContent: ShootTypesPageContent = {
|
||||
' op de homepage of stel je vraag via het contactformulier.',
|
||||
],
|
||||
// The homepage contact section until /contact exists
|
||||
booking: { label: 'Boek je shoot', to: '/', hash: 'contact' },
|
||||
booking: { label: 'Boek je shoot', to: '/contact' },
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -166,6 +166,20 @@ export interface AboutPageContent {
|
||||
person: { name: string; jobTitle: string; knowsAbout: string[] };
|
||||
}
|
||||
|
||||
// Content of the contact page (/contact). The intro has one placeholder,
|
||||
// {reactietermijn}, filled in with siteContent.contactForm.replyTime.
|
||||
export interface ContactPageContent {
|
||||
head: { eyebrow: string; title: string; intro: string };
|
||||
// Heading of the form, only for assistive technology
|
||||
formTitle: string;
|
||||
// Heading of the contact card
|
||||
detailsTitle: string;
|
||||
// 4:5 photo next to the form on wide screens
|
||||
image: ContentImage;
|
||||
// Small square crop for the round photo in the card on narrow screens
|
||||
portrait: ContentImage;
|
||||
}
|
||||
|
||||
// Content of the shoot types page (/soorten-fotoshoots); the shoots
|
||||
// themselves come from shootTypes
|
||||
export interface ShootTypesPageContent {
|
||||
|
||||
@@ -16,16 +16,14 @@ const shoot = (id: string) => shootTypes.find((item) => item.id === id)!;
|
||||
describe('shootContactLink', () => {
|
||||
it('preselects the package of a shoot that has one', () => {
|
||||
expect(shootContactLink(shoot('newborn'), packages)).toEqual({
|
||||
to: '/',
|
||||
to: '/contact',
|
||||
search: { pakket: 'newborn' },
|
||||
hash: 'contact',
|
||||
});
|
||||
});
|
||||
|
||||
it('links without a package for a shoot that has none', () => {
|
||||
expect(shootContactLink(shoot('loveshoot'), packages)).toEqual({
|
||||
to: '/',
|
||||
hash: 'contact',
|
||||
to: '/contact',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,14 +33,13 @@ describe('shootContactLink', () => {
|
||||
shoot('gezin'),
|
||||
packages.filter((pkg) => pkg.id !== 'gezin'),
|
||||
),
|
||||
).toEqual({ to: '/', hash: 'contact' });
|
||||
).toEqual({ to: '/contact' });
|
||||
});
|
||||
|
||||
it('always goes to the contact section (invariant)', () => {
|
||||
it('always goes to the contact page (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(shootType, fc.array(anyPackage), (item, list) => {
|
||||
const link = shootContactLink(item, list);
|
||||
return link.to === '/' && link.hash === 'contact';
|
||||
return shootContactLink(item, list).to === '/contact';
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -3,9 +3,8 @@ import type { RoutePath } from '../navigation.ts';
|
||||
import type { PageMeta } from '../sitePages.ts';
|
||||
import { visiblePackages } from './visiblePackages.ts';
|
||||
|
||||
// Where "Stuur een berichtje" goes: the homepage contact section, with the
|
||||
// shoot's package preselected when that package is shown (BR-SF-01..03).
|
||||
// Once /contact exists, only this function changes.
|
||||
// Where "Stuur een berichtje" goes: the contact page, with the shoot's
|
||||
// package preselected when that package is shown (BR-SF-01..03, FR-CP-09)
|
||||
export function shootContactLink(
|
||||
shoot: ShootType,
|
||||
packages: readonly PricingPackage[],
|
||||
@@ -14,12 +13,8 @@ export function shootContactLink(
|
||||
(pkg) => pkg.id === shoot.packageId,
|
||||
);
|
||||
return shown && shoot.packageId !== undefined
|
||||
? {
|
||||
to: '/' as const,
|
||||
search: { pakket: shoot.packageId },
|
||||
hash: 'contact',
|
||||
}
|
||||
: { to: '/' as const, hash: 'contact' };
|
||||
? { to: '/contact' as const, search: { pakket: shoot.packageId } }
|
||||
: { to: '/contact' as const };
|
||||
}
|
||||
|
||||
// "Bekijk meer …foto's": the portfolio filtered on this shoot type
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import fc from 'fast-check';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import contactContent from '../content/contactContent';
|
||||
import siteContent from '../content/siteContent';
|
||||
import { REPLY_TIME_PLACEHOLDER, withReplyTime } from './withReplyTime';
|
||||
|
||||
// Text with some placeholders in it, as an editor might write it. Plain
|
||||
// pieces have no braces: half a placeholder around a real one could
|
||||
// otherwise form a new one, which content never contains.
|
||||
const plain = fc.string().filter((text) => !/[{}]/.test(text));
|
||||
const template = fc
|
||||
.array(fc.oneof(plain, fc.constant(REPLY_TIME_PLACEHOLDER)))
|
||||
.map((pieces) => pieces.join(''));
|
||||
const replyTime = fc
|
||||
.string()
|
||||
.filter((value) => !value.includes(REPLY_TIME_PLACEHOLDER));
|
||||
|
||||
describe('withReplyTime', () => {
|
||||
it('fills in the reply time of the site in the contact intro', () => {
|
||||
expect(
|
||||
withReplyTime(
|
||||
contactContent.head.intro,
|
||||
siteContent.contactForm.replyTime,
|
||||
),
|
||||
).toBe(
|
||||
'Wil je een fotoshoot boeken of meer informatie ontvangen? Stuur me een berichtje, ik reageer binnen 1-2 werkdagen.',
|
||||
);
|
||||
});
|
||||
|
||||
it('leaves no placeholder behind (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(template, replyTime, (text, time) => {
|
||||
expect(withReplyTime(text, time)).not.toContain(
|
||||
REPLY_TIME_PLACEHOLDER,
|
||||
);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('returns text without the placeholder as it is (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(
|
||||
fc.string().filter((t) => !t.includes(REPLY_TIME_PLACEHOLDER)),
|
||||
fc.string(),
|
||||
(text, time) => {
|
||||
expect(withReplyTime(text, time)).toBe(text);
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it('puts the reply time exactly where the placeholders were (oracle)', () => {
|
||||
fc.assert(
|
||||
fc.property(fc.array(plain), replyTime, (pieces, time) => {
|
||||
const text = pieces.join(REPLY_TIME_PLACEHOLDER);
|
||||
expect(withReplyTime(text, time)).toBe(pieces.join(time));
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
// The placeholder for the reply time in content texts (BR-CP-05)
|
||||
export const REPLY_TIME_PLACEHOLDER = '{reactietermijn}';
|
||||
|
||||
// Fills in the reply time, so a text and the form's thank-you always name
|
||||
// the same one. Text without the placeholder comes back as it is.
|
||||
export function withReplyTime(text: string, replyTime: string): string {
|
||||
return text.split(REPLY_TIME_PLACEHOLDER).join(replyTime);
|
||||
}
|
||||
@@ -28,15 +28,16 @@ const linkButtonRecipe = defineRecipe({
|
||||
_hover: { bg: 'ink', color: 'paper' },
|
||||
_focusVisible: { bg: 'ink', color: 'paper' },
|
||||
},
|
||||
// Gevuld met het heidegroen
|
||||
// Filled with the deep heidegroen: white on the design's lighter
|
||||
// accent is only 3.58:1, on accent.deep about 5.7:1 (WCAG AA)
|
||||
accent: {
|
||||
borderColor: 'accent',
|
||||
bg: 'accent',
|
||||
borderColor: 'accent.deep',
|
||||
bg: 'accent.deep',
|
||||
color: 'white',
|
||||
_hover: { bg: 'accent.deep', borderColor: 'accent.deep' },
|
||||
_hover: { bg: 'accent.deeper', borderColor: 'accent.deeper' },
|
||||
_focusVisible: {
|
||||
bg: 'accent.deep',
|
||||
borderColor: 'accent.deep',
|
||||
bg: 'accent.deeper',
|
||||
borderColor: 'accent.deeper',
|
||||
},
|
||||
},
|
||||
// Wit, voor over foto's
|
||||
|
||||
@@ -1,17 +1,105 @@
|
||||
import { createFileRoute } from '@tanstack/react-router';
|
||||
import { useEffect } from 'react';
|
||||
import { Box, Grid, Heading, VisuallyHidden } from '@chakra-ui/react';
|
||||
import { createFileRoute, useNavigate } from '@tanstack/react-router';
|
||||
import ContactAside from '../components/contact/ContactAside/ContactAside';
|
||||
import ContactDetails from '../components/ContactDetails/ContactDetails';
|
||||
import ContactPanel from '../components/ContactPanel/ContactPanel';
|
||||
import PageIntro from '../components/PageIntro/PageIntro';
|
||||
import { pageHead } from '../seo';
|
||||
import PageSection from '../components/PageSection/PageSection';
|
||||
import Reveal from '../components/Reveal/Reveal';
|
||||
import contactContent from '../content/contactContent';
|
||||
import packages from '../content/packages';
|
||||
import siteContent from '../content/siteContent';
|
||||
import { withReplyTime } from '../lib/withReplyTime';
|
||||
import { contactPage, pageHead, structuredDataScript } from '../seo';
|
||||
|
||||
// ?pakket= from a link elsewhere on the site. Only text is kept; the panel
|
||||
// checks it against the shown packages (BR-CP-10).
|
||||
type ContactSearch = { pakket?: string };
|
||||
|
||||
const FORM_TITLE_ID = 'contact-form-title';
|
||||
|
||||
export const Route = createFileRoute('/contact')({
|
||||
head: () => pageHead('/contact'),
|
||||
validateSearch: (search: Record<string, unknown>): ContactSearch =>
|
||||
typeof search.pakket === 'string' ? { pakket: search.pakket } : {},
|
||||
head: () => ({
|
||||
...pageHead('/contact'),
|
||||
scripts: [structuredDataScript(contactPage('/contact'))],
|
||||
}),
|
||||
component: Contact,
|
||||
});
|
||||
|
||||
// Placeholder tot de echte pagina er is (noindex via sitePages)
|
||||
// The contact page (mockup 1a): the form next to the photo with the contact
|
||||
// card on wide screens; below lg the card with a small portrait above the
|
||||
// form (BR-CP-01..04). The card is in the page twice, one per layout, so the
|
||||
// reading order always matches what is shown.
|
||||
function Contact() {
|
||||
const { pakket } = Route.useSearch();
|
||||
const navigate = useNavigate();
|
||||
const { head, formTitle, detailsTitle, image, portrait } = contactContent;
|
||||
const { email, socials, contactForm } = siteContent;
|
||||
|
||||
// The panel has taken the package over; tidy the address bar without a
|
||||
// history entry. It is a fresh page, so no scrolling or focus move
|
||||
// (BR-CP-12).
|
||||
useEffect(() => {
|
||||
if (pakket === undefined) return;
|
||||
void navigate({
|
||||
to: '/contact',
|
||||
search: {},
|
||||
replace: true,
|
||||
resetScroll: false,
|
||||
});
|
||||
}, [pakket, navigate]);
|
||||
|
||||
const details = (variant: 'narrow' | 'wide') => (
|
||||
<ContactDetails
|
||||
titleId={`contact-details-${variant}-title`}
|
||||
title={detailsTitle}
|
||||
email={email}
|
||||
socials={socials}
|
||||
portrait={variant === 'narrow' ? portrait : undefined}
|
||||
data-testid={`contact-details-${variant}`}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<PageIntro eyebrow="Neem contact op" title="Contact">
|
||||
Deze pagina is nog in de maak. Kom snel terug!
|
||||
</PageIntro>
|
||||
<>
|
||||
<PageIntro eyebrow={head.eyebrow} title={head.title}>
|
||||
{withReplyTime(head.intro, contactForm.replyTime)}
|
||||
</PageIntro>
|
||||
<PageSection
|
||||
labelledBy={FORM_TITLE_ID}
|
||||
spacing="flushTop"
|
||||
data-testid="contact-page"
|
||||
>
|
||||
<Box display={{ base: 'block', lg: 'none' }} mb={10}>
|
||||
<Reveal>{details('narrow')}</Reveal>
|
||||
</Box>
|
||||
<Grid
|
||||
templateColumns={{ base: '1fr', lg: '3fr 2fr' }}
|
||||
gap="clamp(2rem, 6vw, 5.5rem)"
|
||||
alignItems="start"
|
||||
>
|
||||
<Reveal>
|
||||
<VisuallyHidden asChild>
|
||||
<Heading as="h2" id={FORM_TITLE_ID}>
|
||||
{formTitle}
|
||||
</Heading>
|
||||
</VisuallyHidden>
|
||||
<ContactPanel
|
||||
idPrefix="contact"
|
||||
packages={packages}
|
||||
enabled={contactForm.enabled}
|
||||
email={email}
|
||||
replyTime={contactForm.replyTime}
|
||||
pakket={pakket}
|
||||
load="eager"
|
||||
/>
|
||||
</Reveal>
|
||||
<ContactAside image={image}>{details('wide')}</ContactAside>
|
||||
</Grid>
|
||||
</PageSection>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
areaServed,
|
||||
businessId,
|
||||
canonicalUrl,
|
||||
contactPage,
|
||||
defaultOgImage,
|
||||
jsonLdScript,
|
||||
pageHead,
|
||||
@@ -569,3 +570,55 @@ describe('shootServices', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('the contact page', () => {
|
||||
it('is indexed, with its own title, description and preview image', () => {
|
||||
const head = pageHead('/contact');
|
||||
expect(head.meta[0]).toEqual({
|
||||
title: 'Contact – fotoshoot boeken in Huizen | Andrea Slop Fotografie',
|
||||
});
|
||||
expect(meta(head, 'robots')).toBeUndefined();
|
||||
expect(meta(head, 'og:image')).toMatchObject({
|
||||
content: `${siteUrl}/og-contact.jpg`,
|
||||
});
|
||||
expect(head.links[0].href).toBe(`${siteUrl}/contact`);
|
||||
});
|
||||
|
||||
it('keeps title and description within what search engines show', () => {
|
||||
const page = sitePages['/contact'];
|
||||
// 61: one over the guideline, accepted to keep "Contact" first
|
||||
expect(
|
||||
`${page.title} | Andrea Slop Fotografie`.length,
|
||||
).toBeLessThanOrEqual(61);
|
||||
expect(page.description.length).toBeLessThanOrEqual(155);
|
||||
});
|
||||
|
||||
it('describes the page as a ContactPage about the business', () => {
|
||||
expect(contactPage('/contact')).toEqual({
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'ContactPage',
|
||||
'@id': `${siteUrl}/contact`,
|
||||
url: `${siteUrl}/contact`,
|
||||
name: sitePages['/contact'].title,
|
||||
description: sitePages['/contact'].description,
|
||||
inLanguage: 'nl-NL',
|
||||
about: { '@id': businessId },
|
||||
});
|
||||
});
|
||||
|
||||
it('never contains an e-mail address and survives the script tag (invariant, round trip)', () => {
|
||||
fc.assert(
|
||||
fc.property(
|
||||
fc.constantFrom(...(Object.keys(sitePages) as RoutePath[])),
|
||||
(path) => {
|
||||
const data = contactPage(path);
|
||||
const script = jsonLdScript(data);
|
||||
expect(script).not.toMatch(/@[a-z0-9-]+\.[a-z]/i);
|
||||
expect(JSON.parse(script)).toEqual(data);
|
||||
expect(data['@id']).toBe(canonicalUrl(path));
|
||||
expect(data.about).toEqual({ '@id': businessId });
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -167,6 +167,12 @@ export function aboutPage(
|
||||
});
|
||||
}
|
||||
|
||||
// The contact page, about the business (SEO-CP-03); no e-mail address, for
|
||||
// the same reason as above
|
||||
export function contactPage(path: RoutePath) {
|
||||
return webPage('ContactPage', path, { about: { '@id': businessId } });
|
||||
}
|
||||
|
||||
// An image URL for structured data: bundled images have a path, which
|
||||
// becomes absolute on the site; an absolute URL stays as it is (BR-SF-13)
|
||||
export function absoluteUrl(src: string): string {
|
||||
|
||||
@@ -56,10 +56,16 @@ const sitePages: Record<RoutePath, PageMeta> = {
|
||||
},
|
||||
},
|
||||
'/contact': {
|
||||
title: 'Contact',
|
||||
title: 'Contact – fotoshoot boeken in Huizen',
|
||||
description:
|
||||
'Neem contact op met Andrea Slop Fotografie voor een fotoshoot in Huizen en omgeving. Ik denk graag met je mee over jullie wensen.',
|
||||
indexed: false,
|
||||
'Neem contact op voor een newborn-, zwangerschaps- of gezinsshoot in Huizen, het Gooi en omgeving. Ik denk graag met je mee en reageer binnen 1-2 werkdagen.',
|
||||
indexed: true,
|
||||
ogImage: {
|
||||
path: '/og-contact.jpg',
|
||||
width: 1200,
|
||||
height: 630,
|
||||
alt: 'Andrea Slop met haar camera op een bospad',
|
||||
},
|
||||
},
|
||||
'/privacyverklaring': {
|
||||
title: 'Privacyverklaring',
|
||||
|
||||
@@ -22,6 +22,7 @@ describe('sitemapXml', () => {
|
||||
`${base}/`,
|
||||
`${base}/over-mij`,
|
||||
`${base}/soorten-fotoshoots`,
|
||||
`${base}/contact`,
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
+4
-1
@@ -53,7 +53,10 @@ const config = defineConfig({
|
||||
line: { value: '#e2dad0' }, // hairlines
|
||||
accent: {
|
||||
DEFAULT: { value: '#7f8b76' }, // heidegroen
|
||||
deep: { value: '#5f6a58' }, // accent hover
|
||||
// Text and buttons in heidegroen: white on it meets 4.5:1
|
||||
deep: { value: '#5f6a58' },
|
||||
// Hover on a deep-green button (deep at 75%)
|
||||
deeper: { value: '#475042' },
|
||||
},
|
||||
sand: { value: '#d9cdbc' }, // zachte vlakken en decoratie
|
||||
// Blocks behind the shoot photos, one per shoot type, taken
|
||||
|
||||
Reference in New Issue
Block a user