From 024bde9a499b9d2b6c91333c9e778dc8c165797d Mon Sep 17 00:00:00 2001 From: Toni <51962051+EinToni@users.noreply.github.com> Date: Wed, 27 Nov 2024 22:05:23 +0100 Subject: [PATCH] Moved the selectable button into its own component. * While adding in that no highligh of the button appears when it is empty the code in the duplicate-asset got quite crowded. I therefore moved the selectable button that holds the metadata into its own component. --- .../duplicate-asset-selection.svelte | 48 ++++++++++++ .../duplicates/duplicate-asset.svelte | 75 +++++++------------ 2 files changed, 77 insertions(+), 46 deletions(-) create mode 100644 web/src/lib/components/utilities-page/duplicates/duplicate-asset-selection.svelte diff --git a/web/src/lib/components/utilities-page/duplicates/duplicate-asset-selection.svelte b/web/src/lib/components/utilities-page/duplicates/duplicate-asset-selection.svelte new file mode 100644 index 0000000000..348f0a8e53 --- /dev/null +++ b/web/src/lib/components/utilities-page/duplicates/duplicate-asset-selection.svelte @@ -0,0 +1,48 @@ + + + + {@render children?.()} + diff --git a/web/src/lib/components/utilities-page/duplicates/duplicate-asset.svelte b/web/src/lib/components/utilities-page/duplicates/duplicate-asset.svelte index ab3124a167..6b24e3fb11 100644 --- a/web/src/lib/components/utilities-page/duplicates/duplicate-asset.svelte +++ b/web/src/lib/components/utilities-page/duplicates/duplicate-asset.svelte @@ -11,6 +11,7 @@ import { locale } from '$lib/stores/preferences.store'; import type { SelectedSyncData } from '$lib/components/utilities-page/duplicates/duplicates-compare-control.svelte'; import { DateTime } from 'luxon'; + import DuplicateAssetSelection from '$lib/components/utilities-page/duplicates/duplicate-asset-selection.svelte'; interface Props { asset: AssetResponseDto; @@ -56,31 +57,16 @@ selectedSyncData.isFavorite = selectedSyncData.isFavorite || asset.isFavorite; selectedSyncData.isArchived = selectedSyncData.isArchived || asset.isArchived; - let descriptionItem = $state(); - let locationItem = $state(); + let descriptionItem = $state(); + let locationItem = $state(); let albums: AlbumResponseDto[] = $state([]); onMount(async () => { - setDescriptionHeight(descriptionItem.getBoundingClientRect().height); - setLocationHeight(locationItem.getBoundingClientRect().height); + setDescriptionHeight(descriptionItem.getHeight()); + setLocationHeight(locationItem.getHeight()); albums = await getAllAlbums({ assetId: asset.id }); setAlbums(albums); }); - const getBackgroundColor = (isSelected: boolean, syncDataExist: boolean, syncIsAssetData: boolean) => { - let color = 'rounded-xl dark:hover:bg-gray-300'; - color += isSelected ? ' hover:bg-gray-300' : ' hover:bg-gray-500'; - if (isSelected) { - if (syncDataExist && !syncIsAssetData) { - color += ' bg-red-300/90'; - } - } else { - if (syncIsAssetData) { - color += ' bg-green-400/90'; - } - } - return color; - }; - let timeZone = $derived(asset.exifInfo?.timeZone); let dateTime = $derived( timeZone && asset.exifInfo?.dateTimeOriginal @@ -217,11 +203,12 @@ {$t('in_albums', { values: { count: displayedAlbums.length } })} {/if} - onSelectDate(displayedDateTime)} + onSelectDate(displayedDateTime)} > {displayedDateTime.toLocaleString( { @@ -240,18 +227,16 @@ }, { locale: $locale }, )} - - + onSelectLocation(displayedLocation)} + {isSelected} + slotHeight={locationHeight} + selectedData={selectedSyncData?.location} + displayedData={displayedLocation?.city && displayedLocation?.state && displayedLocation?.country} + isSelectedEqualOriginal={selectedSyncData?.location?.latitude === location.latitude && + selectedSyncData?.location?.longitude === location.longitude} + onClick={() => onSelectLocation(displayedLocation)} > {#if displayedLocation?.city} @@ -264,19 +249,17 @@ {#if displayedLocation?.country} {displayedLocation.country} {/if} - - + onSelectDescription(displayedDescription)} + {isSelected} + slotHeight={descriptionHeight} + selectedData={selectedSyncData.description} + displayedData={displayedDescription} + isSelectedEqualOriginal={selectedSyncData?.description === description} + onClick={() => onSelectDescription(displayedDescription)} > {displayedDescription} - +
{displayedLocation.country}