Refine recipe overlay demo

This commit is contained in:
Sam Becker 2025-02-24 18:24:56 -06:00
parent 1611450a13
commit 613aa17849
2 changed files with 51 additions and 49 deletions

View File

@ -1,38 +1,33 @@
import { getPhotos } from '@/photo/db/query'; import { getPhoto, getPhotos } from '@/photo/db/query';
import PhotoRecipeOverlay from '@/photo/PhotoRecipeOverlay'; import PhotoRecipeOverlay from '@/photo/PhotoRecipeOverlay';
export default async function AdminRecipePage() { export default async function AdminRecipePage() {
const photos = await getPhotos({ tag: 'favs', limit: 4}); const [
const photosHidden = await getPhotos({ hidden: 'only', limit: 1 }); photos,
const { filmSimulation } = photosHidden[0]; 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]; const { fujifilmRecipe } = photosHidden[0];
return ( return (
<div className="grid grid-cols-2 xl:grid-cols-3 w-full">
{photos.map(photo =>
<PhotoRecipeOverlay <PhotoRecipeOverlay
key={photo.id} photos={[
backgroundImageUrl={photo.url} ...photos,
photo1!,
photo2!,
photo3!,
photo4!,
]}
recipe={fujifilmRecipe!} recipe={fujifilmRecipe!}
simulation={filmSimulation!}
exposure={photo.exposureCompensationFormatted ?? '+0ev'}
iso={photo.isoFormatted ?? 'ISO 0'}
/>,
)}
<PhotoRecipeOverlay
key="black"
className="bg-black"
recipe={fujifilmRecipe!}
simulation={filmSimulation!}
exposure="+0ev"
iso="ISO 0"
/> />
<PhotoRecipeOverlay );
key="white"
className="bg-white"
recipe={fujifilmRecipe!}
simulation={filmSimulation!}
exposure="+0ev"
iso="ISO 0"
/>
</div>);
} }

View File

@ -1,43 +1,50 @@
'use client';
import { FujifilmRecipe } from '@/platforms/fujifilm/recipe'; import { FujifilmRecipe } from '@/platforms/fujifilm/recipe';
import { FilmSimulation } from '@/simulation';
import clsx from 'clsx/lite'; import clsx from 'clsx/lite';
import ImageLarge from '@/components/image/ImageLarge'; import ImageLarge from '@/components/image/ImageLarge';
import PhotoRecipe from './PhotoRecipe'; import PhotoRecipe from './PhotoRecipe';
import { Photo } from '.';
import { useEffect, useState } from 'react';
export default function PhotoRecipeOverlay({ export default function PhotoRecipeOverlay({
backgroundImageUrl, photos,
recipe, recipe,
simulation,
exposure,
iso,
className, className,
}: { }: {
backgroundImageUrl?: string photos: Photo[]
recipe: FujifilmRecipe recipe: FujifilmRecipe
simulation: FilmSimulation
exposure: string
iso: string
className?: 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 ( return (
<div className={clsx( <div className={clsx(
'relative w-full aspect-[3/2]', 'relative w-full aspect-[3/2]',
className, className,
)}> )}>
{backgroundImageUrl &&<ImageLarge <ImageLarge
src={backgroundImageUrl} src={photo.url}
alt="Image Background" alt="Image Background"
aspectRatio={3 / 2} aspectRatio={3 / 2}
/>} />
<div className={clsx( <div className={clsx(
'absolute inset-0', 'absolute inset-0 w-full h-full',
'flex items-center justify-center', 'flex items-center justify-center',
)}> )}>
<PhotoRecipe {...{ <PhotoRecipe {...{
recipe, recipe,
simulation, simulation: photo.filmSimulation ?? 'provia',
exposure, exposure: photo.exposureCompensationFormatted ?? '+0ev',
iso, iso: photo.isoFormatted ?? 'ISO 0',
}} /> }} />
</div> </div>
</div> </div>