From 0fda67543de201ecedfe60dfd64fc2988fa17296 Mon Sep 17 00:00:00 2001 From: Ben <45583362+ben-basten@users.noreply.github.com> Date: Thu, 20 Jun 2024 21:15:36 +0000 Subject: [PATCH] chore(web): context menu improvements (#10475) - ability to add custom hover colors - migrate activity menu to ButtonContextMenu component - onClick callbacks rather than events for menu options - remove slots - configurable menu option colors - improve menu option layout --- .../components/album-page/albums-list.svelte | 8 +-- .../album-page/share-info-modal.svelte | 6 +- .../asset-viewer/activity-viewer.svelte | 67 ++++++++----------- .../asset-viewer/asset-viewer-nav-bar.svelte | 26 +++---- .../components/faces-page/people-card.svelte | 8 +-- .../photos-page/actions/add-to-album.svelte | 2 +- .../photos-page/actions/archive-action.svelte | 2 +- .../actions/asset-job-actions.svelte | 2 +- .../actions/change-date-action.svelte | 2 +- .../actions/change-location-action.svelte | 2 +- .../photos-page/actions/delete-assets.svelte | 2 +- .../actions/download-action.svelte | 2 +- .../actions/favorite-action.svelte | 2 +- .../actions/remove-from-album.svelte | 2 +- .../photos-page/actions/stack-action.svelte | 4 +- .../context-menu/menu-option.svelte | 45 +++++-------- .../[[assetId=id]]/+page.svelte | 12 ++-- .../[[assetId=id]]/+page.svelte | 10 +-- .../admin/library-management/+page.svelte | 23 ++++--- 19 files changed, 102 insertions(+), 125 deletions(-) diff --git a/web/src/lib/components/album-page/albums-list.svelte b/web/src/lib/components/album-page/albums-list.svelte index a5802bf13b..1f5d654c4a 100644 --- a/web/src/lib/components/album-page/albums-list.svelte +++ b/web/src/lib/components/album-page/albums-list.svelte @@ -424,13 +424,13 @@ contextMenuTargetAlbum && handleEdit(contextMenuTargetAlbum)} + onClick={() => contextMenuTargetAlbum && handleEdit(contextMenuTargetAlbum)} /> - openShareModal()} /> + openShareModal()} /> {/if} - handleDownloadAlbum()} /> + handleDownloadAlbum()} /> {#if showFullContextMenu} - setAlbumToDelete()} /> + setAlbumToDelete()} /> {/if} diff --git a/web/src/lib/components/album-page/share-info-modal.svelte b/web/src/lib/components/album-page/share-info-modal.svelte index 82403efcbe..3bda154249 100644 --- a/web/src/lib/components/album-page/share-info-modal.svelte +++ b/web/src/lib/components/album-page/share-info-modal.svelte @@ -109,14 +109,14 @@ {#if isOwned} {#if role === AlbumUserRole.Viewer} - handleSetReadonly(user, AlbumUserRole.Editor)} text={$t('allow_edits')} /> + handleSetReadonly(user, AlbumUserRole.Editor)} text={$t('allow_edits')} /> {:else} handleSetReadonly(user, AlbumUserRole.Viewer)} + onClick={() => handleSetReadonly(user, AlbumUserRole.Viewer)} text={$t('disallow_edits')} /> {/if} - handleMenuRemove(user)} text={$t('remove')} /> + handleMenuRemove(user)} text={$t('remove')} /> {:else if user.id == currentUser?.id} - {/if} - {#if (index != reactions.length - 1 && !shouldGroup(reactions[index].createdAt, reactions[index + 1].createdAt)) || index === reactions.length - 1} @@ -240,27 +231,23 @@ {/if} {#if reaction.user.id === user.id || albumOwnerId === user.id} -
- + (showDeleteReaction[index] ? '' : showOptionsMenu(index))} - /> + > + handleDeleteReaction(reaction, index)} + /> +
{/if} -
- {#if showDeleteReaction[index]} - - {/if} -
{#if (index != reactions.length - 1 && isTenMinutesApart(reactions[index].createdAt, reactions[index + 1].createdAt)) || index === reactions.length - 1}
{#if showSlideshow} - onMenuClick('playSlideShow')} text={$t('slideshow')} /> + onMenuClick('playSlideShow')} text={$t('slideshow')} /> {/if} {#if showDownloadButton} - onMenuClick('download')} text={$t('download')} /> + onMenuClick('download')} text={$t('download')} /> {/if} {#if asset.isTrashed} - onMenuClick('restoreAsset')} text={$t('restore')} /> + onMenuClick('restoreAsset')} text={$t('restore')} /> {:else} - onMenuClick('addToAlbum')} text={$t('add_to_album')} /> + onMenuClick('addToAlbum')} text={$t('add_to_album')} /> onMenuClick('addToSharedAlbum')} + onClick={() => onMenuClick('addToSharedAlbum')} text={$t('add_to_shared_album')} /> {/if} {#if isOwner} {#if hasStackChildren} - onMenuClick('unstack')} text={$t('unstack')} /> + onMenuClick('unstack')} text={$t('unstack')} /> {/if} {#if album} onMenuClick('setAsAlbumCover')} + onClick={() => onMenuClick('setAsAlbumCover')} /> {/if} {#if asset.type === AssetTypeEnum.Image} onMenuClick('asProfileImage')} + onClick={() => onMenuClick('asProfileImage')} text={$t('set_as_profile_picture')} /> {/if} onMenuClick('toggleArchive')} + onClick={() => onMenuClick('toggleArchive')} icon={asset.isArchived ? mdiArchiveArrowUpOutline : mdiArchiveArrowDownOutline} text={asset.isArchived ? $t('unarchive') : $t('to_archive')} /> openFileUploadDialog({ multiple: false, assetId: asset.id })} + onClick={() => openFileUploadDialog({ multiple: false, assetId: asset.id })} text={$t('replace_with_upload')} />
onJobClick(AssetJobName.RefreshMetadata)} + onClick={() => onJobClick(AssetJobName.RefreshMetadata)} text={getAssetJobName(AssetJobName.RefreshMetadata)} /> onJobClick(AssetJobName.RegenerateThumbnail)} + onClick={() => onJobClick(AssetJobName.RegenerateThumbnail)} text={getAssetJobName(AssetJobName.RegenerateThumbnail)} /> {#if asset.type === AssetTypeEnum.Video} onJobClick(AssetJobName.TranscodeVideo)} + onClick={() => onJobClick(AssetJobName.TranscodeVideo)} text={getAssetJobName(AssetJobName.TranscodeVideo)} /> {/if} diff --git a/web/src/lib/components/faces-page/people-card.svelte b/web/src/lib/components/faces-page/people-card.svelte index ef11d0236e..b532899353 100644 --- a/web/src/lib/components/faces-page/people-card.svelte +++ b/web/src/lib/components/faces-page/people-card.svelte @@ -75,15 +75,15 @@ icon={mdiDotsVertical} title={$t('show_person_options')} > - onMenuClick('hide-person')} icon={mdiEyeOffOutline} text={$t('hide_person')} /> - onMenuClick('change-name')} icon={mdiAccountEditOutline} text={$t('change_name')} /> + onMenuClick('hide-person')} icon={mdiEyeOffOutline} text={$t('hide_person')} /> + onMenuClick('change-name')} icon={mdiAccountEditOutline} text={$t('change_name')} /> onMenuClick('set-birth-date')} + onClick={() => onMenuClick('set-birth-date')} icon={mdiCalendarEditOutline} text={$t('set_date_of_birth')} /> onMenuClick('merge-people')} + onClick={() => onMenuClick('merge-people')} icon={mdiAccountMultipleCheckOutline} text={$t('merge_people')} /> diff --git a/web/src/lib/components/photos-page/actions/add-to-album.svelte b/web/src/lib/components/photos-page/actions/add-to-album.svelte index 78b2969cef..8e8f247354 100644 --- a/web/src/lib/components/photos-page/actions/add-to-album.svelte +++ b/web/src/lib/components/photos-page/actions/add-to-album.svelte @@ -33,7 +33,7 @@ (showAlbumPicker = true)} + onClick={() => (showAlbumPicker = true)} text={shared ? $t('add_to_shared_album') : $t('add_to_album')} icon={shared ? mdiShareVariantOutline : mdiImageAlbum} /> diff --git a/web/src/lib/components/photos-page/actions/archive-action.svelte b/web/src/lib/components/photos-page/actions/archive-action.svelte index 59b0916064..792b80b702 100644 --- a/web/src/lib/components/photos-page/actions/archive-action.svelte +++ b/web/src/lib/components/photos-page/actions/archive-action.svelte @@ -33,7 +33,7 @@ {#if menuItem} - + {/if} {#if !menuItem} diff --git a/web/src/lib/components/photos-page/actions/asset-job-actions.svelte b/web/src/lib/components/photos-page/actions/asset-job-actions.svelte index 9294bd34d4..4460548c38 100644 --- a/web/src/lib/components/photos-page/actions/asset-job-actions.svelte +++ b/web/src/lib/components/photos-page/actions/asset-job-actions.svelte @@ -34,6 +34,6 @@ {#each jobs as job} {#if isAllVideos || job !== AssetJobName.TranscodeVideo} - handleRunJob(job)} /> + handleRunJob(job)} /> {/if} {/each} diff --git a/web/src/lib/components/photos-page/actions/change-date-action.svelte b/web/src/lib/components/photos-page/actions/change-date-action.svelte index ded3e663cd..6ee775fa69 100644 --- a/web/src/lib/components/photos-page/actions/change-date-action.svelte +++ b/web/src/lib/components/photos-page/actions/change-date-action.svelte @@ -28,7 +28,7 @@ {#if menuItem} - (isShowChangeDate = true)} /> + (isShowChangeDate = true)} /> {/if} {#if isShowChangeDate} (isShowChangeLocation = true)} + onClick={() => (isShowChangeLocation = true)} /> {/if} {#if isShowChangeLocation} diff --git a/web/src/lib/components/photos-page/actions/delete-assets.svelte b/web/src/lib/components/photos-page/actions/delete-assets.svelte index 3e8f9dd8fe..5c79e7b221 100644 --- a/web/src/lib/components/photos-page/actions/delete-assets.svelte +++ b/web/src/lib/components/photos-page/actions/delete-assets.svelte @@ -39,7 +39,7 @@ {#if menuItem} - + {:else if loading} {:else} diff --git a/web/src/lib/components/photos-page/actions/download-action.svelte b/web/src/lib/components/photos-page/actions/download-action.svelte index 654fdcb400..073d20901c 100644 --- a/web/src/lib/components/photos-page/actions/download-action.svelte +++ b/web/src/lib/components/photos-page/actions/download-action.svelte @@ -27,7 +27,7 @@ {#if menuItem} - + {:else} {/if} diff --git a/web/src/lib/components/photos-page/actions/favorite-action.svelte b/web/src/lib/components/photos-page/actions/favorite-action.svelte index 3e5583bf58..503f0ba156 100644 --- a/web/src/lib/components/photos-page/actions/favorite-action.svelte +++ b/web/src/lib/components/photos-page/actions/favorite-action.svelte @@ -58,7 +58,7 @@ {#if menuItem} - + {/if} {#if !menuItem} diff --git a/web/src/lib/components/photos-page/actions/remove-from-album.svelte b/web/src/lib/components/photos-page/actions/remove-from-album.svelte index 0af95a218f..90bdb39b71 100644 --- a/web/src/lib/components/photos-page/actions/remove-from-album.svelte +++ b/web/src/lib/components/photos-page/actions/remove-from-album.svelte @@ -57,7 +57,7 @@ {#if menuItem} - + {:else} {/if} diff --git a/web/src/lib/components/photos-page/actions/stack-action.svelte b/web/src/lib/components/photos-page/actions/stack-action.svelte index 465c695a48..5e425c4f00 100644 --- a/web/src/lib/components/photos-page/actions/stack-action.svelte +++ b/web/src/lib/components/photos-page/actions/stack-action.svelte @@ -40,7 +40,7 @@ {#if unstack} - + {:else} - + {/if} diff --git a/web/src/lib/components/shared-components/context-menu/menu-option.svelte b/web/src/lib/components/shared-components/context-menu/menu-option.svelte index ce43b10821..e7ff4c626e 100644 --- a/web/src/lib/components/shared-components/context-menu/menu-option.svelte +++ b/web/src/lib/components/shared-components/context-menu/menu-option.svelte @@ -1,24 +1,22 @@ @@ -29,27 +27,20 @@ on:click={handleClick} on:mouseover={() => ($selectedIdStore = id)} on:mouseleave={() => ($selectedIdStore = undefined)} - class="w-full p-4 text-left text-sm font-medium text-immich-fg focus:outline-none focus:ring-2 focus:ring-inset dark:text-immich-dark-bg cursor-pointer border-gray-200" - class:bg-slate-300={isActive} - class:bg-slate-100={!isActive} + class="w-full p-4 text-left text-sm font-medium {textColor} focus:outline-none focus:ring-2 focus:ring-inset cursor-pointer border-gray-200 flex gap-2 items-center {isActive + ? activeColor + : 'bg-slate-100'}" role="menuitem" > - {#if text} - {#if icon} -

- - {text} -

- {:else} - {text} - {/if} - {:else} - + {#if icon} + {/if} - - -

- {subtitle} -

-
+
+ {text} + {#if subtitle} +

+ {subtitle} +

+ {/if} +
diff --git a/web/src/routes/(user)/albums/[albumId=id]/[[photos=photos]]/[[assetId=id]]/+page.svelte b/web/src/routes/(user)/albums/[albumId=id]/[[photos=photos]]/[[assetId=id]]/+page.svelte index 7d0dbf0750..e73a0584a6 100644 --- a/web/src/routes/(user)/albums/[albumId=id]/[[photos=photos]]/[[assetId=id]]/+page.svelte +++ b/web/src/routes/(user)/albums/[albumId=id]/[[photos=photos]]/[[assetId=id]]/+page.svelte @@ -426,7 +426,7 @@ updateThumbnailUsingCurrentSelection()} + onClick={() => updateThumbnailUsingCurrentSelection()} /> {/if} assetStore.triggerUpdate()} /> @@ -468,14 +468,10 @@ (viewMode = ViewMode.SELECT_THUMBNAIL)} + onClick={() => (viewMode = ViewMode.SELECT_THUMBNAIL)} /> - (viewMode = ViewMode.OPTIONS)} - /> - handleRemoveAlbum()} /> + (viewMode = ViewMode.OPTIONS)} /> + handleRemoveAlbum()} />
{/if} {/if} diff --git a/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.svelte b/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.svelte index 3238d2ddc7..d239da64c3 100644 --- a/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.svelte +++ b/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.svelte @@ -390,7 +390,7 @@ @@ -406,22 +406,22 @@ (viewMode = ViewMode.SELECT_PERSON)} + onClick={() => (viewMode = ViewMode.SELECT_PERSON)} /> toggleHidePerson()} + onClick={() => toggleHidePerson()} /> (viewMode = ViewMode.BIRTH_DATE)} + onClick={() => (viewMode = ViewMode.BIRTH_DATE)} /> (viewMode = ViewMode.MERGE_PEOPLE)} + onClick={() => (viewMode = ViewMode.MERGE_PEOPLE)} /> diff --git a/web/src/routes/admin/library-management/+page.svelte b/web/src/routes/admin/library-management/+page.svelte index adb77a1e88..60b33e48d9 100644 --- a/web/src/routes/admin/library-management/+page.svelte +++ b/web/src/routes/admin/library-management/+page.svelte @@ -380,29 +380,32 @@ icon={mdiDotsVertical} title={$t('library_options')} > - onRenameClicked(index)} text={$t('rename')} /> - onEditImportPathClicked(index)} text={$t('edit_import_paths')} /> - onScanSettingClicked(index)} text={$t('scan_settings')} /> + onRenameClicked(index)} text={$t('rename')} /> + onEditImportPathClicked(index)} text={$t('edit_import_paths')} /> + onScanSettingClicked(index)} text={$t('scan_settings')} />
- onScanNewLibraryClicked(library)} text={$t('scan_new_library_files')} /> + onScanNewLibraryClicked(library)} text={$t('scan_new_library_files')} /> onScanAllLibraryFilesClicked(library)} + onClick={() => onScanAllLibraryFilesClicked(library)} text={$t('scan_all_library_files')} subtitle={$t('only_refreshes_modified_files')} /> onForceScanAllLibraryFilesClicked(library)} + onClick={() => onForceScanAllLibraryFilesClicked(library)} text={$t('force_re-scan_library_files')} subtitle={$t('refreshes_every_file')} />
onRemoveOfflineFilesClicked(library)} + onClick={() => onRemoveOfflineFilesClicked(library)} text={$t('remove_offline_files')} /> - onDeleteLibraryClicked(library, index)}> -

{$t('delete_library')}

-
+ onDeleteLibraryClicked(library, index)} + />