Skip to content

Commit

Permalink
refactor: apply script setup style to MapFeatures #362
Browse files Browse the repository at this point in the history
  • Loading branch information
wazolab committed Sep 23, 2024
1 parent a4943dc commit 787f736
Show file tree
Hide file tree
Showing 6 changed files with 354 additions and 420 deletions.
18 changes: 7 additions & 11 deletions components/Home/Embedded.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const { t } = useI18n()
// Data
//
const initialBbox = ref<LngLatBounds | null>(null)
const mapFeaturesRef = ref<InstanceType<typeof MapFeatures>>()
const mapFeaturesRef = ref<InstanceType<typeof MapFeatures> | null>(null)
//
// Hooks
Expand Down Expand Up @@ -108,14 +108,11 @@ const mapFeatures = computed((): ApiPoi[] => {
const poiFilters = computed(() => {
return (
(
isModeExplorer.value
&& (Object.values(apiMenuCategory.value || {})
.map(c => c.category?.style_class)
.filter(s => s !== undefined) as string[][])
)
|| null
)
isModeExplorer.value
&& (Object.values(apiMenuCategory.value || {})
.map(c => c.category?.style_class)
.filter(s => s !== undefined) as string[][])
) || undefined
})
// Store Subscribers
Expand Down Expand Up @@ -144,8 +141,7 @@ watch(selectedCategoryIds, (a, b) => {
// Methods
//
function goToSelectedFeature() {
if (mapFeaturesRef.value)
mapFeaturesRef.value.goToSelectedFeature()
mapFeaturesRef.value?.goToSelectedFeature()
}
function onMenuChange(newCategoryId: number) {
Expand Down
16 changes: 6 additions & 10 deletions components/Home/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,11 @@ const menuItemsToIcons = computed(() => {
const poiFilters = computed(() => {
return (
(
isModeExplorer.value
&& (Object.values(apiMenuCategory.value || {})
.map(c => c.category?.style_class)
.filter(s => s !== undefined) as string[][])
)
|| null
)
isModeExplorer.value
&& (Object.values(apiMenuCategory.value || {})
.map(c => c.category?.style_class)
.filter(s => s !== undefined) as string[][])
) || undefined
})
const siteName = computed(() => {
Expand Down Expand Up @@ -291,8 +288,7 @@ watch(isModeFavorites, async (isEnabled) => {
// Methods
//
function goToSelectedFeature() {
if (mapFeaturesRef.value)
mapFeaturesRef.value.goToSelectedFeature()
mapFeaturesRef.value?.goToSelectedFeature()
}
async function fetchAddress(hash: string) {
Expand Down
5 changes: 3 additions & 2 deletions components/MainMap/MapFeatures.story.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { LngLatBounds } from 'maplibre-gl'
import { LngLatBounds, type LngLatBoundsLike } from 'maplibre-gl'
import MapFeatures from '~/components/MainMap/MapFeatures.vue'
import type { ApiMenuCategory } from '~/lib/apiMenu'
Expand All @@ -12,7 +12,7 @@ const defaultProps = {
defaultBounds: new LngLatBounds([
[-1.4755803, 43.4916681],
[-1.4735674, 43.4902015],
]),
]) as LngLatBoundsLike,
categories: [
{
id: 1,
Expand All @@ -35,6 +35,7 @@ const defaultProps = {
} as ApiMenuCategory,
],
explorerModeEnabled: false,
selectedCategoriesIds: [],
}
const feature1: ApiPoi = {
Expand Down
Loading

0 comments on commit 787f736

Please sign in to comment.