From 73b805546fd849f76e5458691dcdbd279712c0fb Mon Sep 17 00:00:00 2001 From: Anika Raemer Date: Sat, 20 Sep 2025 17:00:27 +0200 Subject: [PATCH] move the recipe list's toolbar to a component of its own --- .../src/components/recipes/RecipeEditor.tsx | 4 +-- .../src/components/recipes/RecipeListPage.tsx | 25 ++++---------- .../components/recipes/RecipeListToolbar.tsx | 34 +++++++++++++++++++ 3 files changed, 42 insertions(+), 21 deletions(-) create mode 100644 frontend/src/components/recipes/RecipeListToolbar.tsx diff --git a/frontend/src/components/recipes/RecipeEditor.tsx b/frontend/src/components/recipes/RecipeEditor.tsx index 040fc5b..56cdd2b 100644 --- a/frontend/src/components/recipes/RecipeEditor.tsx +++ b/frontend/src/components/recipes/RecipeEditor.tsx @@ -94,7 +94,7 @@ export default function RecipeEditor({ recipe, onSave, onCancel }: RecipeEditorP placeholder="1" value={draft.servings.amount} onChange={e => { - let tempServings = draft.servings + const tempServings = draft.servings tempServings.amount = Number(e.target.value) setDraft({...draft, servings: tempServings}) }} @@ -104,7 +104,7 @@ export default function RecipeEditor({ recipe, onSave, onCancel }: RecipeEditorP placeholder="Persons" value={draft.servings.unit} onChange={e => { - let tempServings = draft.servings + const tempServings = draft.servings tempServings.unit = e.target.value setDraft({...draft, servings: tempServings}) }} diff --git a/frontend/src/components/recipes/RecipeListPage.tsx b/frontend/src/components/recipes/RecipeListPage.tsx index f086f1d..cd08be9 100644 --- a/frontend/src/components/recipes/RecipeListPage.tsx +++ b/frontend/src/components/recipes/RecipeListPage.tsx @@ -5,6 +5,7 @@ import { fetchRecipeList } from "../../api/recipePoint" import { useNavigate } from "react-router-dom" import { getRecipeAddUrl, getRecipeDetailUrl } from "../../routes" import SearchField from "../basics/SearchField" +import RecipeListToolbar from "./RecipeListToolbar" /** * Displays a list of recipes in a sidebar layout. @@ -44,25 +45,11 @@ export default function RecipeListPage() { {/* Header - remains in position when scrolling */}

Recipes

-
- {/* Label: left-aligned on medium+ screens, full-width on small screens */} -
- -
- - {/* Search + Add button container: right-aligned on medium+ screens */} -
-
- -
- -
-
+
{/*Content - List of recipe cards */}
diff --git a/frontend/src/components/recipes/RecipeListToolbar.tsx b/frontend/src/components/recipes/RecipeListToolbar.tsx new file mode 100644 index 0000000..99d23ef --- /dev/null +++ b/frontend/src/components/recipes/RecipeListToolbar.tsx @@ -0,0 +1,34 @@ +import SearchField from "../basics/SearchField" + +/** + * Toolbar for RecipeListPage containing searchfield, add recipe button and number of recipes + */ +type RecepeListToolbarProps = { + onSearchStringChanged: (searchString : string) => void + onAddClicked: () => void + numberOfRecipes : number +} + +export default function RecipeListToolbar({onSearchStringChanged, onAddClicked, numberOfRecipes} : RecepeListToolbarProps){ + return ( +
+ {/* Label: left-aligned on medium+ screens, full-width on small screens */} +
+ +
+ + {/* Search + Add button container: right-aligned on medium+ screens */} +
+
+ +
+ +
+
+ ) +} \ No newline at end of file