Skip to content

Commit

Permalink
fix: fixed text color on RecipeCard in RecipePrintView and implemente…
Browse files Browse the repository at this point in the history
…d ingredient sections (#1351)

* Enhanced ingredients in RecipePrintView

* Resolved frontend lint tests

* switched lets to consts and simplified import

* implement with CSS grid

Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com>
  • Loading branch information
michael-genson and hay-kot committed Jun 11, 2022
1 parent c0d59db commit 92ccbae
Showing 1 changed file with 22 additions and 37 deletions.
59 changes: 22 additions & 37 deletions frontend/components/Domain/Recipe/RecipePrintView.vue
Expand Up @@ -14,19 +14,14 @@
<VueMarkdown :source="recipe.description" />
</v-card-text>

<!-- Ingredients -->
<section>
<v-card-title class="headline pl-0"> {{ $t("recipe.ingredients") }} </v-card-title>
<div class="ingredient-grid">
<div class="ingredient-col-1">
<ul>
<li v-for="(text, index) in splitIngredients.firstHalf" :key="index" v-html="text" />
</ul>
</div>
<div class="ingredient-col-2">
<ul>
<li v-for="(text, index) in splitIngredients.secondHalf" :key="index" v-html="text" />
</ul>
</div>
<template v-for="(ingredient, index) in recipe.recipeIngredient">
<h4 v-if="ingredient.title" :key="`title-${index}`" class="ingredient-title mt-2">{{ ingredient.title }}</h4>
<p :key="`ingredient-${index}`" v-html="parseText(ingredient)" />
</template>
</div>
</section>

Expand Down Expand Up @@ -57,14 +52,9 @@ import { defineComponent, computed } from "@nuxtjs/composition-api";
// @ts-ignore vue-markdown has no types
import VueMarkdown from "@adapttive/vue-markdown";
import RecipeTimeCard from "~/components/Domain/Recipe/RecipeTimeCard.vue";
import { Recipe } from "~/types/api-types/recipe";
import { Recipe, RecipeIngredient } from "~/types/api-types/recipe";
import { parseIngredientText } from "~/composables/recipes";
type SplitIngredients = {
firstHalf: string[];
secondHalf: string[];
};
export default defineComponent({
components: {
RecipeTimeCard,
Expand All @@ -77,32 +67,17 @@ export default defineComponent({
},
},
setup(props) {
const splitIngredients = computed<SplitIngredients>(() => {
const firstHalf = props.recipe.recipeIngredient
?.slice(0, Math.ceil(props.recipe.recipeIngredient.length / 2))
.map((ingredient) => {
return parseIngredientText(ingredient, props.recipe?.settings?.disableAmount || false);
});
const secondHalf = props.recipe.recipeIngredient
?.slice(Math.ceil(props.recipe.recipeIngredient.length / 2))
.map((ingredient) => {
return parseIngredientText(ingredient, props.recipe?.settings?.disableAmount || false);
});
return {
firstHalf: firstHalf || [],
secondHalf: secondHalf || [],
};
});
const hasNotes = computed(() => {
return props.recipe.notes && props.recipe.notes.length > 0;
});
function parseText(ingredient: RecipeIngredient) {
return parseIngredientText(ingredient, props.recipe.settings?.disableAmount || false);
}
return {
hasNotes,
splitIngredients,
parseText,
parseIngredientText,
};
},
Expand Down Expand Up @@ -136,6 +111,12 @@ export default defineComponent({
.print-container {
display: none;
background-color: white;
}
/* Makes all text solid black */
.print-container,
.print-container >>> * {
opacity: 1 !important;
color: black !important;
}
Expand All @@ -152,7 +133,11 @@ p {
.ingredient-grid {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 1rem;
grid-gap: 0.5rem;
}
.ingredient-title {
grid-column: 1 / span 2;
}
ul {
Expand Down

0 comments on commit 92ccbae

Please sign in to comment.