Skip to content

Commit 138b5b5

Browse files
committed
Add search input to map and list view. Search only on address for now. OWC-94
1 parent e4834fe commit 138b5b5

8 files changed

Lines changed: 246 additions & 20 deletions

File tree

build/blocks/owc-openkaarten/streetmap/client.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/blocks/owc-openkaarten/streetmap/client.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/blocks/owc-openkaarten/streetmap/editor.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/blocks/owc-openkaarten/streetmap/style.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"/blocks/owc-openkaarten/streetmap/client.js": "/blocks/owc-openkaarten/streetmap/client.js?id=7a35ddc22ecd2afb0e29c5bc1867f468",
2+
"/blocks/owc-openkaarten/streetmap/client.js": "/blocks/owc-openkaarten/streetmap/client.js?id=8888c46658d6c24f49ebeaf5d0a89eb3",
33
"/blocks/owc-openkaarten/streetmap/style.css": "/blocks/owc-openkaarten/streetmap/style.css?id=0c70cc29722d11466724176fc03cdd58",
44
"/blocks/owc-openkaarten/streetmap/editor.css": "/blocks/owc-openkaarten/streetmap/editor.css?id=f4316f0723fb86e3b028a9b448b1f3ae"
55
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<script setup>
2+
import { ref } from 'vue';
3+
4+
const props = defineProps({
5+
placeholder: {
6+
type: String,
7+
default: 'Zoeken...',
8+
},
9+
primaryColor: {
10+
type: String,
11+
required: true,
12+
},
13+
});
14+
15+
const emit = defineEmits(['search']);
16+
const searchQuery = ref('');
17+
18+
const handleSubmit = (e) => {
19+
e.preventDefault();
20+
emit('search', searchQuery.value);
21+
};
22+
23+
const handleInput = () => {
24+
if (!searchQuery.value) {
25+
emit('search', ''); // Clear search when input is empty
26+
}
27+
};
28+
</script>
29+
30+
<template>
31+
<form
32+
@submit="handleSubmit"
33+
class="search-input"
34+
:style="{ '--search-primary-color': primaryColor }"
35+
>
36+
<input
37+
type="search"
38+
v-model="searchQuery"
39+
:placeholder="placeholder"
40+
@input="handleInput"
41+
class="search-input__field"
42+
/>
43+
<button
44+
type="submit"
45+
class="search-input__button"
46+
:disabled="!searchQuery"
47+
>
48+
<span class="sr-only">Zoeken</span>
49+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
50+
<path d="M15.5 14H14.71L14.43 13.73C15.41 12.59 16 11.11 16 9.5C16 5.91 13.09 3 9.5 3C5.91 3 3 5.91 3 9.5C3 13.09 5.91 16 9.5 16C11.11 16 12.59 15.41 13.73 14.43L14 14.71V15.5L19 20.49L20.49 19L15.5 14ZM9.5 14C7.01 14 5 11.99 5 9.5C5 7.01 7.01 5 9.5 5C11.99 5 14 7.01 14 9.5C14 11.99 11.99 14 9.5 14Z" fill="currentColor"/>
51+
</svg>
52+
</button>
53+
</form>
54+
</template>
55+
56+
<style lang="scss" scoped>
57+
.search-input {
58+
position: relative;
59+
flex-grow: 1;
60+
margin-inline-end: 1.5rem;
61+
62+
&__field {
63+
block-size: 100%;
64+
inline-size: 100%;
65+
padding: 0.75rem 1rem;
66+
border: 1px solid #7a7a7a;
67+
border-radius: 4px;
68+
font-size: 1rem;
69+
}
70+
71+
&__button {
72+
position: absolute;
73+
display: flex;
74+
align-items: center;
75+
justify-content: center;
76+
inset-block: 4px;
77+
inset-inline-end: 4px;
78+
min-block-size: auto;
79+
padding: 0.75rem;
80+
background-color: var(--search-primary-color);
81+
border: none;
82+
border-radius: 4px;
83+
color: white;
84+
transition: opacity 0.2s ease;
85+
cursor: pointer;
86+
87+
&:hover {
88+
opacity: 0.9;
89+
}
90+
91+
&:focus-visible {
92+
outline: 2px solid var(--search-primary-color);
93+
outline-offset: 2px;
94+
}
95+
}
96+
}
97+
</style>

src/blocks/owc-openkaarten/streetmap/assets/scripts/vue/ListView.vue

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import BaseListCard from './BaseListCard.vue';
44
import { makeFilterButtonHTML } from '../utils/make-filter-button-html';
55
import { makeMapButtonHTML } from '../utils/make-map-button-html';
66
import BaseFilters from './BaseFilters.vue';
7+
import BaseSearchInput from './BaseSearchInput.vue';
78
89
const props = defineProps({
910
datasets: {
@@ -20,8 +21,10 @@ const props = defineProps({
2021
},
2122
});
2223
24+
const searchQuery = ref('');
25+
2326
const filteredLocations = computed(() => {
24-
return props.datasets
27+
let locations = props.datasets
2528
.filter(dataset => {
2629
return props.selectedDatasets.includes(dataset.id) &&
2730
!dataset.features.some(feature => feature.geometry?.type === 'Polygon');
@@ -39,6 +42,15 @@ const filteredLocations = computed(() => {
3942
image: tooltipData.find(t => t.layout === 'image')?.image || ''
4043
};
4144
}));
45+
46+
if (searchQuery.value) {
47+
const query = searchQuery.value.toLowerCase();
48+
locations = locations.filter(location =>
49+
location.meta?.toLowerCase().includes(query)
50+
);
51+
}
52+
53+
return locations;
4254
});
4355
4456
const emits = defineEmits(['toggleView', 'datasetChange']);
@@ -88,6 +100,10 @@ const loadMore = () => {
88100
}
89101
});
90102
};
103+
104+
const handleSearch = (query) => {
105+
searchQuery.value = query;
106+
};
91107
</script>
92108
93109
<template>
@@ -100,6 +116,10 @@ const loadMore = () => {
100116
}"
101117
>
102118
<div class="list-view__controls">
119+
<BaseSearchInput
120+
:primary-color="primaryColor"
121+
@search="handleSearch"
122+
/>
103123
<button @click="toggleView" class="list-view__map-button" v-html="mapButtonHTML"></button>
104124
<button
105125
v-if="datasets.length > 1"
@@ -187,7 +207,7 @@ const loadMore = () => {
187207
&__controls {
188208
display: flex;
189209
justify-content: flex-end;
190-
gap: 1rem;
210+
gap: 0.5rem;
191211
margin-block-end: 0.5rem;
192212
193213
button {

0 commit comments

Comments
 (0)