# Component Methods — Portfolio Page Signatures only; the rules behind them (edge cases, invariants, properties) follow in Functional Design for units 2 and 3. Types are TypeScript; names are working names. ## Types ```ts // content/types.ts (unit 2: GalleryItem lives next to ContentImage) interface ImageSource { src: string; width: number; height: number } // What the generic components show interface GalleryItem { id: string; thumb: ContentImage; // grid size (~800 px), alt text included full: ImageSource; // lightbox size (~1600–2000 px), same alt as thumb caption?: string; // visible caption in the lightbox } // unit 3 interface PortfolioPhoto { id: string; shootType: ShootTypeId; // from the soorten-fotoshoots commit thumb: ContentImage; full: ImageSource; } interface PortfolioContent { intro: { eyebrow: string; title: string; text: string }; photos: PortfolioPhoto[]; } // unit 1 interface InstagramContent { title: string; handle: string; photos: ContentImage[]; } interface FilterOption { id: string; label: string } ``` ## Components (props) ```ts // unit 1 InstagramGrid({ content: InstagramContent; profileUrl: string }) // unit 2 PortfolioGrid({ items: readonly GalleryItem[]; eagerCount?: number; // default 3 onOpen: (index: number) => void; onIntent?: () => void; // hover/focus: preload the lightbox code 'data-testid'?: string; }) Lightbox({ items: readonly GalleryItem[]; index: number | null; // null = closed onIndexChange: (index: number) => void; onClose: () => void; label?: string; // dialog name, default "Foto groot bekijken" finalFocusRef?: RefObject // or a getter for the tile to return to }) FilterBar({ options: readonly FilterOption[]; value: string; onChange: (id: string) => void; label: string; // group name, e.g. "Filter op soort shoot" }) // unit 3 PortfolioGallery({ photos: readonly PortfolioPhoto[]; shootTypes: readonly ShootType[]; shoot: ShootTypeId | undefined; // active filter from the route onShootChange: (shoot: ShootTypeId | undefined) => void; }) ``` ## Hooks ```ts // hooks/useSwipe.ts (unit 2) useSwipe(options: { onPrev: () => void; onNext: () => void; enabled?: boolean }): { onTouchStart: TouchEventHandler; onTouchEnd: TouchEventHandler } ``` ## Pure helpers (`lib/`, 100% coverage threshold, example + property-based tests) ```ts // unit 2 wrapIndex(index: number, count: number): number // position within 0..count-1, wrapping both ways (also used by useHeroSlider) swipeDirection(start: Point, end: Point, threshold?: number): 'prev' | 'next' | null masonryRowSpan(image: { width: number; height: number }, rowsPerColumnWidth: number): number // number of implicit rows an item spans, from its aspect ratio neighbourIndexes(index: number, count: number): number[] // which large images to preload around the current one // unit 3 shootTypesWithPhotos(shootTypes: readonly ShootType[], photos: readonly PortfolioPhoto[]): ShootType[] // in list order; also offered to soorten-fotoshoots shootFromSearch(value: unknown, available: readonly ShootTypeId[]): ShootTypeId | undefined // allowlist check for ?shoot= (like packageFromSearch) filterPhotos(photos: readonly PortfolioPhoto[], shoot: ShootTypeId | undefined): PortfolioPhoto[] filterOptions(shootTypes: readonly ShootType[], allLabel: string): FilterOption[] // "Alles" first, then one option per shoot type (label = name) toGalleryItems(photos: readonly PortfolioPhoto[], shootTypes: readonly ShootType[]): GalleryItem[] // caption = shootLabel photoCountLabel(count: number): string // "1 foto" / "4 foto's" ``` ## SEO (`seo.ts`, unit 3) ```ts galleryImages(photos: readonly PortfolioPhoto[], base?: string): ImageObject[] // contentUrl/thumbnailUrl absolute https, description = alt, creator → personId, copyrightHolder → businessId // head: structuredDataScript(webPage('ImageGallery', '/portfolio', { associatedMedia: galleryImages(...) })) ```