mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-02 20:59:28 -05:00
start page
This commit is contained in:
59
vue3/src/components/display/HorizontalRecipeScroller.vue
Normal file
59
vue3/src/components/display/HorizontalRecipeScroller.vue
Normal file
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<v-row justify="space-between">
|
||||
<v-col>
|
||||
<h2>{{ title }}</h2>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-btn density="default" variant="outlined" size="x-small" icon="fas fa-chevron-left" @click="scrollList('left', scroll_id)"></v-btn>
|
||||
<v-btn density="default" variant="outlined" size="x-small" icon="fas fa-chevron-right" @click="scrollList('right', scroll_id)"></v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-row>
|
||||
<v-col>
|
||||
|
||||
<v-infinite-scroll direction="horizontal" mode="manual" :id="scroll_id">
|
||||
|
||||
<div v-for="r in recipes" class="mr-2">
|
||||
<recipe-card :recipe="r" :show_description="false" :show_keywords="false" style="width: 45vw; height: 30vh"></recipe-card>
|
||||
</div>
|
||||
|
||||
<template #load-more></template>
|
||||
|
||||
</v-infinite-scroll>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {defineComponent, PropType} from 'vue'
|
||||
import {Recipe, RecipeOverview} from "@/openapi";
|
||||
import RecipeCard from "@/components/display/RecipeCard.vue";
|
||||
|
||||
export default defineComponent({
|
||||
name: "HorizontalRecipeScroller",
|
||||
components: {RecipeCard},
|
||||
props: {
|
||||
title: {type: String, required: true},
|
||||
recipes: {type: Array as PropType<Array<Recipe | RecipeOverview>>, required: true},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
scroll_id: Math.random(1000).toString()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
scrollList(direction: string, target: string) {
|
||||
const newRecipeScroll = document.getElementById(target)
|
||||
if (newRecipeScroll != null) {
|
||||
newRecipeScroll.scrollLeft = newRecipeScroll.scrollLeft + (200 * ((direction == 'left') ? -1 : 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -3,19 +3,19 @@
|
||||
|
||||
<v-img
|
||||
cover
|
||||
height="250"
|
||||
height="50%"
|
||||
:src="recipe.image"
|
||||
></v-img>
|
||||
|
||||
<v-card-item>
|
||||
<v-card-title>{{ recipe.name }}</v-card-title>
|
||||
|
||||
<v-card-subtitle>
|
||||
<v-card-subtitle v-if="show_keywords">
|
||||
<KeywordsComponent :keywords="recipe.keywords"></KeywordsComponent>
|
||||
</v-card-subtitle>
|
||||
</v-card-item>
|
||||
|
||||
<v-card-text>
|
||||
<v-card-text v-if="show_description">
|
||||
<v-row align="center" class="mx-0" v-if="recipe.rating">
|
||||
<v-rating
|
||||
:model-value="recipe.rating"
|
||||
@@ -26,7 +26,7 @@
|
||||
size="small"
|
||||
></v-rating>
|
||||
|
||||
<div class="text-grey ms-4">
|
||||
<div class="text-grey ">
|
||||
{{ recipe.rating }}
|
||||
</div>
|
||||
</v-row>
|
||||
@@ -46,7 +46,9 @@ export default defineComponent({
|
||||
name: "RecipeCard",
|
||||
components: {KeywordsComponent},
|
||||
props: {
|
||||
recipe: {} as Recipe
|
||||
recipe: {} as Recipe,
|
||||
show_keywords: {type: Boolean, required: false},
|
||||
show_description: {type: Boolean, required: false},
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user