From a50497426b0471f19ff8ba459ce4ba6712f2db60 Mon Sep 17 00:00:00 2001 From: Anika Raemer Date: Sat, 13 Sep 2025 08:41:07 +0200 Subject: [PATCH] Style recipe list --- frontend/src/App.css | 16 --------- .../src/components/recipes/RecipeListItem.tsx | 28 ++++++++++++--- .../src/components/recipes/RecipeListPage.tsx | 35 +++++++++++-------- 3 files changed, 45 insertions(+), 34 deletions(-) diff --git a/frontend/src/App.css b/frontend/src/App.css index e9a992d..ae4e583 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -8,22 +8,6 @@ @apply p-4 flex; } - .sidebar { - @apply min-w-[16rem] bg-gray-50 p-4 w-1/3 border-r pr-4; - } - - .sidebar-title { - @apply text-blue-900 font-bold mb-2; - } - - .sidebar-link { - @apply block bg-white rounded-xl shadow-md overflow-hidden hover:shadow-lg transition w-full px-4 py-2 hover:bg-blue-100 - } - - .sidebar-item-text { - @apply font-semibold text-blue-400; - } - .content-title{ @apply text-3xl font-black mb-8 text-blue-400; } diff --git a/frontend/src/components/recipes/RecipeListItem.tsx b/frontend/src/components/recipes/RecipeListItem.tsx index cfe0d9c..1f892f4 100644 --- a/frontend/src/components/recipes/RecipeListItem.tsx +++ b/frontend/src/components/recipes/RecipeListItem.tsx @@ -3,18 +3,38 @@ import { Link } from "react-router-dom" type RecipeListItemProps = { title: string targetPath: string + imageUrl?: string } /** * List item for the recipe list. Selecting an item navigates to the recipe */ -export default function RecipeListItem({ title, targetPath: path}: RecipeListItemProps) { + +export default function RecipeListItem({ title, targetPath, imageUrl }: RecipeListItemProps) { return ( -

{title}

+ {/* Optional recipe image */} + {imageUrl ? ( + {title} + ) + :
+ +
+ } + + {/* Card content */} +
+

+ {title} +

+
) } diff --git a/frontend/src/components/recipes/RecipeListPage.tsx b/frontend/src/components/recipes/RecipeListPage.tsx index dc672bc..327750e 100644 --- a/frontend/src/components/recipes/RecipeListPage.tsx +++ b/frontend/src/components/recipes/RecipeListPage.tsx @@ -14,7 +14,7 @@ export default function RecipeListPage() { useEffect(() => { const loadRecipeList = async () => { try { - // Fetch recipe data when editing an existing one + // Fetch recipe list console.log("loading recipe list") const data = await fetchRecipeList() setRecipeList(data) @@ -26,20 +26,27 @@ export default function RecipeListPage() { }, []) if(!recipeList) { return
Unable to load recipes1
} - // @todo find a better representation than an oldfashioned sidebar return ( -
-

Recipes

- -
- {recipeList.map((recipe) => ( - - ))} + /*Contaier spanning entire screen used to center content horizontally */ +
+ {/* Container defining the maximum width of the content */} +
+ {/* Header - remains in position when scrolling */} +
+

Recipes

+ +
+ {/*Content - List of recipe cards */} +
+ {recipeList.map((recipe) => ( + + ))} +
) -} +}