From d54b841148289e094d075a34659763f8ed00f248 Mon Sep 17 00:00:00 2001 From: june Date: Wed, 13 Aug 2025 13:49:15 +1200 Subject: [PATCH] Add ingredient table to recipe view --- src/components/Detail/ImageCarousel.astro | 8 ++-- .../Detail/IngredientTableView.astro | 42 +++++++++++++++++++ src/pages/recipe/[recipeid].astro | 42 ++++++++++--------- src/styles/global.css | 4 +- 4 files changed, 72 insertions(+), 24 deletions(-) create mode 100644 src/components/Detail/IngredientTableView.astro diff --git a/src/components/Detail/ImageCarousel.astro b/src/components/Detail/ImageCarousel.astro index 4f23d3c..8800a17 100644 --- a/src/components/Detail/ImageCarousel.astro +++ b/src/components/Detail/ImageCarousel.astro @@ -1,6 +1,6 @@ --- import client from "@/data/pocketbase"; -const { recipe } = Astro.props +const { class: className, recipe } = Astro.props async function getLink(img: string) { const record = await client.collection("images").getOne(img) @@ -26,8 +26,8 @@ const links = await Promise.all( const b0 = document.getElementById('dec-button') const b1 = document.getElementById('inc-button') - b0.hidden = true - b1.hidden = true + b0!.hidden = true + b1!.hidden = true } function inc() { @@ -45,7 +45,7 @@ const links = await Promise.all( (window as any).dec = dec; -
+
diff --git a/src/components/Detail/IngredientTableView.astro b/src/components/Detail/IngredientTableView.astro new file mode 100644 index 0000000..8d6951c --- /dev/null +++ b/src/components/Detail/IngredientTableView.astro @@ -0,0 +1,42 @@ +--- +// const { ingredients } = Astro.props + +const { class: className, ingredients } = Astro.props +--- + + + + + + + + + + + + + { + ingredients.map(ing => ( + <> + + + + + + + )) + } + +
QuantityUnitFood
{ing.quantity}{ing.unit}{ing.name}
\ No newline at end of file diff --git a/src/pages/recipe/[recipeid].astro b/src/pages/recipe/[recipeid].astro index 0158bd1..0cae90b 100644 --- a/src/pages/recipe/[recipeid].astro +++ b/src/pages/recipe/[recipeid].astro @@ -2,6 +2,7 @@ import client from "@/data/pocketbase"; import SiteLayout from "@/layouts/base"; import ImageCarousel from "@/components/Detail/ImageCarousel"; +import IngredientTableView from "@/components/Detail/IngredientTableView"; const { recipeid } = Astro.params; @@ -9,12 +10,14 @@ const re = await client.collection("recipes").getOne(recipeid ?? "0"); const stepIds = re.steps -const steps = await Promise.all( +let steps = await Promise.all( stepIds.map(async s => await client.collection("steps").getOne(s) ) ) +steps = steps.sort((a, b) => a.index - b.index); + const ingredients = await Promise.all( re.ingredients.map(async s => await client.collection("ingredients").getOne(s) @@ -23,27 +26,28 @@ const ingredients = await Promise.all( --- -
-
- - -

{re.name}

+
+
+ +

{re.name}

+

Ingredients

+
+ +
+ - -
- Quantity - Unit - Food - - { - ingredients.map(ing => ( - {ing.quantity} - {ing.unit} - {ing.name} - )) - } +
+

Steps

+ { steps.map(s => ( +
+

Step {s.index + 1}

+

{s.instruction}

+
+ )) } +
+
diff --git a/src/styles/global.css b/src/styles/global.css index 281ef03..12ec143 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -4,5 +4,7 @@ html { @apply bg-[#1d1f21]; /* @apply bg-[#fafafa]; */ @apply text-white; - @apply font-stretch-condensed; + /* @apply font-; */ + @apply font-sans; + /* font-family: 'SF Pro Display', 'Segoe UI', 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; */ } \ No newline at end of file