A masonry photo grid that keeps the reading order (pure CSS, no measuring in the browser), an accessible lightbox on Chakra's Dialog with wrap-around browsing, keys, swipe and preloading, and a filter bar of toggle buttons. They work on generic gallery items, so other pages can use them. The swipe logic moves out of the hero into a shared hook; the hero behaves as before. The rules behind them live in pure helpers with property-based tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 lines
311 B
TypeScript
7 lines
311 B
TypeScript
// A position in a list of `count` items that wraps around both ways: one
|
|
// past the last is the first, one before the first is the last. Used for
|
|
// browsing photos in the hero and the lightbox.
|
|
export function wrapIndex(index: number, count: number): number {
|
|
return ((index % count) + count) % count;
|
|
}
|