add categories to cards

This commit is contained in:
hay-kot 2021-04-02 22:26:34 -08:00
commit 289eceab71
3 changed files with 34 additions and 10 deletions

View file

@ -5,6 +5,7 @@
:elevation="hover ? 12 : 2" :elevation="hover ? 12 : 2"
:to="route ? `/recipe/${slug}` : ''" :to="route ? `/recipe/${slug}` : ''"
@click="$emit('click')" @click="$emit('click')"
min-height="275"
> >
<v-img height="200" :src="getImage(image)"> <v-img height="200" :src="getImage(image)">
<v-expand-transition v-if="description"> <v-expand-transition v-if="description">
@ -25,9 +26,9 @@
</div> </div>
</v-card-title> </v-card-title>
<v-card-actions class=""> <v-card-actions>
<v-rating <v-rating
class="mr-2" class="mr-2 my-auto"
color="secondary" color="secondary"
background-color="secondary lighten-3" background-color="secondary lighten-3"
dense dense
@ -36,14 +37,24 @@
:value="rating" :value="rating"
></v-rating> ></v-rating>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<RecipeChips
:items="categories"
:title="false"
:limit="2"
:small="true"
/>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-hover> </v-hover>
</template> </template>
<script> <script>
import RecipeChips from "@/components/Recipe/RecipeViewer/RecipeChips";
import { api } from "@/api"; import { api } from "@/api";
export default { export default {
components: {
RecipeChips,
},
props: { props: {
name: String, name: String,
slug: String, slug: String,
@ -54,6 +65,9 @@ export default {
route: { route: {
default: true, default: true,
}, },
categories: {
default: true,
},
}, },
methods: { methods: {
getImage(image) { getImage(image) {

View file

@ -1,12 +1,13 @@
<template> <template>
<div v-if="items && items.length > 0"> <div v-if="items && items.length > 0">
<h2 class="mt-4">{{ title }}</h2> <h2 v-if="title" class="mt-4">{{ title }}</h2>
<v-chip <v-chip
label label
class="ma-1" class="ma-1"
color="accent" color="accent"
:small="small"
dark dark
v-for="category in items" v-for="category in items.slice(0, limit)"
:to="`/recipes/${urlParam}/${getSlug(category)}`" :to="`/recipes/${urlParam}/${getSlug(category)}`"
:key="category" :key="category"
> >
@ -19,10 +20,18 @@
export default { export default {
props: { props: {
items: Array, items: Array,
title: String, title: {
default: null,
},
isCategory: { isCategory: {
default: true, default: true,
}, },
limit: {
default: 999,
},
small: {
default: false,
},
}, },
computed: { computed: {
allCategories() { allCategories() {
@ -32,8 +41,8 @@ export default {
return this.$store.getters.getAllTags; return this.$store.getters.getAllTags;
}, },
urlParam() { urlParam() {
return this.isCategory ? 'category' : 'tag' return this.isCategory ? "category" : "tag";
} },
}, },
methods: { methods: {
getSlug(name) { getSlug(name) {

View file

@ -15,9 +15,9 @@
<v-menu offset-y v-if="sortable"> <v-menu offset-y v-if="sortable">
<template v-slot:activator="{ on, attrs }"> <template v-slot:activator="{ on, attrs }">
<v-btn-toggle group> <v-btn-toggle group>
<v-btn text v-bind="attrs" v-on="on">{{ <v-btn text v-bind="attrs" v-on="on">
$t("general.sort") {{ $t("general.sort") }}
}}</v-btn> </v-btn>
</v-btn-toggle> </v-btn-toggle>
</template> </template>
<v-list> <v-list>
@ -53,6 +53,7 @@
:slug="recipe.slug" :slug="recipe.slug"
:rating="recipe.rating" :rating="recipe.rating"
:image="recipe.image" :image="recipe.image"
:categories="recipe.recipeCategory"
/> />
</v-col> </v-col>
</v-row> </v-row>