Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.
TypeScript albumsexif-extractiongeocodinglive-photomotion-photophoto-galleryphoto-sharingwebgl-viewer
style(share): redesign share modal ui and layout
Timothy Yindf0125b7f474
diff --git a/app/components/photo/ShareModal.vue b/app/components/photo/ShareModal.vueindex ba0af1c6..353a965b 100644--- a/app/components/photo/ShareModal.vue+++ b/app/components/photo/ShareModal.vue@@ -1,6 +1,4 @@<script lang="ts" setup>-import { motion, AnimatePresence } from 'motion-v'-interface Props {isOpen: booleanphoto: Photo@@ -11,6 +9,13 @@ const emit = defineEmits<{close: []}>()+const linkCopied = ref(false)+const copyingLink = ref(false)+const downloadingOriginal = ref(false)+const downloadingPreview = ref(false)+let copiedTimer: ReturnType<typeof setTimeout> | undefined+const previewVersion = ref(0)+const toast = useToast()const { gtag } = useGtag()const { returnRoute } = storeToRefs(useViewerState())@@ -43,6 +48,9 @@ const ogImageUrl = computed(() => `/_og/r/${props.photo.id}.png`)// Reset loading state when photo changes or modal opensconst resetLoadingState = () => {+ linkCopied.value = false+ clearTimeout(copiedTimer)+ previewVersion.value++ogImageLoading.value = trueogImageError.value = false@@ -71,6 +79,7 @@ watch(resetLoadingState()}},+ { immediate: true },)// Handle image load events@@ -94,6 +103,7 @@ const handleOgImageError = () => {// Cleanup on unmountonUnmounted(() => {+ clearTimeout(copiedTimer)if (loadingTimer.value) {clearTimeout(loadingTimer.value)}@@ -188,8 +198,15 @@ const shareToLinkedIn = () => {// Copy functionsconst copyLink = async () => {+ if (copyingLink.value) return+ copyingLink.value = truetry {await navigator.clipboard.writeText(shareTextAndUrl.value)+ linkCopied.value = true+ clearTimeout(copiedTimer)+ copiedTimer = setTimeout(() => {+ linkCopied.value = false+ }, 2500)toast.add({title: $t('ui.action.share.success.linkCopied'),color: 'success',@@ -204,6 +221,8 @@ const copyLink = async () => {icon: 'tabler:x',duration: 3000,})+ } finally {+ copyingLink.value = false}}@@ -230,8 +249,11 @@ const nativeShare = async () => {// Download OG Imageconst downloadOgImage = async () => {+ if (downloadingPreview.value) return+ downloadingPreview.value = truetry {const response = await fetch(ogImageUrl.value)+ if (!response.ok) throw new Error(`HTTP ${response.status}`)const blob = await response.blob()const url = window.URL.createObjectURL(blob)const link = document.createElement('a')@@ -256,12 +278,17 @@ const downloadOgImage = async () => {icon: 'tabler:x',duration: 3000,})+ } finally {+ downloadingPreview.value = false}}const downloadOriginalImage = async () => {+ if (downloadingOriginal.value || !props.photo.originalUrl) return+ downloadingOriginal.value = truetry {const response = await fetch(props.photo.originalUrl!)+ if (!response.ok) throw new Error(`HTTP ${response.status}`)const blob = await response.blob()const url = window.URL.createObjectURL(blob)const link = document.createElement('a')@@ -278,7 +305,10 @@ const downloadOriginalImage = async () => {'image/bmp': 'bmp','image/tiff': 'tiff',}- const extension = extensionByMime[mimeType] || props.photo.originalUrl!.split('.').pop() || 'jpg'+ const extension =+ extensionByMime[mimeType] ||+ props.photo.originalUrl!.split('.').pop() ||+ 'jpg'link.download = `${props.photo.title || 'photo'}.${extension}`document.body.appendChild(link)link.click()@@ -306,6 +336,8 @@ const downloadOriginalImage = async () => {icon: 'tabler:x',duration: 3000,})+ } finally {+ downloadingOriginal.value = false}}@@ -353,83 +385,127 @@ const socialPlatforms = computed(() => [action: shareToLinkedIn,},])--// Close modal when clicking outside-const handleBackdropClick = (event: MouseEvent) => {- if (event.target === event.currentTarget) {- emit('close')- }-}--// Keyboard shortcuts-defineShortcuts({- escape: () => {- emit('close')- },-})</script><template>- <Teleport to="body">- <AnimatePresence>- <motion.div- v-if="isOpen"- :initial="{ opacity: 0 }"- :animate="{ opacity: 1 }"- :exit="{ opacity: 0 }"- :transition="{ duration: 0.2 }"- class="fixed inset-0 z-60 flex items-center justify-center bg-black/50 backdrop-blur-sm"- @click="handleBackdropClick"- >- <motion.div- :initial="{ opacity: 0, scale: 0.95, y: 20 }"- :animate="{ opacity: 1, scale: 1, y: 0 }"- :exit="{ opacity: 0, scale: 0.95, y: 20 }"- :transition="{- type: 'spring',- duration: 0.3,- bounce: 0.1,- }"- class="relative mx-4 w-full max-w-md overflow-hidden rounded-2xl border border-white/10 bg-white/90 shadow-2xl backdrop-blur-2xl dark:bg-neutral-900/90"- @click.stop- >- <!-- Header -->+ <UModal+ :open="isOpen"+ :content="{+ onEscapeKeyDown: (event: KeyboardEvent) => event.stopPropagation(),+ }"+ :title="$t('ui.action.share.title')"+ :close="{ 'aria-label': $t('ui.action.share.actions.close') }"+ :description="photo.title || $t('ui.action.share.fallback.photoTitle')"+ :ui="{+ overlay: 'z-[60] bg-black/50 backdrop-blur-sm',+ content:+ 'z-[60] max-w-md divide-y-0 rounded-2xl bg-white/95 dark:bg-neutral-900/95 ring-black/10 dark:ring-white/10 shadow-xl',+ header: 'min-h-0 px-4 pt-4 pb-2 sm:px-4 sm:pt-4 sm:pb-2 border-0',+ body: 'px-4 pt-2 pb-4 sm:px-4 sm:pt-2 sm:pb-4 overflow-y-auto',+ wrapper: 'min-w-0 flex-1',+ close: 'static shrink-0',+ description: 'sr-only',+ }"+ @update:open="+ (open) => {+ if (!open) emit('close')+ }+ "+ >+ <template #body>+ <div class="space-y-4">+ <section :aria-label="$t('ui.action.share.ogImage.title')"><div- class="flex items-center justify-between border-b border-white/10 p-4"+ class="relative aspect-2/1 overflow-hidden rounded-xl bg-neutral-100 dark:bg-neutral-800">- <div class="flex items-center gap-2">+ <img+ :key="`${photo.id}-${previewVersion}`"+ :src="ogImageUrl"+ :alt="$t('ui.action.share.ogImage.alt')"+ class="size-full object-cover"+ :class="{ 'opacity-0': ogImageLoading || ogImageError }"+ @load="handleOgImageLoad"+ @error="handleOgImageError"+ />+ <div+ v-if="ogImageLoading || ogImageError"+ class="absolute inset-0 flex flex-col items-center justify-center gap-2 text-neutral-500 dark:text-neutral-400"+ role="status"+ ><Icon- name="tabler:share-3"- class="size-5 text-neutral-700 dark:text-neutral-300"+ :name="ogImageError ? 'tabler:photo-off' : 'tabler:loader-2'"+ class="size-6"+ :class="{ 'animate-spin': !ogImageError }"/>- <h3- class="text-lg font-semibold text-neutral-900 dark:text-white"+ <span class="text-sm">{{+ $t(+ ogImageError+ ? 'ui.action.share.ogImage.loadError'+ : 'ui.action.share.ogImage.loading',+ )+ }}</span>+ <UButton+ v-if="ogImageError"+ size="sm"+ color="neutral"+ variant="ghost"+ icon="tabler:refresh"+ @click="resetLoadingState">- {{ $t('ui.action.share.title') }}- </h3>+ {{ $t('ui.action.share.actions.retry') }}+ </UButton></div>- <UButton- size="sm"- variant="ghost"- color="neutral"- icon="tabler:x"- @click="emit('close')"- /></div>+ </section>- <!-- Content -->+ <section class="space-y-3">+ <label+ for="photo-share-url"+ class="block text-xs font-medium text-neutral-500 dark:text-neutral-400"+ >{{ $t('ui.action.share.actions.shareUrl') }}</label+ ><div- v-if="photo"- class="p-4"+ class="overflow-hidden rounded-xl border border-black/10 bg-neutral-100/70 dark:border-white/10 dark:bg-neutral-800/50">- <!-- Native Share and Original Image Download -->- <div class="mb-4 flex items-center gap-2">+ <div+ class="flex items-center gap-2 border-b border-black/5 bg-white/80 p-2 dark:border-white/10 dark:bg-neutral-800"+ >+ <input+ id="photo-share-url"+ :value="shareUrl"+ readonly+ class="min-w-0 flex-1 rounded px-1 py-1 text-sm text-neutral-600 outline-none focus-visible:ring-2 focus-visible:ring-primary dark:text-neutral-300"+ />+ <UButton+ size="sm"+ color="neutral"+ variant="soft"+ class="shrink-0"+ :icon="linkCopied ? 'tabler:check' : 'tabler:copy'"+ :loading="copyingLink"+ @click="copyLink"+ >+ {{+ $t(+ linkCopied+ ? 'ui.action.share.actions.copied'+ : 'ui.action.share.actions.copyLink',+ )+ }}+ </UButton>+ </div>+ <div+ class="grid p-1.5 [&>button+button]:relative [&>button+button]:before:absolute [&>button+button]:before:inset-y-2 [&>button+button]:before:left-0 [&>button+button]:before:w-px [&>button+button]:before:bg-black/8 dark:[&>button+button]:before:bg-white/10"+ :class="canNativeShare ? 'grid-cols-3' : 'grid-cols-2'"+ ><UButtonv-if="canNativeShare"block- size="lg"- color="info"- variant="soft"+ size="sm"+ class="min-w-0 justify-center gap-1 px-0 py-2 text-[11px] [&>span]:whitespace-normal [&>span]:text-center"+ :ui="{ leadingIcon: 'size-3.5' }"+ color="neutral"+ variant="ghost"icon="tabler:share-2"@click="nativeShare">@@ -437,142 +513,66 @@ defineShortcuts({</UButton><UButtonblock- size="lg"- color="info"- variant="soft"+ size="sm"+ class="min-w-0 justify-center gap-1 px-0 py-2 text-[11px] [&>span]:whitespace-normal [&>span]:text-center"+ :ui="{ leadingIcon: 'size-3.5' }"+ color="neutral"+ variant="ghost"icon="tabler:download"+ :loading="downloadingOriginal"+ :disabled="!photo.originalUrl"@click="downloadOriginalImage">{{ $t('ui.action.share.actions.downloadOriginalImage') }}</UButton>+ <UButton+ block+ size="sm"+ class="min-w-0 justify-center gap-1 px-0 py-2 text-[11px] [&>span]:whitespace-normal [&>span]:text-center"+ :ui="{ leadingIcon: 'size-3.5' }"+ color="neutral"+ variant="ghost"+ icon="tabler:photo-down"+ :loading="downloadingPreview"+ :disabled="ogImageLoading || ogImageError"+ @click="downloadOgImage"+ >+ {{ $t('ui.action.share.actions.downloadOgImage') }}+ </UButton></div>+ </div>+ </section>- <div class="space-y-4">- <!-- Share URL Display -->- <div- class="rounded-lg border border-neutral-200/50 bg-neutral-50/50 p-3 dark:border-neutral-700/50 dark:bg-neutral-800/50"- >- <label- class="mb-1 block text-xs font-medium text-neutral-600 dark:text-neutral-400"- >- {{ $t('ui.action.share.actions.shareUrl') }}- </label>- <div class="flex items-center gap-2">- <input- :value="shareUrl"- readonly- class="flex-1 truncate bg-transparent text-sm text-neutral-800 dark:text-neutral-200 resize-none"- />- <UButton- size="xs"- variant="ghost"- color="neutral"- icon="tabler:copy"- @click="copyLink"- />- </div>- </div>-- <!-- OG Image Preview -->- <div- class="rounded-lg border border-neutral-200/50 bg-neutral-50/50 p-3 dark:border-neutral-700/50 dark:bg-neutral-800/50"+ <section+ class="border-t border-black/5 pt-4 dark:border-white/10"+ :aria-label="$t('ui.action.share.actions.otherPlatforms')"+ >+ <p+ class="mb-3 text-xs font-medium text-neutral-500 dark:text-neutral-400"+ >+ {{ $t('ui.action.share.actions.otherPlatforms') }}+ </p>+ <div class="grid grid-cols-3 gap-2.5">+ <button+ v-for="platform in socialPlatforms"+ :key="platform.name"+ type="button"+ class="flex min-h-18 cursor-pointer flex-col items-center justify-center gap-2 rounded-xl border border-neutral-200/70 bg-white px-2 py-3 transition-colors hover:border-neutral-300 hover:bg-neutral-50 focus-visible:outline-2 focus-visible:outline-primary dark:border-neutral-700/70 dark:bg-neutral-800/70 dark:hover:border-neutral-600 dark:hover:bg-neutral-800"+ @click="platform.action"+ >+ <Icon+ :name="platform.icon"+ class="size-5"+ :class="platform.color"+ />+ <span+ class="text-xs font-medium text-neutral-600 dark:text-neutral-300"+ >{{ platform.name }}</span>- <div class="flex items-center justify-between mb-2">- <label- class="block text-xs font-medium text-neutral-600 dark:text-neutral-400"- >- {{ $t('ui.action.share.ogImage.title') }}- </label>- <UButton- size="xs"- variant="ghost"- color="neutral"- icon="tabler:download"- @click="downloadOgImage"- >- {{ $t('ui.action.share.actions.downloadOgImage') }}- </UButton>- </div>- <div- class="relative rounded-md bg-neutral-100/50 dark:bg-neutral-700/50 overflow-hidden"- >- <!-- Loading indicator -->- <div- v-if="ogImageLoading"- class="flex items-center justify-center bg-neutral-100/50 dark:bg-neutral-700/50 aspect-2/1"- >- <div class="flex flex-col items-center gap-2">- <Icon- name="tabler:loader-2"- class="size-6 text-neutral-500 animate-spin"- />- <span- class="text-xs text-neutral-500 dark:text-neutral-400"- >- {{ $t('ui.action.share.ogImage.loading') }}- </span>- </div>- </div>-- <!-- Error state -->- <div- v-else-if="ogImageError"- class="flex items-center justify-center bg-neutral-100/50 dark:bg-neutral-700/50 aspect-2/1"- >- <div class="flex flex-col items-center gap-2">- <Icon- name="tabler:photo-off"- class="size-6 text-neutral-400"- />- <span- class="text-xs text-neutral-500 dark:text-neutral-400"- >- {{ $t('ui.action.share.ogImage.loadError') }}- </span>- </div>- </div>-- <!-- OG Image -->- <img- v-show="!ogImageLoading && !ogImageError"- :key="`og-image-${props.photo.id}-${Date.now()}`"- :src="ogImageUrl"- :alt="$t('ui.action.share.ogImage.alt')"- class="w-full h-auto aspect-2/1 object-cover rounded"- loading="eager"- @load="handleOgImageLoad"- @error="handleOgImageError"- />- </div>- </div>-- <!-- Social Platforms Grid -->- <div class="grid grid-cols-3 gap-3">- <button- v-for="platform in socialPlatforms"- :key="platform.name"- type="button"- class="cursor-pointer flex flex-col items-center justify-center gap-2 rounded-xl border border-neutral-200/50 bg-white/50 p-4 transition-all hover:scale-105 hover:border-neutral-300/50 hover:bg-white/70 dark:border-neutral-700/50 dark:bg-neutral-800/50 dark:hover:border-neutral-600/50 dark:hover:bg-neutral-700/50"- @click="platform.action"- >- <Icon- :name="platform.icon"- class="size-6"- :class="platform.color"- />- <span- class="text-xs font-medium text-neutral-700 dark:text-neutral-300"- >- {{ platform.name }}- </span>- </button>- </div>- </div>+ </button></div>- </motion.div>- </motion.div>- </AnimatePresence>- </Teleport>+ </section>+ </div>+ </template>+ </UModal></template>--<style scoped></style>diff --git a/app/components/photo/Viewer.vue b/app/components/photo/Viewer.vueindex a8710b14..def8f074 100644--- a/app/components/photo/Viewer.vue+++ b/app/components/photo/Viewer.vue@@ -511,6 +511,10 @@ watch(defineShortcuts({escape: () => {+ if (showShareModal.value) {+ showShareModal.value = false+ return+ }emit('close')},})diff --git a/i18n/locales/en.json b/i18n/locales/en.jsonindex 052af166..231b21b7 100644--- a/i18n/locales/en.json+++ b/i18n/locales/en.json@@ -87,11 +87,15 @@"actions": {"nativeShare": "Use System Share","copyLink": "Copy Link",+ "copied": "Copied",+ "close": "Close",+ "otherPlatforms": "Other sharing options",+ "retry": "Retry","copyImage": "Copy Image","downloadImage": "Download Original","generateShareImage": "Generate Share Image","shareUrl": "Share URL",- "downloadOgImage": "Download Preview",+ "downloadOgImage": "Download Share Card","downloadOriginal": "Download Original","downloadOriginalImage": "Download Original Image"},diff --git a/i18n/locales/ja.json b/i18n/locales/ja.jsonindex c8606766..3f851f4d 100644--- a/i18n/locales/ja.json+++ b/i18n/locales/ja.json@@ -87,11 +87,15 @@"actions": {"nativeShare": "システム共有を使用","copyLink": "リンクをコピー",+ "copied": "コピー済み",+ "close": "閉じる",+ "otherPlatforms": "その他の共有先",+ "retry": "再試行","copyImage": "画像をコピー","downloadImage": "オリジナルをダウンロード","generateShareImage": "共有画像を生成","shareUrl": "共有URL",- "downloadOgImage": "プレビューをダウンロード",+ "downloadOgImage": "共有カードをダウンロード","downloadOriginal": "オリジナルをダウンロード","downloadOriginalImage": "オリジナル画像をダウンロード"},diff --git a/i18n/locales/ru.json b/i18n/locales/ru.jsonindex d1e048f3..4c17a18e 100644--- a/i18n/locales/ru.json+++ b/i18n/locales/ru.json@@ -87,11 +87,15 @@"actions": {"nativeShare": "Поделиться через систему","copyLink": "Копировать ссылку",+ "copied": "Скопировано",+ "close": "Закрыть",+ "otherPlatforms": "Другие способы поделиться",+ "retry": "Повторить","copyImage": "Копировать изображение","downloadImage": "Скачать оригинал","generateShareImage": "Создать изображение для публикации","shareUrl": "Поделиться ссылкой",- "downloadOgImage": "Скачать превью",+ "downloadOgImage": "Скачать карточку","downloadOriginal": "Скачать оригинал","downloadOriginalImage": "Скачать исходное изображение"},diff --git a/i18n/locales/zh-Hans.json b/i18n/locales/zh-Hans.jsonindex a34d2de8..38e546c2 100644--- a/i18n/locales/zh-Hans.json+++ b/i18n/locales/zh-Hans.json@@ -102,11 +102,15 @@"actions": {"nativeShare": "使用系统分享","copyLink": "复制链接",+ "copied": "已复制",+ "close": "关闭",+ "otherPlatforms": "分享到其他平台",+ "retry": "重试","copyImage": "复制图片","downloadImage": "下载原图","generateShareImage": "生成分享图片","shareUrl": "分享链接",- "downloadOgImage": "下载预览图",+ "downloadOgImage": "下载分享卡片","downloadOriginal": "下载原图","downloadOriginalImage": "下载原图"},diff --git a/i18n/locales/zh-Hant-HK.json b/i18n/locales/zh-Hant-HK.jsonindex 5387912f..1360d937 100644--- a/i18n/locales/zh-Hant-HK.json+++ b/i18n/locales/zh-Hant-HK.json@@ -102,11 +102,15 @@"actions": {"nativeShare": "使用系統分享","copyLink": "複製連結",+ "copied": "已複製",+ "close": "關閉",+ "otherPlatforms": "分享到其他平台",+ "retry": "重試","copyImage": "複製圖片","downloadImage": "下載原圖","generateShareImage": "產生分享圖片","shareUrl": "分享連結",- "downloadOgImage": "下載預覽圖",+ "downloadOgImage": "下載分享卡片","downloadOriginal": "下載原圖","downloadOriginalImage": "下載原圖"},diff --git a/i18n/locales/zh-Hant-TW.json b/i18n/locales/zh-Hant-TW.jsonindex 21f218bc..6284bcb5 100644--- a/i18n/locales/zh-Hant-TW.json+++ b/i18n/locales/zh-Hant-TW.json@@ -102,11 +102,15 @@"actions": {"nativeShare": "使用系統分享","copyLink": "複製連結",+ "copied": "已複製",+ "close": "關閉",+ "otherPlatforms": "分享到其他平台",+ "retry": "重試","copyImage": "複製圖片","downloadImage": "下載原圖","generateShareImage": "產生分享圖片","shareUrl": "分享連結",- "downloadOgImage": "下載預覽圖",+ "downloadOgImage": "下載分享卡片","downloadOriginal": "下載原圖","downloadOriginalImage": "下載原圖"},