Standardize recipe props
This commit is contained in:
parent
f9db50e41a
commit
99dde505b3
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -8,6 +8,7 @@
|
|||||||
"Astia",
|
"Astia",
|
||||||
"authjs",
|
"authjs",
|
||||||
"camelcase",
|
"camelcase",
|
||||||
|
"CLAR",
|
||||||
"cloudflarestorage",
|
"cloudflarestorage",
|
||||||
"cmdk",
|
"cmdk",
|
||||||
"Consolas",
|
"Consolas",
|
||||||
|
|||||||
@ -45,7 +45,7 @@ export default async function RecipePageEdit({
|
|||||||
accessory={recipeData && film &&
|
accessory={recipeData && film &&
|
||||||
<AdminShowRecipeButton
|
<AdminShowRecipeButton
|
||||||
title={recipe}
|
title={recipe}
|
||||||
recipe={recipeData}
|
data={recipeData}
|
||||||
film={film}
|
film={film}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,20 +1,11 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import LoaderButton from '@/components/primitives/LoaderButton';
|
import LoaderButton from '@/components/primitives/LoaderButton';
|
||||||
import { FujifilmRecipe } from '@/platforms/fujifilm/recipe';
|
import { RecipeProps } from '@/recipe';
|
||||||
import { FujifilmSimulation } from '@/platforms/fujifilm/simulation';
|
|
||||||
import { useAppState } from '@/state/AppState';
|
import { useAppState } from '@/state/AppState';
|
||||||
import { TbChecklist } from 'react-icons/tb';
|
import { TbChecklist } from 'react-icons/tb';
|
||||||
|
|
||||||
export default function AdminShowRecipeButton({
|
export default function AdminShowRecipeButton(props: RecipeProps) {
|
||||||
title,
|
|
||||||
recipe,
|
|
||||||
film,
|
|
||||||
}: {
|
|
||||||
title: string
|
|
||||||
recipe: FujifilmRecipe
|
|
||||||
film: FujifilmSimulation
|
|
||||||
}) {
|
|
||||||
const { setRecipeModalProps } = useAppState();
|
const { setRecipeModalProps } = useAppState();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -23,11 +14,7 @@ export default function AdminShowRecipeButton({
|
|||||||
size={17}
|
size={17}
|
||||||
className="translate-y-[1px]"
|
className="translate-y-[1px]"
|
||||||
/>}
|
/>}
|
||||||
onClick={() => setRecipeModalProps?.({
|
onClick={() => setRecipeModalProps?.(props)}
|
||||||
title,
|
|
||||||
recipe,
|
|
||||||
film,
|
|
||||||
})}
|
|
||||||
>
|
>
|
||||||
Preview
|
Preview
|
||||||
</LoaderButton>
|
</LoaderButton>
|
||||||
|
|||||||
@ -34,7 +34,7 @@ export default function RecipeImageResponse({
|
|||||||
|
|
||||||
let recipeLines = recipeData && film
|
let recipeLines = recipeData && film
|
||||||
? generateRecipeText({
|
? generateRecipeText({
|
||||||
recipe: recipeData,
|
data: recipeData,
|
||||||
film,
|
film,
|
||||||
}, true)
|
}, true)
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
@ -229,7 +229,7 @@ export default function PhotoLarge({
|
|||||||
<PhotoRecipeOverlay
|
<PhotoRecipeOverlay
|
||||||
ref={refRecipe}
|
ref={refRecipe}
|
||||||
title={photo.recipeTitle}
|
title={photo.recipeTitle}
|
||||||
recipe={photo.recipeData}
|
data={photo.recipeData}
|
||||||
film={photo.film}
|
film={photo.film}
|
||||||
iso={photo.isoFormatted}
|
iso={photo.isoFormatted}
|
||||||
exposure={photo.exposureCompensationFormatted}
|
exposure={photo.exposureCompensationFormatted}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import { labelForFilm } from '@/film';
|
|||||||
export default function PhotoRecipeOverlay({
|
export default function PhotoRecipeOverlay({
|
||||||
ref,
|
ref,
|
||||||
title,
|
title,
|
||||||
recipe,
|
data,
|
||||||
film,
|
film,
|
||||||
onClose,
|
onClose,
|
||||||
}: RecipeProps & {
|
}: RecipeProps & {
|
||||||
@ -43,9 +43,9 @@ export default function PhotoRecipeOverlay({
|
|||||||
colorChromeFXBlue,
|
colorChromeFXBlue,
|
||||||
bwAdjustment,
|
bwAdjustment,
|
||||||
bwMagentaGreen,
|
bwMagentaGreen,
|
||||||
} = recipe;
|
} = data;
|
||||||
|
|
||||||
const whiteBalanceTypeFormatted = formatWhiteBalance(recipe);
|
const whiteBalanceTypeFormatted = formatWhiteBalance(data);
|
||||||
|
|
||||||
const renderDataSquare = (
|
const renderDataSquare = (
|
||||||
value: ReactNode,
|
value: ReactNode,
|
||||||
@ -122,7 +122,7 @@ export default function PhotoRecipeOverlay({
|
|||||||
label={`${title
|
label={`${title
|
||||||
? `${formatRecipe(title).toLocaleUpperCase()} recipe`
|
? `${formatRecipe(title).toLocaleUpperCase()} recipe`
|
||||||
: 'Recipe'}`}
|
: 'Recipe'}`}
|
||||||
text={generateRecipeText({ title, recipe, film }).join('\n')}
|
text={generateRecipeText({ title, data, film }).join('\n')}
|
||||||
iconSize={17}
|
iconSize={17}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'translate-y-[0.5px]',
|
'translate-y-[0.5px]',
|
||||||
@ -171,7 +171,7 @@ export default function PhotoRecipeOverlay({
|
|||||||
'col-span-8',
|
'col-span-8',
|
||||||
)}
|
)}
|
||||||
{renderDataSquare(
|
{renderDataSquare(
|
||||||
formatNoiseReduction(recipe),
|
formatNoiseReduction(data),
|
||||||
'ISO NR',
|
'ISO NR',
|
||||||
'col-span-4',
|
'col-span-4',
|
||||||
)}
|
)}
|
||||||
@ -195,7 +195,7 @@ export default function PhotoRecipeOverlay({
|
|||||||
)}
|
)}
|
||||||
{/* ROW */}
|
{/* ROW */}
|
||||||
{renderDataSquare(
|
{renderDataSquare(
|
||||||
formatGrain(recipe),
|
formatGrain(data),
|
||||||
'grain',
|
'grain',
|
||||||
'col-span-6',
|
'col-span-6',
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -35,7 +35,7 @@ export default function RecipeHeader({
|
|||||||
photo?.film
|
photo?.film
|
||||||
) ? setRecipeModalProps?.({
|
) ? setRecipeModalProps?.({
|
||||||
title: photo.recipeTitle,
|
title: photo.recipeTitle,
|
||||||
recipe: photo.recipeData,
|
data: photo.recipeData,
|
||||||
film: photo.film,
|
film: photo.film,
|
||||||
iso: photo.isoFormatted,
|
iso: photo.isoFormatted,
|
||||||
exposure: photo.exposureTimeFormatted,
|
exposure: photo.exposureTimeFormatted,
|
||||||
|
|||||||
@ -18,7 +18,7 @@ export type Recipes = RecipeWithCount[]
|
|||||||
|
|
||||||
export interface RecipeProps {
|
export interface RecipeProps {
|
||||||
title?: string
|
title?: string
|
||||||
recipe: FujifilmRecipe
|
data: FujifilmRecipe
|
||||||
film: string
|
film: string
|
||||||
iso?: string
|
iso?: string
|
||||||
exposure?: string
|
exposure?: string
|
||||||
@ -55,7 +55,7 @@ export const descriptionForRecipePhotos = (
|
|||||||
|
|
||||||
export const generateRecipeText = ({
|
export const generateRecipeText = ({
|
||||||
title,
|
title,
|
||||||
recipe,
|
data,
|
||||||
film,
|
film,
|
||||||
}: RecipeProps,
|
}: RecipeProps,
|
||||||
abbreviate?: boolean,
|
abbreviate?: boolean,
|
||||||
@ -63,53 +63,51 @@ abbreviate?: boolean,
|
|||||||
const lines = [
|
const lines = [
|
||||||
`${labelForFilm(film).small.toLocaleUpperCase()}`,
|
`${labelForFilm(film).small.toLocaleUpperCase()}`,
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
`${formatWhiteBalance(recipe).toLocaleUpperCase()} ${formatWhiteBalanceColor(recipe)}`,
|
`${formatWhiteBalance(data).toLocaleUpperCase()} ${formatWhiteBalanceColor(data)}`,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (abbreviate) {
|
if (abbreviate) {
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
lines.push(`DR${recipe.dynamicRange.development} NR${formatNoiseReduction(recipe)}`);
|
lines.push(`DR${data.dynamicRange.development} NR${formatNoiseReduction(data)}`);
|
||||||
} else {
|
} else {
|
||||||
lines.push(
|
lines.push(
|
||||||
`DYNAMIC RANGE ${recipe.dynamicRange.development}`,
|
`DYNAMIC RANGE ${data.dynamicRange.development}`,
|
||||||
`NOISE REDUCTION ${formatNoiseReduction(recipe)}`,
|
`NOISE REDUCTION ${formatNoiseReduction(data)}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recipe.highlight || recipe.shadow) {
|
if (data.highlight || data.shadow) {
|
||||||
lines.push(abbreviate
|
lines.push(abbreviate
|
||||||
? `HIGH${addSign(recipe.highlight)} SHAD${addSign(recipe.shadow)}`
|
? `HIGH${addSign(data.highlight)} SHAD${addSign(data.shadow)}`
|
||||||
// eslint-disable-next-line max-len
|
: `HIGHLIGHT ${addSign(data.highlight)} SHADOW ${addSign(data.shadow)}`,
|
||||||
: `HIGHLIGHT ${addSign(recipe.highlight)} SHADOW ${addSign(recipe.shadow)}`,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
lines.push(abbreviate
|
lines.push(abbreviate
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
? `COL${addSign(recipe.color)} SHARP${addSign(recipe.sharpness)} CLAR${addSign(recipe.clarity)}`
|
? `COL${addSign(data.color)} SHARP${addSign(data.sharpness)} CLAR${addSign(data.clarity)}`
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
: `COLOR ${addSign(recipe.color)} SHARPEN ${addSign(recipe.sharpness)} CLARITY ${addSign(recipe.clarity)}`,
|
: `COLOR ${addSign(data.color)} SHARPEN ${addSign(data.sharpness)} CLARITY ${addSign(data.clarity)}`,
|
||||||
);
|
);
|
||||||
if (recipe.colorChromeEffect) {
|
if (data.colorChromeEffect) {
|
||||||
lines.push(abbreviate
|
lines.push(abbreviate
|
||||||
? `CHROME ${recipe.colorChromeEffect.toLocaleUpperCase()}`
|
? `CHROME ${data.colorChromeEffect.toLocaleUpperCase()}`
|
||||||
: `COLOR CHROME ${recipe.colorChromeEffect.toLocaleUpperCase()}`,
|
: `COLOR CHROME ${data.colorChromeEffect.toLocaleUpperCase()}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (recipe.colorChromeFXBlue) {
|
if (data.colorChromeFXBlue) {
|
||||||
lines.push(abbreviate
|
lines.push(abbreviate
|
||||||
? `FX BLUE ${recipe.colorChromeFXBlue.toLocaleUpperCase()}`
|
? `FX BLUE ${data.colorChromeFXBlue.toLocaleUpperCase()}`
|
||||||
: `CHROME FX BLUE ${recipe.colorChromeFXBlue.toLocaleUpperCase()}`,
|
: `CHROME FX BLUE ${data.colorChromeFXBlue.toLocaleUpperCase()}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (recipe.grainEffect.roughness !== 'off') {
|
if (data.grainEffect.roughness !== 'off') {
|
||||||
lines.push(`GRAIN ${formatGrain(recipe, abbreviate)}`);
|
lines.push(`GRAIN ${formatGrain(data, abbreviate)}`);
|
||||||
}
|
}
|
||||||
if (recipe.bwAdjustment || recipe.bwMagentaGreen) {
|
if (data.bwAdjustment || data.bwMagentaGreen) {
|
||||||
lines.push(abbreviate
|
lines.push(abbreviate
|
||||||
|
? `BW ADJ${addSign(data.bwAdjustment)} M/G${addSign(data.bwMagentaGreen)}`
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
? `BW ADJ${addSign(recipe.bwAdjustment)} M/G${addSign(recipe.bwMagentaGreen)}`
|
: `BW ADJUSTMENT ${addSign(data.bwAdjustment)} MAGENTA/GREEN ${addSign(data.bwMagentaGreen)}`,
|
||||||
// eslint-disable-next-line max-len
|
|
||||||
: `BW ADJUSTMENT ${addSign(recipe.bwAdjustment)} MAGENTA/GREEN ${addSign(recipe.bwMagentaGreen)}`,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user