8000 search meals · WilliamBostrom/Nuxt-vue@9718606 · GitHub
[go: up one dir, main page]

Skip to content 10000

Commit 9718606

Browse files
search meals
1 parent c030dd4 commit 9718606

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pages/menu/index.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
<template>
22
<main class="mb-8">
3+
<div class="flex items-center justify-center">
4+
<input
5+
class="mt-8 border border-gray-200 card bg-gray-50 focus:outline-none focus:ring-2 focus:ring-[#12b488] justify-center p-2"
6+
placeholder="Search meals..."
7+
v-model="filterText"
8+
/>
9+
</div>
310
<div class="mt-6 gap-6 grid sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
4-
<div v-for="recipe in recipes" :key="recipe.id">
11+
<div v-for="recipe in filteredMeals" :key="recipe.id">
512
<MenuCard :recipe="recipe" />
613
</div>
714
</div>
815
</main>
916
</template>
1017

1118
<script setup lang="ts">
19+
const filterText = ref("");
20+
122 9934 1
definePageMeta({
1322
layout: "menu",
1423
});
@@ -20,6 +29,14 @@ useHead({
2029
const { data } = await useFetch<Recipe[]>("api/food/menus");
2130
2231
const recipes: Recipe[] = data.value || [];
32+
33+
const filteredMeals = computed(() =>
34+
recipes.filter(
35+
(
36+
meal // Ingen .value här på recipes
37+
) => meal.name.toLowerCase().includes(filterText.value.toLowerCase()) // använd filterText här istället
38+
)
39+
);
2340
</script>
2441

2542
<style scoped>

0 commit comments

Comments
 (0)
0