import { Image } from "../network/models.ts"; import { network } from "../network/network.ts"; export function SquareImage({ image }: { image: Image }) { let cover = false; const imgAspectRatio = image.width / image.height; if (imgAspectRatio > 0.8 && imgAspectRatio < 1.2) { cover = true; } return ( <>
{ const dialog = document.getElementById( `image-dialog-${image.id}`, ) as HTMLDialogElement; dialog.showModal(); }} > {"image"}
{ const dialog = document.getElementById( `image-dialog-${image.id}`, ) as HTMLDialogElement; dialog.close(); }} > {"image"}
); } export function VerticalImage({ image }: { image: Image }) { let cover = false; const imgAspectRatio = image.width / image.height; if (imgAspectRatio < 0.8 && imgAspectRatio > 0.5) { cover = true; } return ( <>
{ const dialog = document.getElementById( `image-dialog-${image.id}`, ) as HTMLDialogElement; dialog.showModal(); }} > {"image"}
{ const dialog = document.getElementById( `image-dialog-${image.id}`, ) as HTMLDialogElement; dialog.close(); }} > {"image"}
); } export function HorizontalImage({ image }: { image: Image }) { let cover = false; const imgAspectRatio = image.width / image.height; if (imgAspectRatio > 1.2 && imgAspectRatio < 2) { cover = true; } return ( <>
{ const dialog = document.getElementById( `image-dialog-${image.id}`, ) as HTMLDialogElement; dialog.showModal(); }} > {"image"}
{ const dialog = document.getElementById( `image-dialog-${image.id}`, ) as HTMLDialogElement; dialog.close(); }} > {"image"}
); } export function ImageGrid({ images }: { images: Image[] }) { let verticalCount = 0; let horizontalCount = 0; for (const image of images) { const imgAspectRatio = image.width / image.height; if (imgAspectRatio < 0.8) { verticalCount++; } else if (imgAspectRatio > 1.2) { horizontalCount++; } } if (verticalCount / images.length > 0.5) { return (
{images.map((image) => ( ))}
); } else if (horizontalCount / images.length > 0.5) { return (
{images.map((image) => ( ))}
); } else { return (
{images.map((image) => ( ))}
); } }