Allow about photos to be cleared

This commit is contained in:
Sam Becker 2026-03-08 16:56:38 -05:00
parent 58fac5c81b
commit 8fe3e81bde
2 changed files with 52 additions and 31 deletions

View File

@ -47,7 +47,7 @@ export default function AdminAboutEditPage({
<FieldsetPhotoChooser <FieldsetPhotoChooser
id="photoIdAvatar" id="photoIdAvatar"
label="Avatar" label="Avatar"
value={aboutForm?.photoIdAvatar || photoAvatar?.id || ''} value={aboutForm?.photoIdAvatar ?? photoAvatar?.id ?? ''}
onChange={photoIdAvatar => setAboutForm(form => onChange={photoIdAvatar => setAboutForm(form =>
({ ...form, photoIdAvatar }))} ({ ...form, photoIdAvatar }))}
photo={photoAvatar} photo={photoAvatar}

View File

@ -164,8 +164,14 @@ export default function FieldsetPhotoChooser({
'z-20 rounded-2xl pb-0 overflow-auto', 'z-20 rounded-2xl pb-0 overflow-auto',
)} )}
> >
<div className={clsx(
'flex items-center',
'pt-1 pb-2',
photo
? 'justify-between pl-1.5 pr-3'
: 'justify-center',
)}>
<SegmentMenu <SegmentMenu
className="pt-1 pb-2 px-1.5"
items={[{ items={[{
value: 'all', value: 'all',
}, { }, {
@ -188,6 +194,24 @@ export default function FieldsetPhotoChooser({
} }
}} }}
/> />
{photo && <button
type="button"
className={clsx(
'link',
'font-sans',
'text-xs text-medium font-medium uppercase tracking-wider',
'py-1',
'select-none',
)}
onClick={() => {
setPhoto(undefined);
props.onChange?.('');
setIsOpen(false);
}}
>
Clear
</button>}
</div>
<div <div
ref={refContainer} ref={refContainer}
className={clsx( className={clsx(
@ -198,18 +222,15 @@ export default function FieldsetPhotoChooser({
<div className={clsx( <div className={clsx(
'flex items-center transition-all overflow-hidden', 'flex items-center transition-all overflow-hidden',
showQuery ? 'h-12 opacity-100' : 'h-0 opacity-0', showQuery ? 'h-12 opacity-100' : 'h-0 opacity-0',
'border-t border-medium',
)}> )}>
<div className="w-full px-1.5"> <div className="w-full px-0.5">
<input <input
id="query" id="query"
ref={refInput} ref={refInput}
type="text" type="text"
placeholder="Search for a photo" placeholder="Search for a photo"
className={clsx( className="block w-full m-0 outline-none border-none"
'block w-full m-0 outline-none',
'rounded-full border border-dim',
'mb-2',
)}
value={query} value={query}
onChange={e => setQuery(e.target.value)} onChange={e => setQuery(e.target.value)}
/> />