feat: add preview button when selecting images (#27305)

* Add preview button when selecting images

* Fix test helper

* prettier

* styling

---------

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
John Maguire 2026-04-03 12:21:43 -04:00 committed by GitHub
parent a2687d674e
commit 4fcd9c2e0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 26 additions and 1 deletions

View File

@ -62,7 +62,7 @@ export const thumbnailUtils = {
return page.locator(`[data-thumbnail-focus-container][data-asset="${assetId}"]`);
},
selectButton(page: Page, assetId: string) {
return page.locator(`[data-thumbnail-focus-container][data-asset="${assetId}"] button`);
return page.locator(`[data-thumbnail-focus-container][data-asset="${assetId}"] button[role="checkbox"]`);
},
selectedAsset(page: Page) {
return page.locator('[data-thumbnail-focus-container][data-selected]');

View File

@ -19,6 +19,7 @@
mdiCheckCircle,
mdiFileGifBox,
mdiHeart,
mdiMagnifyPlusOutline,
mdiMotionPauseOutline,
mdiMotionPlayOutline,
mdiRotate360,
@ -46,6 +47,7 @@
dimmed?: boolean;
albumUsers?: UserResponseDto[];
onClick?: (asset: TimelineAsset) => void;
onPreview?: (asset: TimelineAsset) => void;
onSelect?: (asset: TimelineAsset) => void;
onMouseEvent?: (event: { isMouseOver: boolean; selectedGroupIndex: number }) => void;
}
@ -65,6 +67,7 @@
showStackedIcon = true,
albumUsers = [],
onClick = undefined,
onPreview = undefined,
onSelect = undefined,
onMouseEvent = undefined,
imageClass = '',
@ -442,6 +445,24 @@
</button>
{/if}
<!-- Preview asset button (visible on hover when any asset is selected) -->
{#if mouseOver && onPreview}
<button
type="button"
onclick={(e) => {
e.stopPropagation();
e.preventDefault();
onPreview?.($state.snapshot(asset));
}}
class="absolute z-2 bottom-1 end-1 rounded-full bg-black/25 p-1.5 hover:bg-black/50 focus:outline-none transition-colors"
in:fade={{ duration: 100 }}
tabindex={-1}
aria-label="Preview asset"
>
<Icon icon={mdiMagnifyPlusOutline} size="20" class="text-white" />
</button>
{/if}
<!-- Outline on focus -->
<div
class={[

View File

@ -376,6 +376,7 @@
void navigateToAsset(asset);
}}
onSelect={() => handleSelectAssets(currentAsset)}
onPreview={assetInteraction.selectionActive ? () => void navigateToAsset(asset) : undefined}
onMouseEvent={() => assetMouseEventHandler(currentAsset)}
{showArchiveIcon}
asset={currentAsset}

View File

@ -698,6 +698,9 @@
void onSelectAssets(asset);
}}
onMouseEvent={() => handleSelectAssetCandidates(asset)}
onPreview={isSelectionMode || assetInteraction.selectionActive
? (asset) => void navigate({ targetRoute: 'current', assetId: asset.id })
: undefined}
selected={isAssetSelected}
selectionCandidate={isAssetSelectionCandidate}
disabled={isAssetDisabled}