Incorporate server-side photo chooser data

This commit is contained in:
Sam Becker 2026-02-28 11:22:22 -06:00
parent 6af00c94f6
commit 42015f7d6d
2 changed files with 24 additions and 8 deletions

View File

@ -20,6 +20,9 @@ export default function AdminAboutEditPage({
about,
photoAvatar: _photoAvatar,
photoHero: _photoHero,
photos,
photosCount,
photosHidden,
}: {
about?: About
photoAvatar?: Photo
@ -68,6 +71,9 @@ export default function AdminAboutEditPage({
onChange={photoIdAvatar => setAboutForm(form =>
({ ...form, photoIdAvatar: convertUrlToPhotoId(photoIdAvatar) }))}
photo={photoAvatar}
photos={photos}
photosCount={photosCount}
photosHidden={photosHidden}
/>
<PhotoAvatar photo={photoAvatar} />
<FieldsetWithStatus

View File

@ -5,17 +5,24 @@ import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
import ImageMedium from '@/components/image/ImageMedium';
import PhotoGridInfinite from '../PhotoGridInfinite';
import { menuSurfaceStyles } from '@/components/primitives/surface';
import { GRID_SPACE_CLASSNAME } from '@/components';
import PhotoGrid from '../PhotoGrid';
export default function FieldsetPhotoChooser({
label,
value,
onChange,
photo,
photos = [],
photosCount,
}: {
label: string
value: string
onChange: (value: string) => void
photo?: Photo
photos?: Photo[]
photosCount?: number
photosHidden?: Photo[]
}) {
return (
<>
@ -44,17 +51,20 @@ export default function FieldsetPhotoChooser({
onCloseAutoFocus={e => e.preventDefault()}
align="start"
sideOffset={10}
className={menuSurfaceStyles('z-20 px-1.5 py-1.5')}>
className={menuSurfaceStyles('z-20 px-1.5 py-1.5')}
>
<div className={clsx(
GRID_SPACE_CLASSNAME,
'w-[14rem] max-h-[20rem] rounded-[3px] overflow-y-auto',
'space-y-1',
)}>
<PhotoGridInfinite
cacheKey="photo-chooser-menu"
initialOffset={0}
sortBy="takenAt"
animate={false}
/>
{photos.length > 0 &&
<PhotoGrid {...{ photos, animate: false }} />}
{(!photosCount || photosCount > photos.length) &&
<PhotoGridInfinite {...{
cacheKey: 'photo-chooser-menu',
initialOffset: photos.length,
animate: false,
}} />}
</div>
</DropdownMenu.Content>
</DropdownMenu.Portal>