Adds the Over mij section to the homepage
Adds the introduction block with a framed photo of Andrea and a link to the about page. Brings in FramedImage and an underline link variant for the later blocks, and narrows the load margin of deferred photos so nothing below the hero starts loading before the hero has painted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import { act, screen } from '@testing-library/react';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { FakeIntersectionObserver } from '@/test/fakeIntersectionObserver';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import DeferredImage from './DeferredImage';
|
||||
import DeferredImage, { DEFERRED_LOAD_MARGIN } from './DeferredImage';
|
||||
|
||||
const image = {
|
||||
src: '/foto.jpg',
|
||||
@@ -33,7 +33,7 @@ describe('DeferredImage', () => {
|
||||
const [observer] = FakeIntersectionObserver.instances;
|
||||
|
||||
expect(img).not.toHaveAttribute('src');
|
||||
expect(observer.options?.rootMargin).toBe('600px 0px');
|
||||
expect(observer.options?.rootMargin).toBe(DEFERRED_LOAD_MARGIN);
|
||||
|
||||
act(() => observer.trigger(true));
|
||||
expect(img).toHaveAttribute('src', '/foto.jpg');
|
||||
|
||||
@@ -3,8 +3,12 @@ import usePageLoaded from '@/hooks/usePageLoaded';
|
||||
import useInView from '@/hooks/useInView';
|
||||
import type { ContentImage } from '@/content/types';
|
||||
|
||||
// How far below the viewport an image starts loading
|
||||
const LOAD_MARGIN = '600px 0px';
|
||||
// How far outside the viewport an image starts loading. Kept small on
|
||||
// purpose: everything below the full-height hero must be out of range when
|
||||
// the page opens, or its photos start before the hero has painted. In
|
||||
// Lighthouse's throttled simulation that pushed the largest contentful
|
||||
// paint from 3.8 s to 5.3 s whenever the request won the race.
|
||||
export const DEFERRED_LOAD_MARGIN = '200px 0px';
|
||||
|
||||
type DeferredImageProps = Omit<ImageProps, 'src' | 'alt'> & {
|
||||
image: ContentImage;
|
||||
@@ -26,7 +30,7 @@ export default function DeferredImage({
|
||||
}: DeferredImageProps) {
|
||||
const pageLoaded = usePageLoaded();
|
||||
const { ref, inView } = useInView<HTMLImageElement>({
|
||||
rootMargin: LOAD_MARGIN,
|
||||
rootMargin: DEFERRED_LOAD_MARGIN,
|
||||
skip: near !== undefined,
|
||||
});
|
||||
const load = pageLoaded && (near ?? inView);
|
||||
|
||||
Reference in New Issue
Block a user