Refine recipe text code
This commit is contained in:
parent
aa7918563e
commit
b69f2c244b
@ -133,10 +133,10 @@ export const pathForPhoto = ({
|
|||||||
prefix = pathForLens(lens);
|
prefix = pathForLens(lens);
|
||||||
} else if (tag) {
|
} else if (tag) {
|
||||||
prefix = pathForTag(tag);
|
prefix = pathForTag(tag);
|
||||||
} else if (film) {
|
|
||||||
prefix = pathForFilm(film);
|
|
||||||
} else if (recipe) {
|
} else if (recipe) {
|
||||||
prefix = pathForRecipe(recipe);
|
prefix = pathForRecipe(recipe);
|
||||||
|
} else if (film) {
|
||||||
|
prefix = pathForFilm(film);
|
||||||
} else if (focal) {
|
} else if (focal) {
|
||||||
prefix = pathForFocalLength(focal);
|
prefix = pathForFocalLength(focal);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,8 @@ export default function FilmHeader({
|
|||||||
const { recipeModalProps, setRecipeModalProps } = useAppState();
|
const { recipeModalProps, setRecipeModalProps } = useAppState();
|
||||||
|
|
||||||
// Only show recipe button when viewing individual photos
|
// 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)
|
? getRecipePropsFromPhotos(photos, selectedPhoto)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import ImagePhotoGrid from './components/ImagePhotoGrid';
|
|||||||
import ImageContainer from './components/ImageContainer';
|
import ImageContainer from './components/ImageContainer';
|
||||||
import type { NextImageSize } from '@/platforms/next-image';
|
import type { NextImageSize } from '@/platforms/next-image';
|
||||||
import { formatTag } from '@/tag';
|
import { formatTag } from '@/tag';
|
||||||
import { generateRecipeText, getRecipePropsFromPhotos } from '@/recipe';
|
import { generateRecipeLines, getRecipePropsFromPhotos } from '@/recipe';
|
||||||
import PhotoFilmIcon from '@/film/PhotoFilmIcon';
|
import PhotoFilmIcon from '@/film/PhotoFilmIcon';
|
||||||
import {
|
import {
|
||||||
isStringFujifilmSimulationLabel,
|
isStringFujifilmSimulationLabel,
|
||||||
@ -30,7 +30,7 @@ export default function RecipeImageResponse({
|
|||||||
const { data, film } = getRecipePropsFromPhotos(photos) ?? {};
|
const { data, film } = getRecipePropsFromPhotos(photos) ?? {};
|
||||||
|
|
||||||
let recipeLines = data && film
|
let recipeLines = data && film
|
||||||
? generateRecipeText({ data, film }, true)
|
? generateRecipeLines({ data, film }, true)
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
if (recipeLines && recipeLines.length > MAX_RECIPE_LINES) {
|
if (recipeLines && recipeLines.length > MAX_RECIPE_LINES) {
|
||||||
|
|||||||
@ -131,7 +131,7 @@ export default function PhotoRecipeOverlay({
|
|||||||
label={`${title
|
label={`${title
|
||||||
? `${formatRecipe(title).toLocaleUpperCase()} recipe`
|
? `${formatRecipe(title).toLocaleUpperCase()} recipe`
|
||||||
: 'Recipe'}`}
|
: 'Recipe'}`}
|
||||||
text={generateRecipeText({ title, data, film }).join('\n')}
|
text={generateRecipeText({ title, data, film })}
|
||||||
iconSize={17}
|
iconSize={17}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'translate-y-[1.5px]',
|
'translate-y-[1.5px]',
|
||||||
|
|||||||
@ -53,12 +53,9 @@ export const descriptionForRecipePhotos = (
|
|||||||
explicitDateRange,
|
explicitDateRange,
|
||||||
);
|
);
|
||||||
|
|
||||||
export const generateRecipeText = ({
|
export const generateRecipeLines = (
|
||||||
title,
|
{ title, data, film }: RecipeProps,
|
||||||
data,
|
abbreviate?: boolean,
|
||||||
film,
|
|
||||||
}: RecipeProps,
|
|
||||||
abbreviate?: boolean,
|
|
||||||
) => {
|
) => {
|
||||||
const lines: string[] = [];
|
const lines: string[] = [];
|
||||||
|
|
||||||
@ -134,6 +131,10 @@ abbreviate?: boolean,
|
|||||||
: lines;
|
: lines;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const generateRecipeText = (
|
||||||
|
...args: Parameters<typeof generateRecipeLines>
|
||||||
|
) => generateRecipeLines(...args).join('\n');
|
||||||
|
|
||||||
export const generateMetaForRecipe = (
|
export const generateMetaForRecipe = (
|
||||||
recipe: string,
|
recipe: string,
|
||||||
photos: Photo[],
|
photos: Photo[],
|
||||||
|
|||||||
@ -19,12 +19,14 @@ export default function ShareModal({
|
|||||||
pathShare,
|
pathShare,
|
||||||
socialText,
|
socialText,
|
||||||
navigatorTitle,
|
navigatorTitle,
|
||||||
|
navigatorText,
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
title?: string
|
title?: string
|
||||||
pathShare: string
|
pathShare: string
|
||||||
socialText: string
|
socialText: string
|
||||||
navigatorTitle: string
|
navigatorTitle: string
|
||||||
|
navigatorText?: string
|
||||||
children: ReactNode
|
children: ReactNode
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
@ -96,6 +98,7 @@ export default function ShareModal({
|
|||||||
<IoArrowUp size={18} />,
|
<IoArrowUp size={18} />,
|
||||||
() => navigator.share({
|
() => navigator.share({
|
||||||
title: navigatorTitle,
|
title: navigatorTitle,
|
||||||
|
text: navigatorText,
|
||||||
url: pathShare,
|
url: pathShare,
|
||||||
})
|
})
|
||||||
.catch(() => console.log('Share canceled')),
|
.catch(() => console.log('Share canceled')),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user