Add lenses to sidebar and cmdk
This commit is contained in:
parent
3b7ec5a6c8
commit
dc765ae4e7
@ -25,8 +25,9 @@ export default async function GridPage() {
|
|||||||
const [
|
const [
|
||||||
photos,
|
photos,
|
||||||
photosCount,
|
photosCount,
|
||||||
tags,
|
|
||||||
cameras,
|
cameras,
|
||||||
|
lenses,
|
||||||
|
tags,
|
||||||
simulations,
|
simulations,
|
||||||
recipes,
|
recipes,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
@ -41,7 +42,15 @@ export default async function GridPage() {
|
|||||||
return (
|
return (
|
||||||
photos.length > 0
|
photos.length > 0
|
||||||
? <PhotoGridPage
|
? <PhotoGridPage
|
||||||
{...{ photos, photosCount, tags, cameras, simulations, recipes }}
|
{...{
|
||||||
|
photos,
|
||||||
|
photosCount,
|
||||||
|
cameras,
|
||||||
|
lenses,
|
||||||
|
tags,
|
||||||
|
simulations,
|
||||||
|
recipes,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
: <PhotosEmptyState />
|
: <PhotosEmptyState />
|
||||||
);
|
);
|
||||||
|
|||||||
19
app/page.tsx
19
app/page.tsx
@ -31,8 +31,9 @@ export default async function HomePage() {
|
|||||||
const [
|
const [
|
||||||
photos,
|
photos,
|
||||||
photosCount,
|
photosCount,
|
||||||
tags,
|
|
||||||
cameras,
|
cameras,
|
||||||
|
lenses,
|
||||||
|
tags,
|
||||||
simulations,
|
simulations,
|
||||||
recipes,
|
recipes,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
@ -43,18 +44,24 @@ export default async function HomePage() {
|
|||||||
.catch(() => 0),
|
.catch(() => 0),
|
||||||
...(GRID_HOMEPAGE_ENABLED
|
...(GRID_HOMEPAGE_ENABLED
|
||||||
? getPhotoSidebarData()
|
? getPhotoSidebarData()
|
||||||
: [[], [], [], []]),
|
: [[], [], [], [], []]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
photos.length > 0
|
photos.length > 0
|
||||||
? GRID_HOMEPAGE_ENABLED
|
? GRID_HOMEPAGE_ENABLED
|
||||||
? <PhotoGridPage
|
? <PhotoGridPage
|
||||||
{...{ photos, photosCount, tags, cameras, simulations, recipes }}
|
{...{
|
||||||
/>
|
photos,
|
||||||
: <PhotoFeedPage
|
photosCount,
|
||||||
{...{ photos, photosCount }}
|
cameras,
|
||||||
|
lenses,
|
||||||
|
tags,
|
||||||
|
simulations,
|
||||||
|
recipes,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
: <PhotoFeedPage {...{ photos, photosCount }} />
|
||||||
: <PhotosEmptyState />
|
: <PhotosEmptyState />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import {
|
|||||||
getPhotosMetaCached,
|
getPhotosMetaCached,
|
||||||
getUniqueCamerasCached,
|
getUniqueCamerasCached,
|
||||||
getUniqueFilmSimulationsCached,
|
getUniqueFilmSimulationsCached,
|
||||||
|
getUniqueLensesCached,
|
||||||
getUniqueRecipesCached,
|
getUniqueRecipesCached,
|
||||||
getUniqueTagsCached,
|
getUniqueTagsCached,
|
||||||
} from '@/photo/cache';
|
} from '@/photo/cache';
|
||||||
@ -17,8 +18,9 @@ import { getUniqueFocalLengths } from '@/photo/db/query';
|
|||||||
export default async function CommandK() {
|
export default async function CommandK() {
|
||||||
const [
|
const [
|
||||||
count,
|
count,
|
||||||
tags,
|
|
||||||
cameras,
|
cameras,
|
||||||
|
lenses,
|
||||||
|
tags,
|
||||||
recipes,
|
recipes,
|
||||||
filmSimulations,
|
filmSimulations,
|
||||||
focalLengths,
|
focalLengths,
|
||||||
@ -26,8 +28,9 @@ export default async function CommandK() {
|
|||||||
getPhotosMetaCached()
|
getPhotosMetaCached()
|
||||||
.then(({ count }) => count)
|
.then(({ count }) => count)
|
||||||
.catch(() => 0),
|
.catch(() => 0),
|
||||||
getUniqueTagsCached().catch(() => []),
|
|
||||||
getUniqueCamerasCached().catch(() => []),
|
getUniqueCamerasCached().catch(() => []),
|
||||||
|
getUniqueLensesCached().catch(() => []),
|
||||||
|
getUniqueTagsCached().catch(() => []),
|
||||||
SHOW_RECIPES
|
SHOW_RECIPES
|
||||||
? getUniqueRecipesCached().catch(() => [])
|
? getUniqueRecipesCached().catch(() => [])
|
||||||
: [],
|
: [],
|
||||||
@ -38,8 +41,9 @@ export default async function CommandK() {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
return <CommandKClient
|
return <CommandKClient
|
||||||
tags={tags}
|
|
||||||
cameras={cameras}
|
cameras={cameras}
|
||||||
|
lenses={lenses}
|
||||||
|
tags={tags}
|
||||||
simulations={filmSimulations}
|
simulations={filmSimulations}
|
||||||
recipes={recipes}
|
recipes={recipes}
|
||||||
focalLengths={focalLengths}
|
focalLengths={focalLengths}
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import {
|
|||||||
pathForCamera,
|
pathForCamera,
|
||||||
pathForFilmSimulation,
|
pathForFilmSimulation,
|
||||||
pathForFocalLength,
|
pathForFocalLength,
|
||||||
|
pathForLens,
|
||||||
pathForPhoto,
|
pathForPhoto,
|
||||||
pathForRecipe,
|
pathForRecipe,
|
||||||
pathForTag,
|
pathForTag,
|
||||||
@ -44,13 +45,11 @@ import { RiToolsFill } from 'react-icons/ri';
|
|||||||
import { BiLockAlt, BiSolidUser } from 'react-icons/bi';
|
import { BiLockAlt, BiSolidUser } from 'react-icons/bi';
|
||||||
import { HiDocumentText } from 'react-icons/hi';
|
import { HiDocumentText } from 'react-icons/hi';
|
||||||
import { signOutAction } from '@/auth/actions';
|
import { signOutAction } from '@/auth/actions';
|
||||||
import { TbChecklist, TbCone, TbPhoto } from 'react-icons/tb';
|
|
||||||
import { getKeywordsForPhoto, titleForPhoto } from '@/photo';
|
import { getKeywordsForPhoto, titleForPhoto } from '@/photo';
|
||||||
import PhotoDate from '@/photo/PhotoDate';
|
import PhotoDate from '@/photo/PhotoDate';
|
||||||
import PhotoSmall from '@/photo/PhotoSmall';
|
import PhotoSmall from '@/photo/PhotoSmall';
|
||||||
import { FaCheck } from 'react-icons/fa6';
|
import { FaCheck } from 'react-icons/fa6';
|
||||||
import { addHiddenToTags, formatTag } from '@/tag';
|
import { addHiddenToTags, formatTag } from '@/tag';
|
||||||
import { FaTag } from 'react-icons/fa';
|
|
||||||
import { formatCount, formatCountDescriptive } from '@/utility/string';
|
import { formatCount, formatCountDescriptive } from '@/utility/string';
|
||||||
import CommandKItem from './CommandKItem';
|
import CommandKItem from './CommandKItem';
|
||||||
import { CATEGORY_VISIBILITY, GRID_HOMEPAGE_ENABLED } from '@/app/config';
|
import { CATEGORY_VISIBILITY, GRID_HOMEPAGE_ENABLED } from '@/app/config';
|
||||||
@ -59,11 +58,17 @@ import * as VisuallyHidden from '@radix-ui/react-visually-hidden';
|
|||||||
import InsightsIndicatorDot from '@/admin/insights/InsightsIndicatorDot';
|
import InsightsIndicatorDot from '@/admin/insights/InsightsIndicatorDot';
|
||||||
import { PhotoSetCategories } from '@/photo/set';
|
import { PhotoSetCategories } from '@/photo/set';
|
||||||
import { formatCameraText } from '@/camera';
|
import { formatCameraText } from '@/camera';
|
||||||
import { IoMdCamera } from 'react-icons/io';
|
|
||||||
import { labelForFilmSimulation } from '@/platforms/fujifilm/simulation';
|
import { labelForFilmSimulation } from '@/platforms/fujifilm/simulation';
|
||||||
import PhotoFilmSimulationIcon from '@/simulation/PhotoFilmSimulationIcon';
|
|
||||||
import { formatFocalLength } from '@/focal';
|
import { formatFocalLength } from '@/focal';
|
||||||
import { formatRecipe } from '@/recipe';
|
import { formatRecipe } from '@/recipe';
|
||||||
|
import IconLens from '../icons/IconLens';
|
||||||
|
import { formatLensText } from '@/lens';
|
||||||
|
import IconTag from '../icons/IconTag';
|
||||||
|
import IconCamera from '../icons/IconCamera';
|
||||||
|
import IconPhoto from '../icons/IconPhoto';
|
||||||
|
import IconRecipe from '../icons/IconRecipe';
|
||||||
|
import IconFocalLength from '../icons/IconFocalLength';
|
||||||
|
import IconFilmSimulation from '../icons/IconFilmSimulation';
|
||||||
|
|
||||||
const DIALOG_TITLE = 'Global Command-K Menu';
|
const DIALOG_TITLE = 'Global Command-K Menu';
|
||||||
const DIALOG_DESCRIPTION = 'For searching photos, views, and settings';
|
const DIALOG_DESCRIPTION = 'For searching photos, views, and settings';
|
||||||
@ -98,8 +103,9 @@ const renderToggle = (
|
|||||||
});
|
});
|
||||||
|
|
||||||
export default function CommandKClient({
|
export default function CommandKClient({
|
||||||
tags,
|
|
||||||
cameras,
|
cameras,
|
||||||
|
lenses,
|
||||||
|
tags,
|
||||||
recipes,
|
recipes,
|
||||||
simulations,
|
simulations,
|
||||||
focalLengths,
|
focalLengths,
|
||||||
@ -198,7 +204,7 @@ export default function CommandKClient({
|
|||||||
setQueriedSections(photos.length > 0
|
setQueriedSections(photos.length > 0
|
||||||
? [{
|
? [{
|
||||||
heading: 'Photos',
|
heading: 'Photos',
|
||||||
accessory: <TbPhoto size={14} />,
|
accessory: <IconPhoto size={14} />,
|
||||||
items: photos.map(photo => ({
|
items: photos.map(photo => ({
|
||||||
label: titleForPhoto(photo),
|
label: titleForPhoto(photo),
|
||||||
keywords: getKeywordsForPhoto(photo),
|
keywords: getKeywordsForPhoto(photo),
|
||||||
@ -250,10 +256,30 @@ export default function CommandKClient({
|
|||||||
CATEGORY_VISIBILITY
|
CATEGORY_VISIBILITY
|
||||||
.map(category => {
|
.map(category => {
|
||||||
switch (category) {
|
switch (category) {
|
||||||
|
case 'cameras': return {
|
||||||
|
heading: 'Cameras',
|
||||||
|
accessory: <IconCamera size={14} />,
|
||||||
|
items: cameras.map(({ camera, count }) => ({
|
||||||
|
label: formatCameraText(camera),
|
||||||
|
annotation: formatCount(count),
|
||||||
|
annotationAria: formatCountDescriptive(count),
|
||||||
|
path: pathForCamera(camera),
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
case 'lenses': return {
|
||||||
|
heading: 'Lenses',
|
||||||
|
accessory: <IconLens size={14} className="translate-y-[0.5px]" />,
|
||||||
|
items: lenses.map(({ lens, count }) => ({
|
||||||
|
label: formatLensText(lens, 'medium'),
|
||||||
|
annotation: formatCount(count),
|
||||||
|
annotationAria: formatCountDescriptive(count),
|
||||||
|
path: pathForLens(lens),
|
||||||
|
})),
|
||||||
|
};
|
||||||
case 'tags': return {
|
case 'tags': return {
|
||||||
heading: 'Tags',
|
heading: 'Tags',
|
||||||
accessory: <FaTag
|
accessory: <IconTag
|
||||||
size={10}
|
size={13}
|
||||||
className="translate-x-[1px] translate-y-[0.75px]"
|
className="translate-x-[1px] translate-y-[0.75px]"
|
||||||
/>,
|
/>,
|
||||||
items: tagsIncludingHidden.map(({ tag, count }) => ({
|
items: tagsIncludingHidden.map(({ tag, count }) => ({
|
||||||
@ -263,19 +289,9 @@ export default function CommandKClient({
|
|||||||
path: pathForTag(tag),
|
path: pathForTag(tag),
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
case 'cameras': return {
|
|
||||||
heading: 'Cameras',
|
|
||||||
accessory: <IoMdCamera />,
|
|
||||||
items: cameras.map(({ camera, count }) => ({
|
|
||||||
label: formatCameraText(camera),
|
|
||||||
annotation: formatCount(count),
|
|
||||||
annotationAria: formatCountDescriptive(count),
|
|
||||||
path: pathForCamera(camera),
|
|
||||||
})),
|
|
||||||
};
|
|
||||||
case 'recipes': return {
|
case 'recipes': return {
|
||||||
heading: 'Recipes',
|
heading: 'Recipes',
|
||||||
accessory: <TbChecklist
|
accessory: <IconRecipe
|
||||||
size={15}
|
size={15}
|
||||||
className="translate-x-[-1px]"
|
className="translate-x-[-1px]"
|
||||||
/>,
|
/>,
|
||||||
@ -288,9 +304,7 @@ export default function CommandKClient({
|
|||||||
};
|
};
|
||||||
case 'films': return {
|
case 'films': return {
|
||||||
heading: 'Film Simulations',
|
heading: 'Film Simulations',
|
||||||
accessory: <span className="w-3">
|
accessory: <IconFilmSimulation size={14} />,
|
||||||
<PhotoFilmSimulationIcon className="translate-y-[0.5px]" />
|
|
||||||
</span>,
|
|
||||||
items: simulations.map(({ simulation, count }) => ({
|
items: simulations.map(({ simulation, count }) => ({
|
||||||
label: labelForFilmSimulation(simulation).medium,
|
label: labelForFilmSimulation(simulation).medium,
|
||||||
annotation: formatCount(count),
|
annotation: formatCount(count),
|
||||||
@ -300,9 +314,7 @@ export default function CommandKClient({
|
|||||||
};
|
};
|
||||||
case 'focal-lengths': return {
|
case 'focal-lengths': return {
|
||||||
heading: 'Focal Lengths',
|
heading: 'Focal Lengths',
|
||||||
accessory: <TbCone
|
accessory: <IconFocalLength className="text-[14px]" />,
|
||||||
className="rotate-[270deg] text-[14px]"
|
|
||||||
/>,
|
|
||||||
items: focalLengths.map(({ focal, count }) => ({
|
items: focalLengths.map(({ focal, count }) => ({
|
||||||
label: formatFocalLength(focal)!,
|
label: formatFocalLength(focal)!,
|
||||||
annotation: formatCount(count),
|
annotation: formatCount(count),
|
||||||
@ -313,7 +325,7 @@ export default function CommandKClient({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter(Boolean) as CommandKSection[]
|
.filter(Boolean) as CommandKSection[]
|
||||||
, [tagsIncludingHidden, cameras, recipes, simulations, focalLengths]);
|
, [tagsIncludingHidden, cameras, lenses, recipes, simulations, focalLengths]);
|
||||||
|
|
||||||
const clientSections: CommandKSection[] = [{
|
const clientSections: CommandKSection[] = [{
|
||||||
heading: 'Theme',
|
heading: 'Theme',
|
||||||
|
|||||||
@ -41,6 +41,15 @@ export const getLensFromParams = ({
|
|||||||
model: parameterize(model),
|
model: parameterize(model),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const sortLensesWithCount = (
|
||||||
|
a: LensWithCount,
|
||||||
|
b: LensWithCount,
|
||||||
|
) => {
|
||||||
|
const aText = formatLensText(a.lens);
|
||||||
|
const bText = formatLensText(b.lens);
|
||||||
|
return aText.localeCompare(bText);
|
||||||
|
};
|
||||||
|
|
||||||
export const lensFromPhoto = (
|
export const lensFromPhoto = (
|
||||||
photo: Photo | undefined,
|
photo: Photo | undefined,
|
||||||
fallback?: Lens,
|
fallback?: Lens,
|
||||||
@ -55,15 +64,24 @@ const isLensMakeApple = (make?: string) =>
|
|||||||
export const isLensApple = ({ make }: Lens) =>
|
export const isLensApple = ({ make }: Lens) =>
|
||||||
isLensMakeApple(make);
|
isLensMakeApple(make);
|
||||||
|
|
||||||
const formatAppleLensText = (model: string) => {
|
const formatAppleLensText = (
|
||||||
if (model.includes('front')) {
|
model: string,
|
||||||
return 'Front Camera';
|
includePhoneName?: boolean,
|
||||||
} else {
|
) => {
|
||||||
if (model.includes('15 Pro')) {
|
if (model.includes('15 Pro')) {
|
||||||
if (model.includes('f/2.2')) { return 'Wide Camera'; }
|
const phoneName = '15 Pro';
|
||||||
if (model.includes('f/1.78')) { return 'Main Camera'; }
|
if (model.includes('front')) { return includePhoneName
|
||||||
if (model.includes('f/2.8')) { return 'Telephoto Camera'; }
|
? `${phoneName}: Front Camera`
|
||||||
}
|
: 'Front Camera'; }
|
||||||
|
if (model.includes('f/2.2')) { return includePhoneName
|
||||||
|
? `${phoneName}: Wide Camera`
|
||||||
|
: 'Wide Camera'; }
|
||||||
|
if (model.includes('f/1.78')) { return includePhoneName
|
||||||
|
? `${phoneName}: Main Camera`
|
||||||
|
: 'Main Camera'; }
|
||||||
|
if (model.includes('f/2.8')) { return includePhoneName
|
||||||
|
? `${phoneName}: Telephoto Camera`
|
||||||
|
: 'Telephoto Camera'; }
|
||||||
}
|
}
|
||||||
return model;
|
return model;
|
||||||
};
|
};
|
||||||
@ -84,13 +102,16 @@ export const formatLensText = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
const model = isLensMakeApple(make)
|
const model = isLensMakeApple(make)
|
||||||
? formatAppleLensText(modelRaw)
|
? formatAppleLensText(modelRaw, length === 'medium')
|
||||||
: modelRaw;
|
: modelRaw;
|
||||||
|
|
||||||
switch (length) {
|
switch (length) {
|
||||||
case 'long':
|
case 'long':
|
||||||
case 'medium':
|
|
||||||
return `${make} ${model}`;
|
return `${make} ${model}`;
|
||||||
|
case 'medium':
|
||||||
|
return doesModelStartWithMake
|
||||||
|
? model.replace(makeSimple, '').trim()
|
||||||
|
: model;
|
||||||
case 'short':
|
case 'short':
|
||||||
return doesModelStartWithMake
|
return doesModelStartWithMake
|
||||||
? model.replace(makeSimple, '').trim()
|
? model.replace(makeSimple, '').trim()
|
||||||
|
|||||||
@ -11,19 +11,22 @@ import { useEffect } from 'react';
|
|||||||
import { useAppState } from '@/state/AppState';
|
import { useAppState } from '@/state/AppState';
|
||||||
import clsx from 'clsx/lite';
|
import clsx from 'clsx/lite';
|
||||||
import { Recipes } from '@/recipe';
|
import { Recipes } from '@/recipe';
|
||||||
|
import { Lenses } from '@/lens';
|
||||||
|
|
||||||
export default function PhotoGridPage({
|
export default function PhotoGridPage({
|
||||||
photos,
|
photos,
|
||||||
photosCount,
|
photosCount,
|
||||||
tags,
|
|
||||||
cameras,
|
cameras,
|
||||||
|
lenses,
|
||||||
|
tags,
|
||||||
simulations,
|
simulations,
|
||||||
recipes,
|
recipes,
|
||||||
}: {
|
}: {
|
||||||
photos: Photo[]
|
photos: Photo[]
|
||||||
photosCount: number
|
photosCount: number
|
||||||
tags: Tags
|
|
||||||
cameras: Cameras
|
cameras: Cameras
|
||||||
|
lenses: Lenses
|
||||||
|
tags: Tags
|
||||||
simulations: FilmSimulations
|
simulations: FilmSimulations
|
||||||
recipes: Recipes
|
recipes: Recipes
|
||||||
}) {
|
}) {
|
||||||
@ -65,6 +68,7 @@ export default function PhotoGridPage({
|
|||||||
<PhotoGridSidebar {...{
|
<PhotoGridSidebar {...{
|
||||||
tags,
|
tags,
|
||||||
cameras,
|
cameras,
|
||||||
|
lenses,
|
||||||
simulations,
|
simulations,
|
||||||
recipes,
|
recipes,
|
||||||
photosCount,
|
photosCount,
|
||||||
|
|||||||
@ -24,16 +24,21 @@ import IconCamera from '@/components/icons/IconCamera';
|
|||||||
import IconRecipe from '@/components/icons/IconRecipe';
|
import IconRecipe from '@/components/icons/IconRecipe';
|
||||||
import IconTag from '@/components/icons/IconTag';
|
import IconTag from '@/components/icons/IconTag';
|
||||||
import IconFilmSimulation from '@/components/icons/IconFilmSimulation';
|
import IconFilmSimulation from '@/components/icons/IconFilmSimulation';
|
||||||
|
import IconLens from '@/components/icons/IconLens';
|
||||||
|
import { Lenses, sortLensesWithCount } from '@/lens';
|
||||||
|
import PhotoLens from '@/lens/PhotoLens';
|
||||||
|
|
||||||
export default function PhotoGridSidebar({
|
export default function PhotoGridSidebar({
|
||||||
tags,
|
|
||||||
cameras,
|
cameras,
|
||||||
|
lenses,
|
||||||
|
tags,
|
||||||
simulations,
|
simulations,
|
||||||
recipes,
|
recipes,
|
||||||
photosCount,
|
photosCount,
|
||||||
photosDateRange,
|
photosDateRange,
|
||||||
}: {
|
}: {
|
||||||
tags: Tags
|
tags: Tags
|
||||||
|
lenses: Lenses
|
||||||
cameras: Cameras
|
cameras: Cameras
|
||||||
simulations: FilmSimulations
|
simulations: FilmSimulations
|
||||||
recipes: Recipes
|
recipes: Recipes
|
||||||
@ -48,6 +53,47 @@ export default function PhotoGridSidebar({
|
|||||||
addHiddenToTags(tags, photosCountHidden)
|
addHiddenToTags(tags, photosCountHidden)
|
||||||
, [tags, photosCountHidden]);
|
, [tags, photosCountHidden]);
|
||||||
|
|
||||||
|
const camerasContent = cameras.length > 0
|
||||||
|
? <HeaderList
|
||||||
|
key="cameras"
|
||||||
|
title="Cameras"
|
||||||
|
icon={<IconCamera size={15} />}
|
||||||
|
items={cameras
|
||||||
|
.sort(sortCamerasWithCount)
|
||||||
|
.map(({ cameraKey, camera, count }) =>
|
||||||
|
<PhotoCamera
|
||||||
|
key={cameraKey}
|
||||||
|
camera={camera}
|
||||||
|
type="text-only"
|
||||||
|
countOnHover={count}
|
||||||
|
prefetch={false}
|
||||||
|
contrast="low"
|
||||||
|
hideAppleIcon
|
||||||
|
badged
|
||||||
|
/>)}
|
||||||
|
/>
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const lensesContent = lenses.length > 0
|
||||||
|
? <HeaderList
|
||||||
|
key="lenses"
|
||||||
|
title="Lenses"
|
||||||
|
icon={<IconLens size={15} />}
|
||||||
|
items={lenses
|
||||||
|
.sort(sortLensesWithCount)
|
||||||
|
.map(({ lensKey, lens, count }) =>
|
||||||
|
<PhotoLens
|
||||||
|
key={lensKey}
|
||||||
|
lens={lens}
|
||||||
|
type="text-only"
|
||||||
|
countOnHover={count}
|
||||||
|
prefetch={false}
|
||||||
|
contrast="low"
|
||||||
|
badged
|
||||||
|
/>)}
|
||||||
|
/>
|
||||||
|
: null;
|
||||||
|
|
||||||
const tagsContent = tags.length > 0
|
const tagsContent = tags.length > 0
|
||||||
? <HeaderList
|
? <HeaderList
|
||||||
key="tags"
|
key="tags"
|
||||||
@ -91,27 +137,6 @@ export default function PhotoGridSidebar({
|
|||||||
/>
|
/>
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const camerasContent = cameras.length > 0
|
|
||||||
? <HeaderList
|
|
||||||
key="cameras"
|
|
||||||
title="Cameras"
|
|
||||||
icon={<IconCamera size={15} />}
|
|
||||||
items={cameras
|
|
||||||
.sort(sortCamerasWithCount)
|
|
||||||
.map(({ cameraKey, camera, count }) =>
|
|
||||||
<PhotoCamera
|
|
||||||
key={cameraKey}
|
|
||||||
camera={camera}
|
|
||||||
type="text-only"
|
|
||||||
countOnHover={count}
|
|
||||||
prefetch={false}
|
|
||||||
contrast="low"
|
|
||||||
hideAppleIcon
|
|
||||||
badged
|
|
||||||
/>)}
|
|
||||||
/>
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const recipesContent = recipes.length > 0
|
const recipesContent = recipes.length > 0
|
||||||
? <HeaderList
|
? <HeaderList
|
||||||
key="recipes"
|
key="recipes"
|
||||||
@ -183,8 +208,9 @@ export default function PhotoGridSidebar({
|
|||||||
/>}
|
/>}
|
||||||
{CATEGORY_VISIBILITY.map(category => {
|
{CATEGORY_VISIBILITY.map(category => {
|
||||||
switch (category) {
|
switch (category) {
|
||||||
case 'cameras': return camerasContent;
|
|
||||||
case 'tags': return tagsContent;
|
case 'tags': return tagsContent;
|
||||||
|
case 'cameras': return camerasContent;
|
||||||
|
case 'lenses': return lensesContent;
|
||||||
case 'recipes': return recipesContent;
|
case 'recipes': return recipesContent;
|
||||||
case 'films': return filmsContent;
|
case 'films': return filmsContent;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,24 @@
|
|||||||
import {
|
import {
|
||||||
getUniqueCamerasCached,
|
getUniqueCamerasCached,
|
||||||
getUniqueFilmSimulationsCached,
|
getUniqueFilmSimulationsCached,
|
||||||
|
getUniqueLensesCached,
|
||||||
getUniqueRecipesCached,
|
getUniqueRecipesCached,
|
||||||
getUniqueTagsCached,
|
getUniqueTagsCached,
|
||||||
} from '@/photo/cache';
|
} from '@/photo/cache';
|
||||||
import {
|
import {
|
||||||
getUniqueCameras,
|
getUniqueCameras,
|
||||||
getUniqueFilmSimulations,
|
getUniqueFilmSimulations,
|
||||||
|
getUniqueLenses,
|
||||||
getUniqueRecipes,
|
getUniqueRecipes,
|
||||||
getUniqueTags,
|
getUniqueTags,
|
||||||
} from '@/photo/db/query';
|
} from '@/photo/db/query';
|
||||||
import { SHOW_FILM_SIMULATIONS, SHOW_RECIPES } from '@/app/config';
|
import { SHOW_FILM_SIMULATIONS, SHOW_LENSES, SHOW_RECIPES } from '@/app/config';
|
||||||
import { sortTagsObject } from '@/tag';
|
import { sortTagsObject } from '@/tag';
|
||||||
|
|
||||||
export const getPhotoSidebarData = () => [
|
export const getPhotoSidebarData = () => [
|
||||||
getUniqueTags().then(sortTagsObject).catch(() => []),
|
|
||||||
getUniqueCameras().catch(() => []),
|
getUniqueCameras().catch(() => []),
|
||||||
|
SHOW_LENSES ? getUniqueLenses().catch(() => []) : [],
|
||||||
|
getUniqueTags().then(sortTagsObject).catch(() => []),
|
||||||
SHOW_FILM_SIMULATIONS
|
SHOW_FILM_SIMULATIONS
|
||||||
? getUniqueFilmSimulations().catch(() => [])
|
? getUniqueFilmSimulations().catch(() => [])
|
||||||
: [],
|
: [],
|
||||||
@ -25,8 +28,9 @@ export const getPhotoSidebarData = () => [
|
|||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export const getPhotoSidebarDataCached = () => [
|
export const getPhotoSidebarDataCached = () => [
|
||||||
getUniqueTagsCached().then(sortTagsObject),
|
|
||||||
getUniqueCamerasCached(),
|
getUniqueCamerasCached(),
|
||||||
|
SHOW_LENSES ? getUniqueLensesCached() : [],
|
||||||
|
getUniqueTagsCached().then(sortTagsObject),
|
||||||
SHOW_FILM_SIMULATIONS ? getUniqueFilmSimulationsCached() : [],
|
SHOW_FILM_SIMULATIONS ? getUniqueFilmSimulationsCached() : [],
|
||||||
SHOW_RECIPES ? getUniqueRecipesCached() : [],
|
SHOW_RECIPES ? getUniqueRecipesCached() : [],
|
||||||
] as const;
|
] as const;
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Photo } from '.';
|
|||||||
import { Camera, Cameras } from '@/camera';
|
import { Camera, Cameras } from '@/camera';
|
||||||
import { PhotoDateRange } from '.';
|
import { PhotoDateRange } from '.';
|
||||||
import { FilmSimulation, FilmSimulations } from '@/simulation';
|
import { FilmSimulation, FilmSimulations } from '@/simulation';
|
||||||
import { Lens } from '@/lens';
|
import { Lens, Lenses } from '@/lens';
|
||||||
import { Tags } from '@/tag';
|
import { Tags } from '@/tag';
|
||||||
import { FocalLengths } from '@/focal';
|
import { FocalLengths } from '@/focal';
|
||||||
import { Recipes } from '@/recipe';
|
import { Recipes } from '@/recipe';
|
||||||
@ -43,8 +43,9 @@ export interface PhotoSetCategory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface PhotoSetCategories {
|
export interface PhotoSetCategories {
|
||||||
tags: Tags
|
|
||||||
cameras: Cameras
|
cameras: Cameras
|
||||||
|
lenses: Lenses
|
||||||
|
tags: Tags
|
||||||
recipes: Recipes
|
recipes: Recipes
|
||||||
simulations: FilmSimulations
|
simulations: FilmSimulations
|
||||||
focalLengths: FocalLengths
|
focalLengths: FocalLengths
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user