Adds the fallbacks for visitors without JavaScript
The mobile menu works through CSS, and controls that need JavaScript are hidden without it. The contact photo gets its own preload, and the tests cover the new Reveal behaviour, the first row and the noscript markup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import fc from 'fast-check';
|
||||
import type { ContentImage } from '@/content/types';
|
||||
import { galleryItems } from './arbitraries';
|
||||
|
||||
export type ColumnMap = {
|
||||
media: string | null;
|
||||
columns: number;
|
||||
}[];
|
||||
|
||||
// Column counts per screen width as a grid can have them: a base count and up
|
||||
// to three breakpoints, the counts and the widths both strictly increasing
|
||||
export const columnMap: fc.Arbitrary<ColumnMap> = fc
|
||||
.tuple(
|
||||
fc.integer({ min: 1, max: 3 }),
|
||||
fc.uniqueArray(fc.integer({ min: 20, max: 120 }), {
|
||||
minLength: 0,
|
||||
maxLength: 3,
|
||||
}),
|
||||
fc.array(fc.integer({ min: 1, max: 3 }), {
|
||||
minLength: 3,
|
||||
maxLength: 3,
|
||||
}),
|
||||
)
|
||||
.map(([base, widths, steps]) => {
|
||||
const sorted = [...widths].sort((a, b) => a - b);
|
||||
let columns = base;
|
||||
return [
|
||||
{ media: null, columns },
|
||||
...sorted.map((width, index) => {
|
||||
columns += steps[index];
|
||||
return { media: `(min-width: ${width}em)`, columns };
|
||||
}),
|
||||
];
|
||||
});
|
||||
|
||||
// The position of a tile in the grid, a little beyond the widest row
|
||||
export const tileIndex: fc.Arbitrary<number> = fc.integer({ min: 0, max: 12 });
|
||||
|
||||
// Unfiltered grid photos, in the shape the preloads are built from
|
||||
export const galleryItemsWithThumbs: fc.Arbitrary<{ thumb: ContentImage }[]> =
|
||||
galleryItems.map((items) => items.map(({ thumb }) => ({ thumb })));
|
||||
@@ -0,0 +1,45 @@
|
||||
import fc from 'fast-check';
|
||||
import type { RevealEvent, RevealPhase } from '@/lib/revealPhase';
|
||||
|
||||
// Heights of real screens, so the shrunk examples read like phones and desktops
|
||||
const screenHeights = [568, 640, 667, 740, 823, 844, 900, 940, 1024, 1080];
|
||||
|
||||
export const viewportHeight: fc.Arbitrary<number> = fc.oneof(
|
||||
fc.constantFrom(...screenHeights),
|
||||
fc.integer({ min: 1, max: 4000 }),
|
||||
fc.double({ min: 1, max: 4000, noNaN: true }),
|
||||
);
|
||||
|
||||
// The top edge of an element relative to the viewport: above it (negative),
|
||||
// at its top, anywhere on screen and far below. `display: none` and jsdom
|
||||
// give zero.
|
||||
export const elementTop: fc.Arbitrary<number> = fc.oneof(
|
||||
fc.constant(0),
|
||||
fc.integer({ min: -20000, max: 20000 }),
|
||||
fc.double({ min: -20000, max: 20000, noNaN: true }),
|
||||
fc.integer({ min: 4000, max: 100000 }),
|
||||
);
|
||||
|
||||
// An element top given relative to the viewport height, for the cases where
|
||||
// the edge itself matters: just above, exactly at and just below it
|
||||
export const topNearViewportEdge: fc.Arbitrary<{
|
||||
viewportHeight: number;
|
||||
top: number;
|
||||
}> = fc
|
||||
.tuple(viewportHeight, fc.constantFrom(-1000, -1, -0.5, 0, 0.5, 1, 1000))
|
||||
.map(([height, offset]) => ({
|
||||
viewportHeight: height,
|
||||
top: height + offset,
|
||||
}));
|
||||
|
||||
export const revealPhase: fc.Arbitrary<RevealPhase> = fc.constantFrom<
|
||||
RevealPhase[]
|
||||
>('settled', 'hidden', 'revealed');
|
||||
|
||||
export const revealEvent: fc.Arbitrary<RevealEvent> = fc.constantFrom<
|
||||
RevealEvent[]
|
||||
>('belowViewport', 'inView', 'intersected');
|
||||
|
||||
export const revealEvents: fc.Arbitrary<RevealEvent[]> = fc.array(revealEvent, {
|
||||
maxLength: 20,
|
||||
});
|
||||
Reference in New Issue
Block a user