diff --git a/.vscode/settings.json b/.vscode/settings.json index e45a8d61..ebeffbc6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,6 +6,7 @@ "exif", "hgetall", "hset", + "Lightbox", "nanoids", "nextjs", "qaub", diff --git a/src/app/(auth-state)/admin/tags/[tag]/edit/page.tsx b/src/app/(auth-state)/admin/tags/[tag]/edit/page.tsx index 190d88a4..ec88375e 100644 --- a/src/app/(auth-state)/admin/tags/[tag]/edit/page.tsx +++ b/src/app/(auth-state)/admin/tags/[tag]/edit/page.tsx @@ -1,12 +1,13 @@ import AdminChildPage from '@/components/AdminChildPage'; import { redirect } from 'next/navigation'; -import { getPhotosCached } from '@/cache'; +import { getPhotosCached, getPhotosTagCountCached } from '@/cache'; import TagForm from '@/tag/TagForm'; -import { PATH_ADMIN, PATH_ADMIN_TAGS } from '@/site/paths'; -import { getPhotosTagCount } from '@/services/postgres'; +import { PATH_ADMIN, PATH_ADMIN_TAGS, pathForTag } from '@/site/paths'; import PhotoTag from '@/tag/PhotoTag'; -import { photoQuantityText } from '@/photo'; -import PhotoGrid from '@/photo/PhotoGrid'; +import { photoLabelForCount } from '@/photo'; +import PhotoLightbox from '@/photo/PhotoLightbox'; + +const MAX_PHOTO_TO_SHOW = 6; export const runtime = 'edge'; @@ -19,8 +20,8 @@ export default async function PhotoPageEdit({ params: { tag } }: Props) { count, photos, ] = await Promise.all([ - getPhotosTagCount(tag), - getPhotosCached({ tag }), + getPhotosTagCountCached(tag), + getPhotosCached({ tag, limit: MAX_PHOTO_TO_SHOW }), ]); if (count === 0) { redirect(PATH_ADMIN); } @@ -32,18 +33,21 @@ export default async function PhotoPageEdit({ params: { tag } }: Props) { breadcrumb={
- {photoQuantityText(count, false)} + {count} + +   + {photoLabelForCount(count)} +
} > -
- + - -
+ ); }; diff --git a/src/components/AdminChildPage.tsx b/src/components/AdminChildPage.tsx index e495501d..b2fc46f9 100644 --- a/src/components/AdminChildPage.tsx +++ b/src/components/AdminChildPage.tsx @@ -20,7 +20,10 @@ function AdminChildPage({ contentMain={
{backPath && -
+
)} + />).concat(additionalTile ?? [])} /> {showMorePath && } diff --git a/src/photo/PhotoLightbox.tsx b/src/photo/PhotoLightbox.tsx new file mode 100644 index 00000000..7c79ba45 --- /dev/null +++ b/src/photo/PhotoLightbox.tsx @@ -0,0 +1,51 @@ +import { cc } from '@/utility/css'; +import { Photo } from '.'; +import PhotoGrid from './PhotoGrid'; +import Link from 'next/link'; + +export default function PhotoLightbox({ + count, + photos, + maxPhotosToShow = 6, + moreLink, +}: { + count: number + photos: Photo[] + maxPhotosToShow?: number + moreLink: string +}) { + const photoCountToShow = maxPhotosToShow < count + ? maxPhotosToShow - 1 + : maxPhotosToShow; + + const countNotShown = count - photoCountToShow; + + const showOverageTile = countNotShown > 0; + + return ( +
+ +
+ +{countNotShown} +
+
More
+ + : undefined} + small + /> +
+ ); +} diff --git a/src/photo/index.ts b/src/photo/index.ts index 971fadbe..a6ee8910 100644 --- a/src/photo/index.ts +++ b/src/photo/index.ts @@ -154,7 +154,7 @@ export const translatePhotoId = (id: string) => export const titleForPhoto = (photo: Photo) => photo.title || 'Untitled'; -const photoLabelForCount = (count: number) => +export const photoLabelForCount = (count: number) => count === 1 ? 'Photo' : 'Photos'; export const photoQuantityText = (count: number, includeParentheses = true) => diff --git a/src/tag/TagForm.tsx b/src/tag/TagForm.tsx index 869519d5..27d3ea35 100644 --- a/src/tag/TagForm.tsx +++ b/src/tag/TagForm.tsx @@ -4,14 +4,16 @@ import SubmitButtonWithStatus from '@/components/SubmitButtonWithStatus'; import Link from 'next/link'; import { PATH_ADMIN_TAGS } from '@/site/paths'; import FieldSetWithStatus from '@/components/FieldSetWithStatus'; -import { useMemo, useState } from 'react'; +import { ReactNode, useMemo, useState } from 'react'; import { renamePhotoTagGloballyAction } from '@/photo/actions'; import { parameterize } from '@/utility/string'; export default function TagForm({ tag, + children, }: { tag: string + children?: ReactNode }) { const [updatedTagRaw, setUpdatedTagRaw] = useState(tag); @@ -49,6 +51,7 @@ export default function TagForm({ hidden readOnly /> + {children}