From 613aa178491df3298c1957bd090b6d5a3d1587ca Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Mon, 24 Feb 2025 18:24:56 -0600 Subject: [PATCH] Refine recipe overlay demo --- app/admin/recipe/page.tsx | 59 +++++++++++++++----------------- src/photo/PhotoRecipeOverlay.tsx | 41 +++++++++++++--------- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/app/admin/recipe/page.tsx b/app/admin/recipe/page.tsx index af6cbb9f..5329b230 100644 --- a/app/admin/recipe/page.tsx +++ b/app/admin/recipe/page.tsx @@ -1,38 +1,33 @@ -import { getPhotos } from '@/photo/db/query'; +import { getPhoto, getPhotos } from '@/photo/db/query'; import PhotoRecipeOverlay from '@/photo/PhotoRecipeOverlay'; export default async function AdminRecipePage() { - const photos = await getPhotos({ tag: 'favs', limit: 4}); - const photosHidden = await getPhotos({ hidden: 'only', limit: 1 }); - const { filmSimulation } = photosHidden[0]; + const [ + photos, + photo1, + photo2, + photo3, + photo4, + photosHidden, + ] = await Promise.all([ + getPhotos({ tag: 'favs' }), + getPhoto('4zT6dgPr'), + getPhoto('9MopluBn'), + getPhoto('ifv8zq45'), + getPhoto('2BO2YoW6'), + getPhotos({ hidden: 'only', limit: 1 }), + ]); const { fujifilmRecipe } = photosHidden[0]; return ( -
- {photos.map(photo => - , - )} - - -
); + + ); } diff --git a/src/photo/PhotoRecipeOverlay.tsx b/src/photo/PhotoRecipeOverlay.tsx index deb1de29..cfcac450 100644 --- a/src/photo/PhotoRecipeOverlay.tsx +++ b/src/photo/PhotoRecipeOverlay.tsx @@ -1,43 +1,50 @@ +'use client'; + import { FujifilmRecipe } from '@/platforms/fujifilm/recipe'; -import { FilmSimulation } from '@/simulation'; import clsx from 'clsx/lite'; import ImageLarge from '@/components/image/ImageLarge'; import PhotoRecipe from './PhotoRecipe'; - +import { Photo } from '.'; +import { useEffect, useState } from 'react'; export default function PhotoRecipeOverlay({ - backgroundImageUrl, + photos, recipe, - simulation, - exposure, - iso, className, }: { - backgroundImageUrl?: string + photos: Photo[] recipe: FujifilmRecipe - simulation: FilmSimulation - exposure: string - iso: string className?: string }) { + const [photoIndex, setPhotoIndex] = useState(0); + + const photo = photos[photoIndex]; + + useEffect(() => { + const interval = setInterval(() => { + setPhotoIndex((photoIndex + 1) % photos.length); + }, 500); + return () => clearInterval(interval); + }, [photoIndex, photos]); + return (
- {backgroundImageUrl &&} + />