1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-19 13:19:41 +02:00

reorganize all frontend items

This commit is contained in:
hay-kot 2021-08-01 19:24:47 -08:00
parent d67240d449
commit 00a8fdda41
147 changed files with 3845 additions and 743 deletions

View file

@ -2,14 +2,14 @@
<div v-if="items.length > 0">
<h2 v-if="title" class="mt-4">{{ title }}</h2>
<v-chip
v-for="category in items.slice(0, limit)"
:key="category"
label
class="ma-1"
color="accent"
:small="small"
dark
v-for="category in items.slice(0, limit)"
:to="`/recipes/${urlParam}/${getSlug(category)}`"
:key="category"
>
{{ truncateText(category) }}
</v-chip>
@ -20,24 +20,33 @@
export default {
props: {
truncate: {
type: Boolean,
default: false,
},
items: {
default: [],
type: Array,
default: () => [],
},
title: {
default: null,
type: Boolean,
default: false,
},
isCategory: {
type: Boolean,
default: true,
},
limit: {
type: Number,
default: 999,
},
small: {
type: Boolean,
default: false,
},
maxWidth: {},
maxWidth: {
type: String,
default: null,
},
},
computed: {
allCategories() {
@ -55,19 +64,19 @@ export default {
if (!name) return;
if (this.isCategory) {
const matches = this.allCategories.filter(x => x.name == name);
const matches = this.allCategories.filter((x) => x.name === name);
if (matches.length > 0) return matches[0].slug;
} else {
const matches = this.allTags.filter(x => x.name == name);
const matches = this.allTags.filter((x) => x.name === name);
if (matches.length > 0) return matches[0].slug;
}
},
truncateText(text, length = 20, clamp) {
if (!this.truncate) return text;
clamp = clamp || "...";
var node = document.createElement("div");
const node = document.createElement("div");
node.innerHTML = text;
var content = node.textContent;
const content = node.textContent;
return content.length > length ? content.slice(0, length) + clamp : content;
},
},