32 lines · 839 B · TypeScript
RawDownload
export interface ExpandedImageItem {  src: string;  name: string;} export interface ExpandedImagePreview {  images: ExpandedImageItem[];  index: number;} export function buildExpandedImagePreview(  images: ReadonlyArray<{ id: string; name: string; previewUrl?: string }>,  selectedImageId: string,): ExpandedImagePreview | null {  const previewableImages = images.flatMap((image) =>    image.previewUrl ? [{ id: image.id, src: image.previewUrl, name: image.name }] : [],  );  if (previewableImages.length === 0) {    return null;  }  const selectedIndex = previewableImages.findIndex((image) => image.id === selectedImageId);  if (selectedIndex < 0) {    return null;  }  return {    images: previewableImages.map((image) => ({      src: image.src,      name: image.name,    })),    index: selectedIndex,  };}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t