Refine admin recipe detail page
This commit is contained in:
parent
769d6b64bb
commit
3684c57dee
@ -6,6 +6,8 @@ import PhotoLightbox from '@/photo/PhotoLightbox';
|
|||||||
import { getPhotosMeta } from '@/photo/db/query';
|
import { getPhotosMeta } from '@/photo/db/query';
|
||||||
import AdminRecipeBadge from '@/admin/AdminRecipeBadge';
|
import AdminRecipeBadge from '@/admin/AdminRecipeBadge';
|
||||||
import AdminRecipeForm from '@/admin/AdminRecipeForm';
|
import AdminRecipeForm from '@/admin/AdminRecipeForm';
|
||||||
|
import { getPhotoWithRecipeFromPhotos } from '@/recipe';
|
||||||
|
import AdminShowRecipeButton from '@/admin/AdminShowRecipeButton';
|
||||||
|
|
||||||
const MAX_PHOTO_TO_SHOW = 6;
|
const MAX_PHOTO_TO_SHOW = 6;
|
||||||
|
|
||||||
@ -28,6 +30,11 @@ export default async function RecipePageEdit({
|
|||||||
getPhotosCached({ recipe, limit: MAX_PHOTO_TO_SHOW }),
|
getPhotosCached({ recipe, limit: MAX_PHOTO_TO_SHOW }),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const {
|
||||||
|
recipeData,
|
||||||
|
filmSimulation,
|
||||||
|
} = getPhotoWithRecipeFromPhotos(photos) ?? {};
|
||||||
|
|
||||||
if (count === 0) { redirect(PATH_ADMIN); }
|
if (count === 0) { redirect(PATH_ADMIN); }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -35,6 +42,13 @@ export default async function RecipePageEdit({
|
|||||||
backPath={PATH_ADMIN_TAGS}
|
backPath={PATH_ADMIN_TAGS}
|
||||||
backLabel="Tags"
|
backLabel="Tags"
|
||||||
breadcrumb={<AdminRecipeBadge {...{ recipe, count, hideBadge: true }} />}
|
breadcrumb={<AdminRecipeBadge {...{ recipe, count, hideBadge: true }} />}
|
||||||
|
accessory={recipeData && filmSimulation &&
|
||||||
|
<AdminShowRecipeButton
|
||||||
|
title={recipe}
|
||||||
|
recipe={recipeData}
|
||||||
|
simulation={filmSimulation}
|
||||||
|
/>
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<AdminRecipeForm {...{ recipe, photos }}>
|
<AdminRecipeForm {...{ recipe, photos }}>
|
||||||
<PhotoLightbox
|
<PhotoLightbox
|
||||||
|
|||||||
@ -15,7 +15,7 @@ export default function AdminRecipeBadge({
|
|||||||
const renderBadgeContent = () =>
|
const renderBadgeContent = () =>
|
||||||
<div className={clsx(
|
<div className={clsx(
|
||||||
'inline-flex items-center gap-2',
|
'inline-flex items-center gap-2',
|
||||||
'translate-y-[1px]',
|
'translate-y-[1.5px]',
|
||||||
)}>
|
)}>
|
||||||
<PhotoRecipe {...{ recipe }} />
|
<PhotoRecipe {...{ recipe }} />
|
||||||
<div className="text-dim uppercase">
|
<div className="text-dim uppercase">
|
||||||
|
|||||||
35
src/admin/AdminShowRecipeButton.tsx
Normal file
35
src/admin/AdminShowRecipeButton.tsx
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import LoaderButton from '@/components/primitives/LoaderButton';
|
||||||
|
import { FujifilmRecipe } from '@/platforms/fujifilm/recipe';
|
||||||
|
import { FujifilmSimulation } from '@/platforms/fujifilm/simulation';
|
||||||
|
import { useAppState } from '@/state/AppState';
|
||||||
|
import { TbChecklist } from 'react-icons/tb';
|
||||||
|
|
||||||
|
export default function AdminShowRecipeButton({
|
||||||
|
title,
|
||||||
|
recipe,
|
||||||
|
simulation,
|
||||||
|
}: {
|
||||||
|
title: string
|
||||||
|
recipe: FujifilmRecipe
|
||||||
|
simulation: FujifilmSimulation
|
||||||
|
}) {
|
||||||
|
const { setRecipeModalProps } = useAppState();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<LoaderButton
|
||||||
|
icon={<TbChecklist
|
||||||
|
size={17}
|
||||||
|
className="translate-y-[1px]"
|
||||||
|
/>}
|
||||||
|
onClick={() => setRecipeModalProps?.({
|
||||||
|
title,
|
||||||
|
recipe,
|
||||||
|
simulation,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
Preview
|
||||||
|
</LoaderButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -23,8 +23,8 @@ export default function Badge({
|
|||||||
return clsx(
|
return clsx(
|
||||||
'px-1.5 h-[26px]',
|
'px-1.5 h-[26px]',
|
||||||
'rounded-md',
|
'rounded-md',
|
||||||
'bg-gray-100/80 dark:bg-gray-900/80',
|
'bg-gray-100/40 dark:bg-gray-900/60',
|
||||||
'border border-gray-200/60 dark:border-gray-800/75',
|
'border border-medium',
|
||||||
);
|
);
|
||||||
case 'small':
|
case 'small':
|
||||||
return clsx(
|
return clsx(
|
||||||
|
|||||||
@ -25,13 +25,15 @@ export default function RecipeImageResponse({
|
|||||||
fontFamily: string
|
fontFamily: string
|
||||||
smallText?: boolean
|
smallText?: boolean
|
||||||
}) {
|
}) {
|
||||||
const photo = getPhotoWithRecipeFromPhotos(photos);
|
const {
|
||||||
|
recipeData,
|
||||||
|
filmSimulation,
|
||||||
|
} = getPhotoWithRecipeFromPhotos(photos) ?? {};
|
||||||
|
|
||||||
let recipeLines = photo?.recipeData && photo.filmSimulation
|
let recipeLines = recipeData && filmSimulation
|
||||||
? generateRecipeText({
|
? generateRecipeText({
|
||||||
recipe: photo.recipeData,
|
recipe: recipeData,
|
||||||
simulation: photo.filmSimulation!,
|
simulation: filmSimulation,
|
||||||
iso: photo.iso!.toString(),
|
|
||||||
}, true)
|
}, true)
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
@ -72,7 +74,7 @@ export default function RecipeImageResponse({
|
|||||||
/>,
|
/>,
|
||||||
title: formatTag(recipe).toLocaleUpperCase(),
|
title: formatTag(recipe).toLocaleUpperCase(),
|
||||||
}}>
|
}}>
|
||||||
{photo?.recipeData &&
|
{recipeData &&
|
||||||
<div
|
<div
|
||||||
// tw="opacity-70"
|
// tw="opacity-70"
|
||||||
style={{
|
style={{
|
||||||
@ -108,10 +110,10 @@ export default function RecipeImageResponse({
|
|||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
}}>
|
}}>
|
||||||
{text}
|
{text}
|
||||||
{isStringFilmSimulation(text) &&
|
{isStringFilmSimulation(text) && filmSimulation &&
|
||||||
<div tw="flex">
|
<div tw="flex">
|
||||||
<PhotoFilmSimulationIcon
|
<PhotoFilmSimulationIcon
|
||||||
simulation={photo.filmSimulation}
|
simulation={filmSimulation}
|
||||||
height={height * .06}
|
height={height * .06}
|
||||||
style={{ transform: `translateY(${-height * .001}px)`}}
|
style={{ transform: `translateY(${-height * .001}px)`}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user