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:
@@ -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>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user