From b69f2c244be3dcb290b3d0b1b2f2ca692af3f050 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Fri, 18 Apr 2025 10:44:46 -0500 Subject: [PATCH] Refine recipe text code --- src/app/paths.ts | 4 ++-- src/film/FilmHeader.tsx | 3 ++- src/image-response/RecipeImageResponse.tsx | 4 ++-- src/recipe/PhotoRecipeOverlay.tsx | 2 +- src/recipe/index.ts | 13 +++++++------ src/share/ShareModal.tsx | 3 +++ 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/app/paths.ts b/src/app/paths.ts index b275a832..43d9a119 100644 --- a/src/app/paths.ts +++ b/src/app/paths.ts @@ -133,10 +133,10 @@ export const pathForPhoto = ({ prefix = pathForLens(lens); } else if (tag) { prefix = pathForTag(tag); - } else if (film) { - prefix = pathForFilm(film); } else if (recipe) { prefix = pathForRecipe(recipe); + } else if (film) { + prefix = pathForFilm(film); } else if (focal) { prefix = pathForFocalLength(focal); } diff --git a/src/film/FilmHeader.tsx b/src/film/FilmHeader.tsx index 5afbdc9e..a9028a41 100644 --- a/src/film/FilmHeader.tsx +++ b/src/film/FilmHeader.tsx @@ -25,7 +25,8 @@ export default function FilmHeader({ const { recipeModalProps, setRecipeModalProps } = useAppState(); // Only show recipe button when viewing individual photos - const recipeProps = selectedPhoto + // that don't have named recipes + const recipeProps = selectedPhoto && !selectedPhoto?.recipeTitle ? getRecipePropsFromPhotos(photos, selectedPhoto) : undefined; diff --git a/src/image-response/RecipeImageResponse.tsx b/src/image-response/RecipeImageResponse.tsx index fd462ce9..8ee879cc 100644 --- a/src/image-response/RecipeImageResponse.tsx +++ b/src/image-response/RecipeImageResponse.tsx @@ -4,7 +4,7 @@ import ImagePhotoGrid from './components/ImagePhotoGrid'; import ImageContainer from './components/ImageContainer'; import type { NextImageSize } from '@/platforms/next-image'; import { formatTag } from '@/tag'; -import { generateRecipeText, getRecipePropsFromPhotos } from '@/recipe'; +import { generateRecipeLines, getRecipePropsFromPhotos } from '@/recipe'; import PhotoFilmIcon from '@/film/PhotoFilmIcon'; import { isStringFujifilmSimulationLabel, @@ -30,7 +30,7 @@ export default function RecipeImageResponse({ const { data, film } = getRecipePropsFromPhotos(photos) ?? {}; let recipeLines = data && film - ? generateRecipeText({ data, film }, true) + ? generateRecipeLines({ data, film }, true) : []; if (recipeLines && recipeLines.length > MAX_RECIPE_LINES) { diff --git a/src/recipe/PhotoRecipeOverlay.tsx b/src/recipe/PhotoRecipeOverlay.tsx index 209b26bf..183e0f76 100644 --- a/src/recipe/PhotoRecipeOverlay.tsx +++ b/src/recipe/PhotoRecipeOverlay.tsx @@ -131,7 +131,7 @@ export default function PhotoRecipeOverlay({ label={`${title ? `${formatRecipe(title).toLocaleUpperCase()} recipe` : 'Recipe'}`} - text={generateRecipeText({ title, data, film }).join('\n')} + text={generateRecipeText({ title, data, film })} iconSize={17} className={clsx( 'translate-y-[1.5px]', diff --git a/src/recipe/index.ts b/src/recipe/index.ts index ae00d5cd..e7beba4c 100644 --- a/src/recipe/index.ts +++ b/src/recipe/index.ts @@ -53,12 +53,9 @@ export const descriptionForRecipePhotos = ( explicitDateRange, ); -export const generateRecipeText = ({ - title, - data, - film, -}: RecipeProps, -abbreviate?: boolean, +export const generateRecipeLines = ( + { title, data, film }: RecipeProps, + abbreviate?: boolean, ) => { const lines: string[] = []; @@ -134,6 +131,10 @@ abbreviate?: boolean, : lines; }; +export const generateRecipeText = ( + ...args: Parameters +) => generateRecipeLines(...args).join('\n'); + export const generateMetaForRecipe = ( recipe: string, photos: Photo[], diff --git a/src/share/ShareModal.tsx b/src/share/ShareModal.tsx index cd6021db..8e688196 100644 --- a/src/share/ShareModal.tsx +++ b/src/share/ShareModal.tsx @@ -19,12 +19,14 @@ export default function ShareModal({ pathShare, socialText, navigatorTitle, + navigatorText, children, }: { title?: string pathShare: string socialText: string navigatorTitle: string + navigatorText?: string children: ReactNode }) { const { @@ -96,6 +98,7 @@ export default function ShareModal({ , () => navigator.share({ title: navigatorTitle, + text: navigatorText, url: pathShare, }) .catch(() => console.log('Share canceled')),