Unify CatalogPage: fixed map, hover support, delete ListMapLayout
All checks were successful
Build Docker Image / build (push) Successful in 4m31s
All checks were successful
Build Docker Image / build (push) Successful in 4m31s
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
<!-- Left: List (scrollable) -->
|
||||
<div class="w-2/5 overflow-y-auto pr-2">
|
||||
<Stack gap="4">
|
||||
<slot name="header" />
|
||||
<slot name="filters" />
|
||||
|
||||
<Stack gap="3">
|
||||
@@ -27,6 +28,8 @@
|
||||
:key="item.uuid"
|
||||
:class="{ 'ring-2 ring-primary rounded-lg': item.uuid === selectedId }"
|
||||
@click="onItemClick(item)"
|
||||
@mouseenter="emit('update:hoveredId', item.uuid)"
|
||||
@mouseleave="emit('update:hoveredId', undefined)"
|
||||
>
|
||||
<slot name="card" :item="item" />
|
||||
</div>
|
||||
@@ -42,17 +45,19 @@
|
||||
</Stack>
|
||||
</div>
|
||||
|
||||
<!-- Right: Map -->
|
||||
<div class="w-3/5 rounded-lg overflow-hidden">
|
||||
<ClientOnly>
|
||||
<CatalogMap
|
||||
ref="mapRef"
|
||||
:map-id="mapId"
|
||||
:items="itemsWithCoords"
|
||||
:point-color="pointColor"
|
||||
@select-item="onMapSelect"
|
||||
/>
|
||||
</ClientOnly>
|
||||
<!-- Right: Map (fixed position) -->
|
||||
<div class="w-3/5 relative">
|
||||
<div class="fixed top-28 right-6 w-[calc(60%-3rem)] h-[calc(100vh-8rem)] rounded-lg overflow-hidden">
|
||||
<ClientOnly>
|
||||
<CatalogMap
|
||||
ref="mapRef"
|
||||
:map-id="mapId"
|
||||
:items="itemsWithCoords"
|
||||
:point-color="pointColor"
|
||||
@select-item="onMapSelect"
|
||||
/>
|
||||
</ClientOnly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -60,6 +65,7 @@
|
||||
<div class="lg:hidden flex-1 flex flex-col min-h-0">
|
||||
<div class="flex-1 overflow-y-auto py-4" v-show="mobileView === 'list'">
|
||||
<Stack gap="4">
|
||||
<slot name="header" />
|
||||
<slot name="filters" />
|
||||
|
||||
<Stack gap="3">
|
||||
@@ -68,6 +74,8 @@
|
||||
:key="item.uuid"
|
||||
:class="{ 'ring-2 ring-primary rounded-lg': item.uuid === selectedId }"
|
||||
@click="onItemClick(item)"
|
||||
@mouseenter="emit('update:hoveredId', item.uuid)"
|
||||
@mouseleave="emit('update:hoveredId', undefined)"
|
||||
>
|
||||
<slot name="card" :item="item" />
|
||||
</div>
|
||||
@@ -120,6 +128,7 @@
|
||||
<!-- Without Map: Simple List -->
|
||||
<div v-else class="flex-1 overflow-y-auto py-4">
|
||||
<Stack gap="4">
|
||||
<slot name="header" />
|
||||
<slot name="filters" />
|
||||
|
||||
<Stack gap="3">
|
||||
@@ -162,6 +171,7 @@ const props = withDefaults(defineProps<{
|
||||
mapId?: string
|
||||
pointColor?: string
|
||||
selectedId?: string
|
||||
hoveredId?: string
|
||||
}>(), {
|
||||
loading: false,
|
||||
withMap: true,
|
||||
@@ -172,6 +182,7 @@ const props = withDefaults(defineProps<{
|
||||
const emit = defineEmits<{
|
||||
'select': [item: MapItem]
|
||||
'update:selectedId': [uuid: string]
|
||||
'update:hoveredId': [uuid: string | undefined]
|
||||
}>()
|
||||
|
||||
// Filter items with valid coordinates for map
|
||||
@@ -229,6 +240,17 @@ watch(() => props.selectedId, (uuid) => {
|
||||
}
|
||||
})
|
||||
|
||||
// Watch hoveredId and fly to it
|
||||
watch(() => props.hoveredId, (uuid) => {
|
||||
if (uuid && props.withMap) {
|
||||
const item = itemsWithCoords.value.find(i => i.uuid === uuid)
|
||||
if (item) {
|
||||
mapRef.value?.flyTo(item.latitude, item.longitude, 8)
|
||||
mobileMapRef.value?.flyTo(item.latitude, item.longitude, 8)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Expose flyTo for external use
|
||||
const flyTo = (lat: number, lng: number, zoom = 8) => {
|
||||
mapRef.value?.flyTo(lat, lng, zoom)
|
||||
|
||||
Reference in New Issue
Block a user