Add conditional admin menu to photo tiles

This commit is contained in:
Sam Becker 2024-02-16 17:45:59 -06:00
parent b6da801c8c
commit 5d85fbf862
3 changed files with 21 additions and 6 deletions

View File

@ -35,9 +35,9 @@ export default function MoreMenu({
<button
className={clsx(
buttonClassName,
'p-1 py-1 min-h-0 border-none shadow-none outline-none',
'hover:bg-gray-50 active:bg-gray-100',
'hover:dark:bg-gray-900/75 active:dark:bg-gray-900',
'p-1 min-h-0 border-none shadow-none hover:outline-none',
'hover:bg-gray-100 active:bg-gray-100',
'hover:dark:bg-gray-800/75 active:dark:bg-gray-900',
'text-dim',
)}
aria-label={`Choose an action for photo: ${'photo'}`}
@ -54,7 +54,7 @@ export default function MoreMenu({
'min-w-[8rem]',
'ml-2.5',
'p-1 rounded-md border',
'bg-content outline-none',
'bg-content',
'shadow-lg dark:shadow-xl',
)}
>
@ -65,7 +65,7 @@ export default function MoreMenu({
className={clsx(
'block w-full',
'border-none min-h-0 bg-transparent',
'select-none outline-none',
'select-none hover:outline-none',
'text-sm text-main text-left',
'px-3 py-1.5 rounded-[3px]',
'hover:text-main',

View File

@ -60,7 +60,7 @@ export default function PhotoGrid({
'aspect-square',
'overflow-hidden',
'[&>*]:flex [&>*]:w-full [&>*]:h-full',
'[&>*>*]:object-cover [&>*>*]:min-h-full',
'[&>*>*]:object-cover',
)
: undefined}
style={{

View File

@ -5,6 +5,8 @@ import { clsx } from 'clsx/lite';
import { pathForPhoto } from '@/site/paths';
import { Camera } from '@/camera';
import { FilmSimulation } from '@/simulation';
import AdminPhotoMenu from '@/admin/AdminPhotoMenu';
import { Suspense } from 'react';
export default function PhotoSmall({
photo,
@ -12,21 +14,34 @@ export default function PhotoSmall({
camera,
simulation,
selected,
showAdminMenu,
}: {
photo: Photo
tag?: string
camera?: Camera
simulation?: FilmSimulation
selected?: boolean
showAdminMenu?: boolean
}) {
return (
<Link
href={pathForPhoto(photo, tag, camera, simulation)}
className={clsx(
'relative group',
'active:brightness-75',
selected && 'brightness-50',
)}
>
<Suspense>
{showAdminMenu &&
<AdminPhotoMenu
buttonClassName={clsx(
'absolute top-1 right-1 opacity-0',
'group-hover:opacity-100 group-focus:opacity-100',
)}
photo={photo}
/>}
</Suspense>
<ImageSmall
src={photo.url}
aspectRatio={photo.aspectRatio}