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
fix(cloud): align masonry selection and touch targets
HoshinoSuzumiea483bc887a4
diff --git a/apps/cloud/app/components/CloudPhotoMasonry.vue b/apps/cloud/app/components/CloudPhotoMasonry.vueindex 48ec11c3..1c221c5f 100644--- a/apps/cloud/app/components/CloudPhotoMasonry.vue+++ b/apps/cloud/app/components/CloudPhotoMasonry.vue@@ -14,15 +14,14 @@ const emit = defineEmits<{ preview: [Photo] }>()const selectedCount = computed(() => props.photos.filter((photo) => selection.value[photo.id]).length,)+const selectionId = useId()const isMobile = useMediaQuery('(max-width: 768px)')function selectAll(value: boolean | 'indeterminate') {- const next = { ...selection.value }- for (const photo of props.photos) {- if (value === true) next[photo.id] = true- else delete next[photo.id]- }- selection.value = next+ selection.value =+ value === true+ ? Object.fromEntries(props.photos.map((photo) => [photo.id, true]))+ : {}}</script>@@ -57,13 +56,17 @@ function selectAll(value: boolean | 'indeterminate') {:index="index"@open-viewer="emit('preview', photo)"/>- <div class="cf-masonry-select">+ <label+ class="cf-masonry-select"+ :for="`${selectionId}-${photo.id}`"+ ><UCheckbox+ :id="`${selectionId}-${photo.id}`":model-value="!!selection[photo.id]":aria-label="$t('cloud.ui.selectNamed', { title: photo.title })"@update:model-value="selection[photo.id] = $event === true"/>- </div>+ </label><UDropdownMenu :items="actions(photo)"><CfButtonclass="cf-masonry-actions"diff --git a/tests/cloud-photo-masonry.test.ts b/tests/cloud-photo-masonry.test.tsnew file mode 100644index 00000000..38589caa--- /dev/null+++ b/tests/cloud-photo-masonry.test.ts@@ -0,0 +1,40 @@+import assert from 'node:assert/strict'+import { readFileSync } from 'node:fs'+import test from 'node:test'+import vm from 'node:vm'+import ts from 'typescript'+import { parse } from 'vue/compiler-sfc'+import { computed, ref } from 'vue'++test('masonry select-all replaces hidden selections and deselect-all clears them like the list view', () => {+ const { descriptor } = parse(+ readFileSync('apps/cloud/app/components/CloudPhotoMasonry.vue', 'utf8'),+ )+ const selection = ref<Record<string, boolean>>({ hidden: true })+ const props = { photos: [{ id: 'visible' }], actions: () => [] }+ const context = vm.createContext({+ exports: {},+ require: () => ({}),+ defineProps: () => props,+ defineModel: () => selection,+ defineEmits: () => () => {},+ computed,+ useId: () => 'selection',+ useMediaQuery: () => ref(false),+ })+ vm.runInContext(+ ts.transpileModule(descriptor.scriptSetup!.content, {+ compilerOptions: { module: ts.ModuleKind.CommonJS },+ }).outputText,+ context,+ )+ vm.runInContext('selectAll(true)', context)+ assert.deepEqual(Object.keys(selection.value), ['visible'])+ props.photos = [{ id: 'hidden' }, { id: 'visible' }]+ vm.runInContext('selectAll(false)', context)+ assert.deepEqual(Object.keys(selection.value), [])+ selection.value = { hidden: true }+ props.photos = [{ id: 'visible' }]+ vm.runInContext('selectAll(false)', context)+ assert.deepEqual(Object.keys(selection.value), [])+})