Refactored some other component and cleanup
This commit is contained in:
19
src/components/BikeClusterLayer.vue
Normal file
19
src/components/BikeClusterLayer.vue
Normal file
@@ -0,0 +1,19 @@
|
||||
<script lang="ts" setup>
|
||||
import type { BikeParking } from '@/types/Bikes'
|
||||
import { LMarkerClusterGroup } from 'vue-leaflet-markercluster'
|
||||
import BikeMarker from './BikeMarker.vue'
|
||||
|
||||
defineProps<{
|
||||
parkings: BikeParking[]
|
||||
group: 'covered' | 'non-covered' | 'premium'
|
||||
visible: boolean
|
||||
maxClusterRadius: number
|
||||
disableClusteringAtZoom: number
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<LMarkerClusterGroup v-if="parkings.length > 0" :visible :max-cluster-radius :disable-clustering-at-zoom>
|
||||
<BikeMarker v-once v-for="park in parkings" :key="park.id_parc_velo" :park :group />
|
||||
</LMarkerClusterGroup>
|
||||
</template>
|
||||
@@ -11,11 +11,10 @@ import type { BikeParking } from '@/types/Bikes'
|
||||
import { API_BASE_URL, API_LIMIT, MAP_TILELAYER_URL, SpotAccess, SpotType } from '@/utils/const'
|
||||
import { useQuery } from '@pinia/colada'
|
||||
import { LControlZoom, LMap, LTileLayer } from '@vue-leaflet/vue-leaflet'
|
||||
import { LMarkerClusterGroup } from 'vue-leaflet-markercluster'
|
||||
import BikeMarker from './BikeMarker.vue'
|
||||
import BikeFilters from './BikeFilters.vue'
|
||||
import { computed } from 'vue'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import BikeClusterLayer from './BikeClusterLayer.vue'
|
||||
|
||||
async function fetchAllBikeParkings(): Promise<BikeParking[]> {
|
||||
const firstPage = await fetch(`${API_BASE_URL}?limit=${API_LIMIT}`).then(r => r.json()) as ApiResponse
|
||||
@@ -84,23 +83,14 @@ const { filterUncovered, filterCovered, filterKorrigo } = storeToRefs(useMap())
|
||||
|
||||
<LTileLayer v-once :url="MAP_TILELAYER_URL" layer-type="base" />
|
||||
|
||||
<!-- Covered parkings: Abrité, Box individuel -->
|
||||
<LMarkerClusterGroup :visible="filterCovered" v-if="coveredParkings.length > 0" :max-cluster-radius
|
||||
:disable-clustering-at-zoom>
|
||||
<BikeMarker v-once v-for="park in coveredParkings" :key="park.id_parc_velo" :park group="covered" />
|
||||
</LMarkerClusterGroup>
|
||||
<BikeClusterLayer :parkings="coveredParkings" group="covered" :visible="filterCovered" :max-cluster-radius
|
||||
:disable-clustering-at-zoom />
|
||||
|
||||
<!-- Non-covered parkings: Non abrité -->
|
||||
<LMarkerClusterGroup :visible="filterUncovered" v-if="nonCoveredParkings.length > 0" :max-cluster-radius
|
||||
:disable-clustering-at-zoom>
|
||||
<BikeMarker v-once v-for="park in nonCoveredParkings" :key="park.id_parc_velo" :park group="non-covered" />
|
||||
</LMarkerClusterGroup>
|
||||
<BikeClusterLayer :parkings="nonCoveredParkings" group="non-covered" :visible="filterUncovered"
|
||||
:max-cluster-radius :disable-clustering-at-zoom />
|
||||
|
||||
<!-- Premium parkings: Abonnement Korrigo -->
|
||||
<LMarkerClusterGroup :visible="filterKorrigo" v-if="premiumParkings.length > 0" :max-cluster-radius
|
||||
:disable-clustering-at-zoom>
|
||||
<BikeMarker v-once v-for="park in premiumParkings" :key="park.id_parc_velo" :park group="premium" />
|
||||
</LMarkerClusterGroup>
|
||||
<BikeClusterLayer :parkings="premiumParkings" group="premium" :visible="filterKorrigo" :max-cluster-radius
|
||||
:disable-clustering-at-zoom />
|
||||
</LMap>
|
||||
</template>
|
||||
</main>
|
||||
@@ -10,16 +10,20 @@ const checked = defineModel<boolean>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<label class="flex flex-row gap-1.5 items-center text-sm cursor-pointer">
|
||||
<label class="flex flex-row gap-1.5 items-center text-sm cursor-pointer group">
|
||||
<CheckboxRoot v-model="checked"
|
||||
class="hover:bg-stone-100 flex size-4 appearance-none items-center justify-center rounded-xs bg-foreground shadow-sm border focus-within:ring-1 cursor-pointer">
|
||||
<CheckboxIndicator class="size-full flex items-center justify-center bg-primary text-primary-foreground">
|
||||
<PhCheck :size="10" weight="bold" />
|
||||
</CheckboxIndicator>
|
||||
</CheckboxRoot>
|
||||
|
||||
<span class="select-none">
|
||||
<slot />
|
||||
<small v-if="count">({{ count }})</small>
|
||||
<span class="group-hover:underline underline-offset-2">
|
||||
<slot />
|
||||
</span>
|
||||
|
||||
<small v-if="count" class="ml-1 opacity-50">({{ count }})</small>
|
||||
</span>
|
||||
</label>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import Map from '@/components/Map.vue';
|
||||
import BikeMap from '@/components/BikeMap.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -10,6 +10,6 @@ import Map from '@/components/Map.vue';
|
||||
</header>
|
||||
|
||||
<Suspense>
|
||||
<Map />
|
||||
<BikeMap />
|
||||
</Suspense>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user