Refine recipe text code
This commit is contained in:
parent
aa7918563e
commit
b69f2c244b
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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]',
|
||||
|
||||
@ -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<typeof generateRecipeLines>
|
||||
) => generateRecipeLines(...args).join('\n');
|
||||
|
||||
export const generateMetaForRecipe = (
|
||||
recipe: string,
|
||||
photos: Photo[],
|
||||
|
||||
@ -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({
|
||||
<IoArrowUp size={18} />,
|
||||
() => navigator.share({
|
||||
title: navigatorTitle,
|
||||
text: navigatorText,
|
||||
url: pathShare,
|
||||
})
|
||||
.catch(() => console.log('Share canceled')),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user