Compacte tegels in de opruim- en verwijderdialoog
Continuous Integration / config-asf (pull_request) Successful in 6s
Continuous Integration / config-sls (pull_request) Successful in 8s
Continuous Integration / changes (pull_request) Successful in 30s
Continuous Integration / backend-build (pull_request) Successful in 1m23s
Continuous Integration / compile-sites (pull_request) Successful in 1m48s
Continuous Integration / vulnerability-scan (pull_request) Successful in 1m59s
Continuous Integration / frontend-prepare (pull_request) Successful in 2m27s
Continuous Integration / frontend-build (pull_request) Successful in 57s
Continuous Integration / backend-test (pull_request) Successful in 3m40s
Continuous Integration / frontend-test (pull_request) Successful in 2m53s
Continuous Integration / frontend-lint (pull_request) Successful in 3m31s
Continuous Integration / publish-sls-test (pull_request) Skipped
Continuous Integration / publish-sls-production (pull_request) Skipped
Continuous Integration / deploy-sls-test (pull_request) Skipped
Continuous Integration / deploy-sls-production (pull_request) Skipped
Continuous Integration / publish-asf-test (pull_request) Skipped
Continuous Integration / deploy-asf-test (pull_request) Skipped
Continuous Integration / smoke-sls-test (pull_request) Skipped
Continuous Integration / smoke-asf-test (pull_request) Skipped

PhotoSelectionList krijgt layout 'compact' (kleine vierkante thumbnails, naam en gebruik op een regel, details in de tooltip). De opruimdialoog gebruikt die; de plekken-lijst van de tweede verwijderstap is een compact raster.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 23:01:05 +01:00
co-authored by Claude Sonnet 5.5
parent 18c6f9598a
commit 821acc4396
5 changed files with 81 additions and 16 deletions
@@ -108,6 +108,7 @@ export function CleanupDialog({ open, onOpenChange }: { open: boolean; onOpenCha
items={items}
selection={selection}
onSelectionChange={setSelection}
layout="compact"
bulk={{
actions: [],
onClear: () => setSelection(new Set()),
@@ -85,12 +85,23 @@ function DeleteDialogBody({ items, onClose, onDone }: { items: readonly PhotoIte
</p>
)}
{step === 'second' && (
<ul className="max-h-60 space-y-1 overflow-y-auto text-sm" data-testid="delete-places">
{inUse.map((item) => (
<li key={item.id}>
<span className="font-medium">{item.name}</span>: {item.uses.map((use) => usageLabel(t, use)).join('; ')}
</li>
))}
<ul className="grid max-h-60 grid-cols-3 gap-2 overflow-y-auto sm:grid-cols-4" data-testid="delete-places">
{inUse.map((item) => {
const places = item.uses.map((use) => usageLabel(t, use)).join('; ');
return (
<li key={item.id} className="overflow-hidden rounded-md border bg-card" title={`${item.name}: ${places}`} data-testid={`delete-place-${item.id}`}>
{item.thumbnailUrl ? (
<img src={item.thumbnailUrl} alt="" loading="lazy" className="aspect-square w-full object-cover" />
) : (
<span className="flex aspect-square w-full items-center justify-center bg-muted text-[10px] text-muted-foreground">{t('media.list.noThumbnail')}</span>
)}
<div className="min-w-0 px-1.5 py-1">
<p className="truncate text-xs font-medium">{item.name}</p>
<p className="truncate text-[11px] leading-tight">{places}</p>
</div>
</li>
);
})}
</ul>
)}
{trash.isError && (
@@ -13,7 +13,7 @@ const items: PhotoItem[] = [
{ id: 'p4', name: 'Foto 4', bytes: 10, createdAt: '2026-11-14T10:00:00Z', uses: [] },
];
function Harness({ disabled, layout }: { disabled?: (item: PhotoItem) => boolean; layout?: 'list' | 'tiles' }) {
function Harness({ disabled, layout }: { disabled?: (item: PhotoItem) => boolean; layout?: 'list' | 'tiles' | 'compact' }) {
const [selection, setSelection] = useState<Selection>(emptySelection);
return (
<>
@@ -192,6 +192,20 @@ describe('the bulk bar is part of the list header, above the photos', () => {
expect(screen.getByRole('checkbox', { name: 'Foto 3' })).toBeChecked();
});
it('compact layout: small tiles, the whole tile selects, name and usage stay available', async () => {
render(<Harness layout="compact" />);
expect(screen.getByTestId('photo-items')).toHaveAttribute('data-layout', 'compact');
expect(screen.getByTestId('photo-chip-p1')).toBeInTheDocument();
expect(screen.getByTestId('photo-usage-p1')).toBeInTheDocument();
expect(screen.getByTestId('photo-row-p1')).toHaveAttribute('title', expect.stringContaining('Foto 1'));
await userEvent.click(screen.getByTestId('photo-row-p1'));
expect(screen.getByRole('checkbox', { name: 'Foto 1' })).toBeChecked();
await userEvent.click(screen.getByTestId('photo-select-all'));
expect(screen.getByRole('checkbox', { name: 'Foto 3' })).toBeChecked();
});
it('does not select a disabled tile by clicking it', async () => {
render(<Harness layout="tiles" disabled={(item) => item.id === 'p1'} />);
@@ -39,8 +39,8 @@ interface PhotoSelectionListProps {
renderUse?: (use: PhotoUse, label: string) => ReactNode;
/** The actions on the selection. They appear in the header of the list, above the photos, once something is selected. */
bulk?: Omit<BulkActionBarProps, 'count'>;
/** A list of rows (default) or a grid of tiles with big thumbnails. Everything works in both. */
layout?: 'list' | 'tiles';
/** A list of rows (default), a grid of tiles with big thumbnails, or a dense grid of small thumbnails ('compact', for the dialogs). Everything works in all. */
layout?: 'list' | 'tiles' | 'compact';
}
/**
@@ -89,7 +89,13 @@ export function PhotoSelectionList({ items, selection, onSelectionChange, isDisa
</span>
</div>
<ul
className={layout === 'tiles' ? 'grid grid-cols-3 gap-3 py-3 sm:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6' : 'divide-y'}
className={
layout === 'tiles'
? 'grid grid-cols-3 gap-3 py-3 sm:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6'
: layout === 'compact'
? 'grid grid-cols-3 gap-2 py-2 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-8'
: 'divide-y'
}
aria-label={t('media.list.label')}
data-layout={layout}
data-testid="photo-items"
@@ -97,7 +103,8 @@ export function PhotoSelectionList({ items, selection, onSelectionChange, isDisa
{items.map((item) => {
const disabled = isDisabled?.(item) ?? false;
const labelId = `photo-${item.id}-label`;
const tiles = layout === 'tiles';
const compact = layout === 'compact';
const tiles = layout === 'tiles' || compact;
const checkbox = (
<Checkbox
aria-labelledby={labelId}
@@ -109,13 +116,43 @@ export function PhotoSelectionList({ items, selection, onSelectionChange, isDisa
/>
);
const thumbnail = item.thumbnailUrl ? (
<img src={item.thumbnailUrl} alt="" loading="lazy" className={cn('object-cover', tiles ? 'aspect-[3/2] w-full' : 'size-14 shrink-0 rounded')} />
<img src={item.thumbnailUrl} alt="" loading="lazy" className={cn('object-cover', compact ? 'aspect-square w-full' : tiles ? 'aspect-[3/2] w-full' : 'size-14 shrink-0 rounded')} />
) : (
<span className={cn('flex items-center justify-center bg-muted text-xs text-muted-foreground', tiles ? 'aspect-[3/2] w-full' : 'size-14 shrink-0 rounded')}>
<span className={cn('flex items-center justify-center bg-muted text-xs text-muted-foreground', compact ? 'aspect-square w-full text-[10px]' : tiles ? 'aspect-[3/2] w-full' : 'size-14 shrink-0 rounded')}>
{t('media.list.noThumbnail')}
</span>
);
const details = (
// The compact tile keeps everything in the tooltip: the full name, date and size, and where the photo is used.
const usageText = item.deletedAt
? t('media.trash.since', { date: dateFormat.format(new Date(item.deletedAt)) })
: item.uses.length === 0
? item.unusedSince
? t('media.use.noneSince', { date: dateFormat.format(new Date(item.unusedSince)) })
: t('media.use.none')
: item.uses.map((use) => usageLabel(t, use)).join('; ');
const tooltip = `${item.name} (${dateFormat.format(new Date(item.createdAt))} · ${formatBytes(item.bytes, i18n.language)}): ${usageText}`;
const details = compact ? (
<div className="min-w-0">
<p id={labelId} className="truncate text-xs font-medium" title={tooltip}>
{item.name}
</p>
<p className="truncate text-[11px] leading-tight" data-testid={`photo-usage-${item.id}`} title={usageText}>
{item.deletedAt || item.uses.length === 0 ? (
<span className="text-muted-foreground">{usageText}</span>
) : (
item.uses.map((use, index) => {
const label = usageLabel(t, use);
return (
<span key={`${use.module}-${use.kind}-${use.position ?? index}`}>
{index > 0 && '; '}
{renderUse ? renderUse(use, label) : label}
</span>
);
})
)}
</p>
</div>
) : (
<div className="min-w-0 flex-1">
<p id={labelId} className="truncate text-sm font-medium">
{item.name}
@@ -149,6 +186,7 @@ export function PhotoSelectionList({ items, selection, onSelectionChange, isDisa
return tiles ? (
<li
key={item.id}
title={compact ? tooltip : undefined}
className={cn('relative overflow-hidden rounded-md border bg-card', !disabled && 'cursor-pointer', selection.has(item.id) && 'ring-2 ring-primary')}
data-testid={`photo-row-${item.id}`}
// The whole tile selects (the box stays for keyboards and screen readers). A link or button on the tile
@@ -159,9 +197,9 @@ export function PhotoSelectionList({ items, selection, onSelectionChange, isDisa
}}
>
{/* flex (not a block with an inline box inside): no line box, so no extra space under the checkbox and equal padding on all four sides */}
<div className="absolute left-2 top-2 z-[1] flex rounded bg-background/90 p-1 shadow-sm" data-testid={`photo-chip-${item.id}`}>{checkbox}</div>
<div className={cn('absolute z-[1] flex rounded bg-background/90 shadow-sm', compact ? 'left-1 top-1 p-0.5' : 'left-2 top-2 p-1')} data-testid={`photo-chip-${item.id}`}>{checkbox}</div>
{thumbnail}
<div className="p-2">{details}</div>
<div className={compact ? 'px-1.5 py-1' : 'p-2'}>{details}</div>
</li>
) : (
<li key={item.id} className="flex items-center gap-3 px-2 py-2" data-testid={`photo-row-${item.id}`}>