Refine recipe behavior

This commit is contained in:
Sam Becker 2025-03-03 20:38:35 -08:00
parent 73fee23ef0
commit d8ef5e290c
4 changed files with 10 additions and 10 deletions

View File

@ -106,9 +106,8 @@ export default function PhotoLarge({
const showZoomControls = showZoomControlsProp && areZoomControlsShown;
const refRecipe = useRef<HTMLDivElement>(null);
const refRecipeTitle = useRef<HTMLButtonElement>(null);
const refRecipeButton = useRef<HTMLButtonElement>(null);
const refTriggers = useMemo(() => [refRecipeTitle, refRecipeButton], []);
const refTriggers = useMemo(() => [refRecipeButton], []);
const {
shouldShowRecipe,
toggleRecipe,
@ -271,11 +270,8 @@ export default function PhotoLarge({
/>}
{showRecipeContent &&
<PhotoRecipe
refButton={refRecipeTitle}
recipe={recipe}
contrast="medium"
isOpen={shouldShowRecipe}
recipeOnClick={toggleRecipe}
prefetch={prefetchRelatedLinks}
/>}
{showTagsContent &&

View File

@ -4,7 +4,7 @@ import { Photo, PhotoDateRange } from '@/photo';
import PhotoHeader from '@/photo/PhotoHeader';
import PhotoRecipe from './PhotoRecipe';
import { useAppState } from '@/state/AppState';
import { descriptionForRecipePhotos } from '.';
import { descriptionForRecipePhotos, photoHasRecipe } from '.';
export default function RecipeHeader({
recipe,
photos,
@ -22,8 +22,9 @@ export default function RecipeHeader({
}) {
const { setRecipeModalProps } = useAppState();
const photo = photos.find(({ filmSimulation, recipeData }) =>
recipeData && filmSimulation);
const photo = photoHasRecipe(selectedPhoto)
? selectedPhoto
: photos.find(photoHasRecipe);
return (
<PhotoHeader

View File

@ -60,3 +60,6 @@ export const generateMetaForRecipe = (
descriptionForRecipePhotos(photos, true, explicitCount, explicitDateRange),
images: absolutePathForRecipeImage(recipe),
});
export const photoHasRecipe = (photo?: Photo) =>
photo?.filmSimulation && photo?.recipeData;

View File

@ -51,9 +51,9 @@ export const shareTextForTag = (tag: string) =>
export const sortTags = (
tags: string[],
tagToHide?: string,
tagToExclude?: string,
) => tags
.filter(tag => tag !== tagToHide)
.filter(tag => tag !== tagToExclude)
.sort((a, b) => isTagFavs(a) ? -1 : a.localeCompare(b));
export const sortTagsObject = (