Adds the Contact section to the homepage
Adds the contact form with the live fields, validation and browser-side anti-spam, behind a coming-soon notice with a mail button until the API exists. A "Boek" link on a price card selects its package, tidies the URL and moves focus to the form. The form loads only when it comes near the screen, so the hero does not wait for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Box, chakra, Link, Text, useRecipe } from '@chakra-ui/react';
|
||||
import type { EmailAddress } from '@/content/types';
|
||||
import { emailAddress } from '@/lib/emailAddress';
|
||||
import { mailtoLink } from '@/lib/mailLink';
|
||||
|
||||
type ContactFormGateProps = {
|
||||
enabled: boolean;
|
||||
email: EmailAddress;
|
||||
subject: string;
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
// Until there is a back-end the form stays visible but dimmed and inert
|
||||
// under a "coming soon" notice with a mail button (FR-HP-07). inert keeps
|
||||
// keyboard and screen reader users out of a form that does nothing.
|
||||
export default function ContactFormGate({
|
||||
enabled,
|
||||
email,
|
||||
subject,
|
||||
children,
|
||||
}: ContactFormGateProps) {
|
||||
const linkButton = useRecipe({ key: 'linkButton' });
|
||||
if (enabled) return <>{children}</>;
|
||||
|
||||
// Assembled in the browser, so the address is nowhere in the bundle
|
||||
const address = emailAddress(email);
|
||||
const href = address ? mailtoLink(address, subject) : undefined;
|
||||
|
||||
return (
|
||||
<Box position="relative" data-testid="contact-gate">
|
||||
<Box inert opacity={0.35} filter="blur(1.5px)" userSelect="none">
|
||||
{children}
|
||||
</Box>
|
||||
<Box
|
||||
position="absolute"
|
||||
top="50%"
|
||||
left="50%"
|
||||
transform="translate(-50%, -50%)"
|
||||
w="min(100%, 520px)"
|
||||
p="clamp(2rem, 4vw, 3rem)"
|
||||
bg="white"
|
||||
borderWidth="1px"
|
||||
borderColor="line"
|
||||
boxShadow="panel"
|
||||
textAlign="center"
|
||||
data-testid="contact-gate-notice"
|
||||
>
|
||||
{/* accent.deep instead of the design's accent: meets 4.5:1 */}
|
||||
<Text textStyle="eyebrow" color="accent.deep" mb={4}>
|
||||
Binnenkort
|
||||
</Text>
|
||||
<Text color="ink.soft" mb={address ? 7 : 0}>
|
||||
Het contactformulier komt binnenkort.
|
||||
{address && (
|
||||
<>
|
||||
{' Mail me voor nu op '}
|
||||
<Link variant="underline" href={href}>
|
||||
{address}
|
||||
</Link>
|
||||
</>
|
||||
)}
|
||||
</Text>
|
||||
{address && (
|
||||
<chakra.a
|
||||
href={href}
|
||||
css={linkButton({ variant: 'accent' })}
|
||||
data-testid="contact-gate-mail"
|
||||
>
|
||||
Stuur een e-mail
|
||||
</chakra.a>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user