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

feat: redesign recipe info card (#5026)

Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com>
This commit is contained in:
Kuchenpirat 2025-02-26 17:07:12 +01:00 committed by GitHub
parent 3fd3661206
commit 3b0d6050a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 96 additions and 106 deletions

View file

@ -86,29 +86,27 @@
</BaseDialog> </BaseDialog>
</div> </div>
<div> <div>
<div class="d-flex justify-center flex-wrap"> <div v-if="lastMadeReady" class="d-flex justify-center flex-wrap">
<v-chip <v-row no-gutters class="d-flex flex-wrap align-center" style="font-size: larger;">
label <v-tooltip bottom>
:small="$vuetify.breakpoint.smAndDown" <template #activator="{ on, attrs }">
color="accent custom-transparent" <v-btn
class="ma-1 pa-3" rounded
> outlined
<v-icon left> x-large
{{ $globals.icons.calendar }} color="primary"
</v-icon> v-bind="attrs"
<div v-if="lastMadeReady"> v-on="on"
{{ $t('recipe.last-made-date', { date: lastMade ? new Date(lastMade).toLocaleDateString($i18n.locale) : $t("general.never") } ) }} @click="madeThisDialog = true"
</div> >
<div v-else> <v-icon left large>{{ $globals.icons.calendar }}</v-icon>
<AppLoader tiny /> <span class="text--secondary" style="letter-spacing: normal;"><b>{{ $tc("general.last-made") }}</b><br>{{ lastMade ? new Date(lastMade).toLocaleDateString($i18n.locale) : $tc("general.never") }}</span>
</div> <v-icon right large>{{ $globals.icons.createAlt }}</v-icon>
</v-chip> </v-btn>
</div> </template>
<div class="d-flex justify-center flex-wrap mt-1"> <span>{{ $tc("recipe.made-this") }}</span>
<BaseButton :small="$vuetify.breakpoint.smAndDown" @click="madeThisDialog = true"> </v-tooltip>
<template #icon> {{ $globals.icons.chefHat }} </template> </v-row>
{{ $t('recipe.made-this') }}
</BaseButton>
</div> </div>
</div> </div>
</div> </div>

View file

@ -14,15 +14,16 @@
</v-card-title> </v-card-title>
<v-divider class="my-2" /> <v-divider class="my-2" />
<SafeMarkdown :source="recipe.description" /> <SafeMarkdown :source="recipe.description" />
<v-divider /> <v-divider v-if="recipe.description" />
<v-container class="d-flex flex-row flex-wrap justify-center align-center"> <v-container class="d-flex flex-row flex-wrap justify-center align-center">
<div class="mx-5"> <div class="mx-6">
<v-row no-gutters class="mb-1"> <v-row no-gutters class="mb-1">
<v-col v-if="recipe.recipeYieldQuantity || recipe.recipeYield" cols="12" class="d-flex flex-wrap justify-center"> <v-col v-if="recipe.recipeYieldQuantity || recipe.recipeYield" cols="12" class="d-flex flex-wrap justify-center">
<RecipeYield <RecipeYield
:yield-quantity="recipe.recipeYieldQuantity" :yield-quantity="recipe.recipeYieldQuantity"
:yield="recipe.recipeYield" :yield="recipe.recipeYield"
:scale="recipeScale" :scale="recipeScale"
class="mb-4"
/> />
</v-col> </v-col>
</v-row> </v-row>
@ -31,18 +32,18 @@
<RecipeLastMade <RecipeLastMade
v-if="isOwnGroup" v-if="isOwnGroup"
:recipe="recipe" :recipe="recipe"
:class="true ? undefined : 'force-bottom'" class="mb-4"
/> />
</v-col> </v-col>
</v-row> </v-row>
</div> </div>
<div class="mx-5"> <div class="mx-6">
<RecipeTimeCard <RecipeTimeCard
stacked
container-class="d-flex flex-wrap justify-center" container-class="d-flex flex-wrap justify-center"
:prep-time="recipe.prepTime" :prep-time="recipe.prepTime"
:total-time="recipe.totalTime" :total-time="recipe.totalTime"
:perform-time="recipe.performTime" :perform-time="recipe.performTime"
class="mb-4"
/> />
</div> </div>
</v-container> </v-container>

View file

@ -30,12 +30,17 @@
<span v-html="recipeYield"></span> <span v-html="recipeYield"></span>
</v-chip> </v-chip>
</div> </div>
<RecipeTimeCard <v-row class="d-flex justify-start">
:prep-time="recipe.prepTime" <RecipeTimeCard
:total-time="recipe.totalTime" :prep-time="recipe.prepTime"
:perform-time="recipe.performTime" :total-time="recipe.totalTime"
color="white" :perform-time="recipe.performTime"
/> small
color="white"
class="ml-4"
/>
</v-row>
<v-card-text v-if="preferences.showDescription" class="px-0"> <v-card-text v-if="preferences.showDescription" class="px-0">
<SafeMarkdown :source="recipe.description" /> <SafeMarkdown :source="recipe.description" />
</v-card-text> </v-card-text>

View file

@ -1,41 +1,33 @@
<template> <template v-if="showCards">
<div v-if="stacked"> <div class="text-center">
<v-container> <!-- Total Time -->
<v-row v-for="(time, index) in allTimes" :key="`${index}-stacked`" no-gutters> <div v-if="validateTotalTime" class="time-card-flex mx-auto">
<v-col cols="12" :class="containerClass"> <v-row no-gutters class="d-flex flex-no-wrap align-center " :style="fontSize">
<v-chip <v-icon :x-large="!small" left color="primary">
:small="$vuetify.breakpoint.smAndDown"
label
:color="color"
class="ma-1"
>
<v-icon left>
{{ $globals.icons.clockOutline }}
</v-icon>
{{ time.name }} |
{{ time.value }}
</v-chip>
</v-col>
</v-row>
</v-container>
</div>
<div v-else>
<v-container :class="containerClass">
<v-chip
v-for="(time, index) in allTimes"
:key="index"
:small="$vuetify.breakpoint.smAndDown"
label
:color="color"
class="ma-1"
>
<v-icon left>
{{ $globals.icons.clockOutline }} {{ $globals.icons.clockOutline }}
</v-icon> </v-icon>
{{ time.name }} | <p class="my-0"><span class="font-weight-bold">{{ validateTotalTime.name }}</span><br>{{ validateTotalTime.value }}</p>
{{ time.value }} </v-row>
</v-chip> </div>
</v-container> <v-divider v-if="validateTotalTime && (validatePrepTime || validatePerformTime)" class="my-2" />
<!-- Prep Time & Perform Time -->
<div v-if="validatePrepTime || validatePerformTime" class="time-card-flex mx-auto">
<v-row no-gutters class="d-flex justify-center align-center" style="width: 100%;" :style="fontSize">
<div v-if="validatePrepTime" class="d-flex flex-no-wrap">
<v-icon :large="!small" :dense="small" left color="primary">
{{ $globals.icons.knfife }}
</v-icon>
<p class="my-0"><span class="font-weight-bold">{{ validatePrepTime.name }}</span><br>{{ validatePrepTime.value }}</p>
</div>
<v-divider v-if="validatePrepTime && validatePerformTime" vertical class="mx-4" />
<div v-if="validatePerformTime" class="d-flex flex-no-wrap">
<v-icon :large="!small" :dense="small" left color="primary">
{{ $globals.icons.potSteam }}
</v-icon>
<p class="my-0"><span class="font-weight-bold">{{ validatePerformTime.name }}</span><br>{{ validatePerformTime.value }}</p>
</div>
</v-row>
</div>
</div> </div>
</template> </template>
@ -44,10 +36,6 @@ import { computed, defineComponent, useContext } from "@nuxtjs/composition-api";
export default defineComponent({ export default defineComponent({
props: { props: {
stacked: {
type: Boolean,
default: false,
},
prepTime: { prepTime: {
type: String, type: String,
default: null, default: null,
@ -64,9 +52,9 @@ export default defineComponent({
type: String, type: String,
default: "accent custom-transparent" default: "accent custom-transparent"
}, },
containerClass: { small: {
type: String, type: Boolean,
default: undefined, default: false,
}, },
}, },
setup(props) { setup(props) {
@ -92,13 +80,16 @@ export default defineComponent({
return !isEmpty(props.performTime) ? { name: i18n.t("recipe.perform-time"), value: props.performTime } : null; return !isEmpty(props.performTime) ? { name: i18n.t("recipe.perform-time"), value: props.performTime } : null;
}); });
const allTimes = computed(() => { const fontSize = computed(() => {
return [validateTotalTime.value, validatePrepTime.value, validatePerformTime.value].filter((x) => x !== null); return props.small ? { fontSize: "smaller" } : { fontSize: "larger" };
}); });
return { return {
showCards, showCards,
allTimes, validateTotalTime,
validatePrepTime,
validatePerformTime,
fontSize,
}; };
}, },
}); });

View file

@ -1,21 +1,20 @@
<template> <template>
<div v-if="displayText" class="d-flex justify-space-between align-center"> <div v-if="scaledAmount" class="d-flex align-center">
<v-chip <v-row no-gutters class="d-flex flex-wrap align-center" style="font-size: larger;">
:small="$vuetify.breakpoint.smAndDown" <v-icon x-large left color="primary">
label {{ $globals.icons.bread }}
:color="color"
>
<v-icon left>
{{ $globals.icons.potSteam }}
</v-icon> </v-icon>
<!-- eslint-disable-next-line vue/no-v-html --> <p class="my-0">
<span v-html="displayText"></span> <span class="font-weight-bold">{{ $i18n.tc("recipe.yield") }}</span><br>
</v-chip> <!-- eslint-disable-next-line vue/no-v-html -->
<span v-html="scaledAmount"></span> {{ text }}
</p>
</v-row>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, useContext } from "@nuxtjs/composition-api"; import { defineComponent, computed } from "@nuxtjs/composition-api";
import DOMPurify from "dompurify"; import DOMPurify from "dompurify";
import { useScaledAmount } from "~/composables/recipes/use-scaled-amount"; import { useScaledAmount } from "~/composables/recipes/use-scaled-amount";
@ -39,7 +38,6 @@ export default defineComponent({
}, },
}, },
setup(props) { setup(props) {
const { i18n } = useContext();
function sanitizeHTML(rawHtml: string) { function sanitizeHTML(rawHtml: string) {
return DOMPurify.sanitize(rawHtml, { return DOMPurify.sanitize(rawHtml, {
@ -48,21 +46,15 @@ export default defineComponent({
}); });
} }
const displayText = computed(() => { const scaledAmount = computed(() => {
if (!(props.yieldQuantity || props.yield)) { const {scaledAmountDisplay} = useScaledAmount(props.yieldQuantity, props.scale);
return ""; return scaledAmountDisplay;
}
const { scaledAmountDisplay } = useScaledAmount(props.yieldQuantity, props.scale);
return i18n.t("recipe.yields-amount-with-text", {
amount: scaledAmountDisplay,
text: sanitizeHTML(props.yield),
}) as string;
}); });
const text = sanitizeHTML(props.yield);
return { return {
displayText, scaledAmount,
text,
}; };
}, },
}); });

View file

@ -579,7 +579,6 @@
"made-this": "I Made This", "made-this": "I Made This",
"how-did-it-turn-out": "How did it turn out?", "how-did-it-turn-out": "How did it turn out?",
"user-made-this": "{user} made this", "user-made-this": "{user} made this",
"last-made-date": "Last Made {date}",
"api-extras-description": "Recipes extras are a key feature of the Mealie API. They allow you to create custom JSON key/value pairs within a recipe, to reference from 3rd party applications. You can use these keys to provide information, for example to trigger automations or custom messages to relay to your desired device.", "api-extras-description": "Recipes extras are a key feature of the Mealie API. They allow you to create custom JSON key/value pairs within a recipe, to reference from 3rd party applications. You can use these keys to provide information, for example to trigger automations or custom messages to relay to your desired device.",
"message-key": "Message Key", "message-key": "Message Key",
"parse": "Parse", "parse": "Parse",

View file

@ -146,6 +146,8 @@ import {
mdiFileCabinet, mdiFileCabinet,
mdiSilverwareForkKnife, mdiSilverwareForkKnife,
mdiCodeTags, mdiCodeTags,
mdiKnife,
mdiCookie
} from "@mdi/js"; } from "@mdi/js";
export const icons = { export const icons = {
@ -271,6 +273,8 @@ export const icons = {
windowClose: mdiWindowClose, windowClose: mdiWindowClose,
zip: mdiFolderZipOutline, zip: mdiFolderZipOutline,
undo: mdiUndo, undo: mdiUndo,
knfife: mdiKnife,
bread: mdiCookie,
// Crud // Crud
backArrow: mdiArrowLeftBoldOutline, backArrow: mdiArrowLeftBoldOutline,