Adds the Lifestyle fotografie section to the homepage
Adds the first block below the hero: heading, intro and a staggered gallery of four live photos. Brings in the shared section building blocks (HomeSection, SectionHeading, Reveal) and DeferredImage, which holds back below-the-fold photos until the page has loaded so they do not compete with the hero for bandwidth. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import Reveal from './Reveal';
|
||||
|
||||
describe('Reveal', () => {
|
||||
it('renders its content visibly when IntersectionObserver is missing', async () => {
|
||||
await renderWithProviders(
|
||||
<Reveal data-testid="reveal">
|
||||
<p>Inhoud</p>
|
||||
</Reveal>,
|
||||
);
|
||||
expect(screen.getByText('Inhoud')).toBeVisible();
|
||||
expect(screen.getByTestId('reveal')).toHaveAttribute(
|
||||
'data-reveal',
|
||||
'visible',
|
||||
);
|
||||
});
|
||||
|
||||
it('passes element props through, e.g. to render a figure', async () => {
|
||||
await renderWithProviders(
|
||||
<Reveal as="figure" delay={0.16} data-testid="reveal">
|
||||
<span>Foto</span>
|
||||
</Reveal>,
|
||||
);
|
||||
expect(screen.getByTestId('reveal').tagName).toBe('FIGURE');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Box, type BoxProps } from '@chakra-ui/react';
|
||||
import useReveal from '@/hooks/useReveal';
|
||||
|
||||
type RevealProps = BoxProps & {
|
||||
// Seconds to wait before fading in, to stagger items in a row
|
||||
delay?: number;
|
||||
};
|
||||
|
||||
// Fades its content in and up once it scrolls into view (design .reveal).
|
||||
// The content is always in the DOM and readable by assistive technology;
|
||||
// only its opacity and position change.
|
||||
export default function Reveal({ delay = 0, children, ...rest }: RevealProps) {
|
||||
const { ref, visible } = useReveal<HTMLDivElement>();
|
||||
|
||||
return (
|
||||
<Box
|
||||
ref={ref}
|
||||
data-reveal={visible ? 'visible' : 'hidden'}
|
||||
opacity={visible ? 1 : 0}
|
||||
transform={visible ? 'none' : 'translateY(24px)'}
|
||||
transitionProperty="opacity, transform"
|
||||
transitionDuration="reveal"
|
||||
transitionTimingFunction="smooth"
|
||||
transitionDelay={`${delay}s`}
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user