Shares the contact form, contact card and privacy line

ContactPanel holds the coming-soon gate, the shoot options, the package
chosen via ?pakket= and the form, which loads as its own chunk either
when it comes near the screen (homepage) or right away (contact page).
ContactDetails shows the ways to reach Andrea as a card with icons. A
privacy line now sits under the form and under the coming-soon notice,
and the reply time in the thank-you comes from the site content.
Instagram is listed before Facebook, so the footer and hero follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 18:26:48 +01:00
co-authored by Claude Opus 5.5
parent 4c257b7ac0
commit 26a8bd9469
20 changed files with 789 additions and 90 deletions
+154
View File
@@ -0,0 +1,154 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import siteContent from '../content/siteContent';
import socialPlatforms from '../content/socialPlatforms';
import { anyEmail, socialLink } from '../test/arbitraries';
import { contactChannels } from './contactChannels';
import { emailAddress } from './emailAddress';
import { visibleSocials } from './visibleSocials';
const socialLinks = fc.array(socialLink, { maxLength: 5 });
describe('contactChannels', () => {
it('lists e-mail, Instagram and Facebook for the site content', () => {
expect(contactChannels(siteContent.email, siteContent.socials)).toEqual(
[
{
kind: 'email',
href: 'mailto:info@andreaslop.nl?subject=Vraag%20via%20andreaslop.nl',
label: 'info@andreaslop.nl',
external: false,
},
{
kind: 'social',
platform: 'instagram',
href: 'https://www.instagram.com/andreaslopfotografie/',
label: '@andreaslopfotografie',
external: true,
},
{
kind: 'social',
platform: 'facebook',
href: 'https://www.facebook.com/andreaslopfotografie/',
label: 'Andrea Slop Fotografie',
external: true,
},
],
);
});
it('leaves out an invalid e-mail address and invalid links', () => {
const channels = contactChannels({ user: 'info', domain: 'nodot' }, [
{ platform: 'facebook', href: 'javascript:alert(1)' },
{ platform: 'instagram', href: 'https://instagram.com/x' },
]);
expect(channels.map((channel) => channel.kind)).toEqual(['social']);
});
it('falls back to the platform name without a usable label', () => {
const channels = contactChannels({ user: '', domain: '' }, [
{ platform: 'instagram', href: 'https://instagram.com/x' },
{
platform: 'facebook',
href: 'https://facebook.com/x',
label: ' ',
},
]);
expect(channels.map((channel) => channel.label)).toEqual([
'Instagram',
'Facebook',
]);
});
it('is empty when nothing is valid', () => {
expect(contactChannels({ user: '', domain: '' }, [])).toEqual([]);
});
it('puts the e-mail channel first exactly when the address is valid (invariant)', () => {
fc.assert(
fc.property(anyEmail, socialLinks, (email, socials) => {
const channels = contactChannels(email, socials);
const valid = emailAddress(email) !== null;
expect(channels[0]?.kind === 'email').toBe(valid);
expect(
channels.filter((channel) => channel.kind === 'email'),
).toHaveLength(valid ? 1 : 0);
}),
);
});
it('shows exactly the visible social links, in order (oracle)', () => {
fc.assert(
fc.property(anyEmail, socialLinks, (email, socials) => {
const shown = contactChannels(email, socials).flatMap(
(channel) =>
channel.kind === 'social'
? [
{
platform: channel.platform,
href: channel.href,
},
]
: [],
);
expect(shown).toEqual(
visibleSocials(socials).map(({ platform, href }) => ({
platform,
href,
})),
);
}),
);
});
it('labels a social link with its trimmed label, or else the platform name (invariant)', () => {
fc.assert(
fc.property(socialLinks, (socials) => {
const channels = contactChannels(
{ user: '', domain: '' },
socials,
);
visibleSocials(socials).forEach((link, index) => {
const expected =
link.label?.trim() ||
socialPlatforms[link.platform].name;
expect(channels[index].label).toBe(expected);
expect(channels[index].label.trim()).not.toBe('');
});
}),
);
});
it('only links to mailto: or https: (invariant)', () => {
fc.assert(
fc.property(anyEmail, socialLinks, (email, socials) => {
for (const channel of contactChannels(email, socials)) {
const scheme = new URL(channel.href).protocol;
expect(
channel.kind === 'email' ? 'mailto:' : 'https:',
).toBe(scheme);
}
}),
);
});
it('opens exactly the social channels in a new tab (invariant)', () => {
fc.assert(
fc.property(anyEmail, socialLinks, (email, socials) => {
for (const channel of contactChannels(email, socials)) {
expect(channel.external).toBe(channel.kind === 'social');
}
}),
);
});
it('has at most one channel per link plus the e-mail (invariant)', () => {
fc.assert(
fc.property(anyEmail, socialLinks, (email, socials) => {
expect(
contactChannels(email, socials).length,
).toBeLessThanOrEqual(1 + socials.length);
}),
);
});
});
+48
View File
@@ -0,0 +1,48 @@
import socialPlatforms, {
type SocialPlatform,
} from '../content/socialPlatforms.ts';
import type { EmailAddress, SocialLink } from '../content/types.ts';
import { emailAddress } from './emailAddress.ts';
import { mailSubject, mailtoLink } from './mailLink.ts';
import { visibleSocials } from './visibleSocials.ts';
// One way to reach Andrea, as the contact card shows it
export type ContactChannel =
| { kind: 'email'; href: string; label: string; external: false }
| {
kind: 'social';
platform: SocialPlatform;
href: string;
label: string;
// Opens in a new tab (BR-CD-05)
external: true;
};
// The channels of the contact card (BR-CD-01..05): the e-mail address first
// when it is valid, then the valid social links in content order, each with
// its label or else the platform name. Only mailto: and https: links come
// out, because both helpers already drop everything else.
export function contactChannels(
email: EmailAddress,
socials: readonly SocialLink[],
): ContactChannel[] {
const address = emailAddress(email);
const mail: ContactChannel[] = address
? [
{
kind: 'email',
href: mailtoLink(address, mailSubject()),
label: address,
external: false,
},
]
: [];
const social = visibleSocials(socials).map((link): ContactChannel => ({
kind: 'social',
platform: link.platform,
href: link.href,
label: link.label?.trim() || socialPlatforms[link.platform].name,
external: true,
}));
return [...mail, ...social];
}