Adds the Instagram section to the homepage

Shows the handle as a link to the profile and six square photos from edge
to edge (2, 3 or 6 per row), each linking to the profile in a new tab.
The photos are ones the page already loads, so the section adds no
downloads; the API will later fill it with the real feed. Without a valid
https link to Instagram the section is left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 00:26:41 +02:00
co-authored by Claude Opus 5.5
parent f8905f5586
commit 52c1864a38
13 changed files with 511 additions and 36 deletions
+44
View File
@@ -13,6 +13,7 @@ import { FakeIntersectionObserver } from './test/fakeIntersectionObserver';
import { routeTree } from './routeTree.gen';
import sitePages from './sitePages';
import { axeResults } from './test/axe';
import type { SocialLink } from './content/types';
import system from './theme';
// Laat PageIntro op verzoek crashen, om de foutpagina binnen de shell te testen
@@ -30,6 +31,24 @@ vi.mock('./components/PageIntro/PageIntro', async (importOriginal) => {
};
});
// Lets a test replace the social links, e.g. without a valid Instagram link
const socials = vi.hoisted(() => ({
override: null as SocialLink[] | null,
}));
vi.mock('./content/siteContent', async (importOriginal) => {
const original = (
await importOriginal<typeof import('./content/siteContent')>()
).default;
return {
default: {
...original,
get socials() {
return socials.override ?? original.socials;
},
},
};
});
// The homepage's review carousel (Zag) needs an IntersectionObserver and
// Element.scrollTo, which jsdom lacks
beforeEach(() => {
@@ -39,6 +58,7 @@ beforeEach(() => {
afterEach(() => {
crash.enabled = false;
socials.override = null;
vi.unstubAllGlobals();
FakeIntersectionObserver.reset();
// @ts-expect-error -- jsdom has no Element.scrollTo of its own
@@ -148,6 +168,7 @@ describe('homepage', () => {
screen.getByRole('region', { name: 'Prijzen' }),
screen.getByRole('region', { name: 'Lieve woorden' }),
screen.getByRole('region', { name: 'Contact' }),
screen.getByRole('region', { name: 'Instagram' }),
];
let previous: Element = hero;
@@ -161,6 +182,29 @@ describe('homepage', () => {
expect(screen.getAllByRole('heading', { level: 1 })).toHaveLength(1);
expect(await axeResults(container)).toHaveNoViolations();
});
it.each([
['missing', []],
[
'not https',
[
{
platform: 'instagram',
href: 'http://www.instagram.com/andreaslopfotografie/',
},
],
],
] satisfies [string, SocialLink[]][])(
'leaves out the Instagram section when its link is %s',
async (_, links) => {
socials.override = links;
await renderApp('/');
await screen.findByRole('region', { name: 'Contact' });
expect(
screen.queryByRole('region', { name: 'Instagram' }),
).toBeNull();
},
);
});
describe('homepage ?pakket=', () => {
@@ -34,4 +34,18 @@ describe('HomeSection', () => {
'contact',
);
});
it('leaves out the content column at full width', async () => {
await renderWithProviders(
<HomeSection labelledBy="insta-title" width="full">
<h2 id="insta-title" data-testid="child">
Instagram
</h2>
</HomeSection>,
);
// The heading is a direct child of the section, not of a Container
expect(screen.getByTestId('child').parentElement).toBe(
screen.getByRole('region', { name: 'Instagram' }),
);
});
});
+12 -4
View File
@@ -6,7 +6,9 @@ type HomeSectionProps = {
labelledBy: string;
id?: string;
tone?: 'paper' | 'alt';
width?: 'default' | 'narrow';
// full: no content column, for edge-to-edge content; the section then
// places its own Container around what should stay in the column
width?: 'default' | 'narrow' | 'full';
spacing?: 'default' | 'tight';
'data-testid'?: string;
children: ReactNode;
@@ -34,9 +36,15 @@ export default function HomeSection({
scrollMarginTop={id ? 'header' : undefined}
py={spacing === 'tight' ? 'sectionYTight' : 'sectionY'}
>
<Container maxW={width === 'narrow' ? 'contentNarrow' : 'content'}>
{children}
</Container>
{width === 'full' ? (
children
) : (
<Container
maxW={width === 'narrow' ? 'contentNarrow' : 'content'}
>
{children}
</Container>
)}
</Box>
);
}
@@ -1,3 +1,4 @@
import type { ReactNode } from 'react';
import { Box, Heading, Text } from '@chakra-ui/react';
type SectionHeadingProps = {
@@ -5,7 +6,8 @@ type SectionHeadingProps = {
id: string;
title: string;
eyebrow?: string;
lead?: string;
// Text, or e.g. a link as in the Instagram section
lead?: ReactNode;
align?: 'center' | 'start';
// compact: little space below, for a heading above running text
spacing?: 'default' | 'compact';
@@ -0,0 +1,66 @@
import { screen, within } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import homeContent from '@/content/homeContent';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import InstagramGrid from './InstagramGrid';
const instagram = homeContent.instagram;
const PROFILE = 'https://www.instagram.com/andreaslopfotografie/';
function expectExternal(link: HTMLElement) {
expect(link).toHaveAttribute('href', PROFILE);
expect(link).toHaveAttribute('target', '_blank');
expect(link).toHaveAttribute('rel', 'noopener noreferrer');
}
describe('InstagramGrid', () => {
it('shows the heading and the handle as a link to the profile', async () => {
const { container } = await renderWithProviders(
<InstagramGrid content={instagram} profileUrl={PROFILE} />,
);
const section = screen.getByRole('region', { name: 'Instagram' });
expect(
within(section).getByRole('heading', { level: 2 }),
).toHaveTextContent('Instagram');
const handle = screen.getByTestId('instagram-handle-link');
expect(handle).toHaveAccessibleName(
'@andreaslopfotografie (opent in nieuw tabblad)',
);
expectExternal(handle);
expect(await axeResults(container)).toHaveNoViolations();
});
it('shows six photo tiles in order, each linking to the profile', async () => {
await renderWithProviders(
<InstagramGrid content={instagram} profileUrl={PROFILE} />,
);
const items = within(screen.getByRole('list')).getAllByRole('listitem');
expect(items).toHaveLength(6);
instagram.photos.forEach((photo, index) => {
const tile = screen.getByTestId(`instagram-tile-${index + 1}`);
expect(items[index]).toContainElement(tile);
expectExternal(tile);
expect(tile).toHaveAccessibleName(
`${photo.alt} (Instagram, opent in nieuw tabblad)`,
);
const image = within(tile).getByRole('img');
expect(image).toHaveAttribute('loading', 'lazy');
expect(image).toHaveAttribute('width', String(photo.width));
});
});
it('still renders the heading and handle when there are no photos', async () => {
await renderWithProviders(
<InstagramGrid
content={{ ...instagram, photos: [] }}
profileUrl={PROFILE}
/>,
);
expect(
screen.getByRole('heading', { name: 'Instagram' }),
).toBeInTheDocument();
expect(screen.getByTestId('instagram-handle-link')).toBeInTheDocument();
expect(screen.queryAllByRole('img')).toHaveLength(0);
});
});
@@ -0,0 +1,117 @@
import { Box, chakra, Container, Link, VisuallyHidden } from '@chakra-ui/react';
import DeferredImage from '@/components/DeferredImage/DeferredImage';
import HomeSection from '@/components/HomeSection/HomeSection';
import Reveal from '@/components/Reveal/Reveal';
import SectionHeading from '@/components/SectionHeading/SectionHeading';
import type { HomeContent } from '@/content/types';
const TITLE_ID = 'instagram-title';
type InstagramGridProps = {
content: HomeContent['instagram'];
// A checked https link (visibleSocials); without one the route leaves
// the section out
profileUrl: string;
};
// "Instagram" (design .instagram): the handle as a link to the profile and
// a row of square photos running from edge to edge, each linking to the
// profile too. A fixed selection until the API delivers the real feed.
export default function InstagramGrid({
content,
profileUrl,
}: InstagramGridProps) {
return (
<HomeSection
labelledBy={TITLE_ID}
spacing="tight"
width="full"
data-testid="instagram-grid"
>
<Container maxW="content">
<Reveal>
<SectionHeading
id={TITLE_ID}
title={content.title}
lead={
<Link
variant="underline"
href={profileUrl}
target="_blank"
rel="noopener noreferrer"
data-testid="instagram-handle-link"
>
{/* Space outside the hidden text, or it drops
out of the announced name */}
{content.handle}{' '}
<VisuallyHidden>
(opent in nieuw tabblad)
</VisuallyHidden>
</Link>
}
/>
</Reveal>
</Container>
<Reveal>
{/* The design's 680px and 1100px steps on the theme breakpoints */}
<chakra.ul
listStyleType="none"
display="grid"
gridTemplateColumns={{
base: 'repeat(2, 1fr)',
md: 'repeat(3, 1fr)',
xl: 'repeat(6, 1fr)',
}}
gap="2px"
>
{content.photos.map((photo, i) => (
// The same photo may appear twice in a feed
<chakra.li key={`${i}-${photo.src}`}>
<chakra.a
href={profileUrl}
target="_blank"
rel="noopener noreferrer"
data-testid={`instagram-tile-${i + 1}`}
display="block"
position="relative"
// Keeps the focus ring above the neighbouring
// tiles, which sit only 2px away
_focusVisible={{ zIndex: 1 }}
className="group"
>
<Box overflow="hidden" bg="paper.deep">
<DeferredImage
image={photo}
w="100%"
aspectRatio="1 / 1"
objectFit="cover"
transitionProperty="transform, opacity"
transitionDuration="interaction"
transitionTimingFunction="smooth"
_groupHover={{
transform: 'scale(1.06)',
opacity: 0.85,
}}
_groupFocusVisible={{
transform: 'scale(1.06)',
opacity: 0.85,
}}
// Only the fade, no zoom
_motionReduce={{
transform: 'none !important',
}}
/>
</Box>
{/* The photo's alt names the link; this says
where it goes */}{' '}
<VisuallyHidden>
(Instagram, opent in nieuw tabblad)
</VisuallyHidden>
</chakra.a>
</chakra.li>
))}
</chakra.ul>
</Reveal>
</HomeSection>
);
}
+42 -27
View File
@@ -1,4 +1,5 @@
import type { HomeContent } from './types';
import type { ContentImage, HomeContent } from './types';
import testimonials from './testimonials';
// Images
import intro1 from '../assets/home/intro-1.jpg';
@@ -9,38 +10,42 @@ import andrea from '../assets/home/andrea.jpg';
import deco1 from '../assets/home/deco-1.png';
import deco2 from '../assets/home/deco-2.png';
// Shared by the intro gallery and the Instagram tiles, so one photo keeps
// one description
const introPhotos: ContentImage[] = [
{
src: intro1,
alt: 'Babyhandje in de hand van de moeder, op een gebreid dekentje',
width: 800,
height: 1200,
},
{
src: intro2,
alt: 'Moeder drukt haar pasgeboren baby in een gebreid truitje tegen zich aan',
width: 800,
height: 1200,
},
{
src: intro3,
alt: 'Zwangere vrouw op blote voeten in het zand bij zonsondergang',
width: 800,
height: 1200,
},
{
src: intro4,
alt: 'Aanstaande vader omarmt zijn zwangere partner in de duinen',
width: 800,
height: 1200,
},
];
// Static content of the homepage sections until the CMS API exists; the API
// will then deliver this object.
const homeContent: HomeContent = {
intro: {
title: 'Lifestyle fotografie',
lead: 'Jouw favoriete momenten, vastgelegd op een natuurlijke en ongedwongen manier.',
photos: [
{
src: intro1,
alt: 'Babyhandje in de hand van de moeder, op een gebreid dekentje',
width: 800,
height: 1200,
},
{
src: intro2,
alt: 'Moeder drukt haar pasgeboren baby in een gebreid truitje tegen zich aan',
width: 800,
height: 1200,
},
{
src: intro3,
alt: 'Zwangere vrouw op blote voeten in het zand bij zonsondergang',
width: 800,
height: 1200,
},
{
src: intro4,
alt: 'Aanstaande vader omarmt zijn zwangere partner in de duinen',
width: 800,
height: 1200,
},
],
photos: introPhotos,
},
about: {
eyebrow: 'Over mij',
@@ -73,6 +78,16 @@ const homeContent: HomeContent = {
title: 'Contact',
lead: 'Wil je meer informatie ontvangen? Neem gerust contact met mij op.',
},
instagram: {
title: 'Instagram',
handle: '@andreaslopfotografie',
// Photos the page already loads, so the tiles cost no extra download;
// Andrea can swap them until the API delivers the real feed
photos: [
...introPhotos,
...testimonials.map((testimonial) => testimonial.image),
],
},
};
export default homeContent;
+6
View File
@@ -80,6 +80,12 @@ export interface HomeContent {
title: string;
lead: string;
};
// A fixed selection until the API delivers the real feed (FR-HP-10)
instagram: {
title: string;
handle: string;
photos: ContentImage[];
};
}
export interface HeroSlide {
+12
View File
@@ -2,6 +2,7 @@ import { createFileRoute } from '@tanstack/react-router';
import Hero from '../components/Hero/Hero';
import AboutBlock from '../components/home/AboutBlock/AboutBlock';
import ContactSection from '../components/home/ContactSection/ContactSection';
import InstagramGrid from '../components/home/InstagramGrid/InstagramGrid';
import Pricing from '../components/home/Pricing/Pricing';
import Testimonials from '../components/home/Testimonials/Testimonials';
import IntroGallery from '../components/home/IntroGallery/IntroGallery';
@@ -10,6 +11,7 @@ import homeContent from '../content/homeContent';
import packages from '../content/packages';
import testimonials from '../content/testimonials';
import siteContent from '../content/siteContent';
import { visibleSocials } from '../lib/visibleSocials';
import { pageHead } from '../seo';
// ?pakket= from a "Boek" link on a price card. Only text is kept; whether it
@@ -26,6 +28,10 @@ export const Route = createFileRoute('/')({
// The homepage: the hero, then the sections in the order of LAYOUT.md
function Index() {
const { pakket } = Route.useSearch();
// Without a valid https link the tiles would lead nowhere: no section
const instagram = visibleSocials(siteContent.socials).find(
(social) => social.platform === 'instagram',
);
return (
<>
<Hero content={heroContent} socials={siteContent.socials} />
@@ -43,6 +49,12 @@ function Index() {
email={siteContent.email}
pakket={pakket}
/>
{instagram && (
<InstagramGrid
content={homeContent.instagram}
profileUrl={instagram.href}
/>
)}
</>
);
}