Refactoring
This commit is contained in:
parent
34bbaa9df4
commit
9b53f6e676
11 changed files with 501 additions and 515 deletions
|
|
@ -21,15 +21,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-title {
|
.content-title {
|
||||||
@apply text-3xl font-black mb-8 text-blue-900;
|
@apply text-3xl font-black pb-6 text-blue-900;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section-heading {
|
.section-heading {
|
||||||
@apply text-xl font-bold mb-2;
|
@apply text-xl font-bold pb-2 pt-4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subsection-heading {
|
.subsection-heading {
|
||||||
@apply font-semibold mb-2 mt-4;
|
@apply font-semibold pb-2 pt-4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* icons */
|
/* icons */
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
/* buttons */
|
/* buttons */
|
||||||
.basic-button {
|
.basic-button {
|
||||||
@apply px-4 py-2 shadow-md rounded-lg whitespace-nowrap;
|
@apply px-4 py-2 shadow-md rounded-lg whitespace-nowrap disabled:opacity-50 disabled:cursor-not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
.default-button-bg {
|
.default-button-bg {
|
||||||
|
|
@ -105,7 +105,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.ingredient-group-card {
|
.ingredient-group-card {
|
||||||
@apply py-4 border-b border-gray-400;
|
@apply pb-4 border-b border-gray-400;
|
||||||
}
|
}
|
||||||
|
|
||||||
.circular-container {
|
.circular-container {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import {defaultIconSize} from "./SvgIcon";
|
import {defaultIconSize} from "./SvgIcon";
|
||||||
import { ButtonType, type BasicButtonProps } from "./BasicButtonDefinitions";
|
import {type BasicButtonProps, ButtonType} from "./BasicButtonDefinitions";
|
||||||
|
|
||||||
type ButtonProps = BasicButtonProps & {
|
type ButtonProps = BasicButtonProps & {
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
|
disabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -14,12 +15,14 @@ export default function Button({
|
||||||
text,
|
text,
|
||||||
buttonType = ButtonType.DefaultButton,
|
buttonType = ButtonType.DefaultButton,
|
||||||
className = "",
|
className = "",
|
||||||
|
disabled = false,
|
||||||
...props
|
...props
|
||||||
}: ButtonProps) {
|
}: ButtonProps) {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className={`basic-button bg-primary-button-bg ${buttonType.backgroundColor} ${buttonType.textColor} ${className}`}
|
className={`basic-button bg-primary-button-bg ${buttonType.backgroundColor} ${buttonType.textColor} ${className}`}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
|
disabled={disabled}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
type NumberedListItemProps = {
|
type NumberedListItemProps = {
|
||||||
/** Number to be displayed in front of text */
|
/** Index of the element. Index + 1 is displayed in circle */
|
||||||
elementNumber: number;
|
index: number;
|
||||||
/** List item text */
|
/** List item text */
|
||||||
text: string;
|
text: string;
|
||||||
}
|
}
|
||||||
|
|
@ -10,11 +10,11 @@ type NumberedListItemProps = {
|
||||||
* @param elementNumber Number to be displayed
|
* @param elementNumber Number to be displayed
|
||||||
* @param text Text to be displayed
|
* @param text Text to be displayed
|
||||||
*/
|
*/
|
||||||
export function NumberedListItem({elementNumber, text}: NumberedListItemProps) {
|
export function NumberedListItem({index, text}: NumberedListItemProps) {
|
||||||
return <li className="flex items-start gap-4">
|
return <li className="flex items-start gap-4">
|
||||||
{/* Step number circle */}
|
{/* Step number circle */}
|
||||||
<div className="circular-container">
|
<div className="circular-container">
|
||||||
{elementNumber}
|
{index + 1}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Step text */}
|
{/* Step text */}
|
||||||
|
|
|
||||||
|
|
@ -34,20 +34,20 @@ export function IngredientGroupListEditor({ ingredientGroupList, onChange }: Ing
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{/* remove bottom margin from this headings the group card has a top padding */}
|
<h2 className="section-heading">Zutaten</h2>
|
||||||
<h3 className="subsection-heading" >Ingredient Groups</h3>
|
<div>
|
||||||
{ingredientGroupList.map((ingGrp, index) => (
|
{ingredientGroupList.map((ingGrp, index) => (
|
||||||
<div key={index} className="ingredient-group-card mb-4">
|
<div key={index} className="ingredient-group-card mb-4">
|
||||||
<div className="horizontal-input-group columns-2">
|
<div className="horizontal-input-group columns-2">
|
||||||
<input
|
<input
|
||||||
className="input-field"
|
className="input-field"
|
||||||
placeholder="Group title (Optional)"
|
placeholder="Titel (Optional)"
|
||||||
value={ingGrp.title}
|
value={ingGrp.title}
|
||||||
onChange={e => handleUpdate(index, "title", e.target.value)}
|
onChange={e => handleUpdate(index, "title", e.target.value)}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => handleRemove(index)}
|
onClick={() => handleRemove(index)}
|
||||||
text={"Remove Group"}
|
text={"Gruppe entfernen"}
|
||||||
buttonType={ButtonType.DarkButton}
|
buttonType={ButtonType.DarkButton}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -57,30 +57,13 @@ export function IngredientGroupListEditor({ ingredientGroupList, onChange }: Ing
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
</div>
|
||||||
<Button
|
<Button
|
||||||
onClick={handleAdd}
|
onClick={handleAdd}
|
||||||
icon={Plus}
|
icon={Plus}
|
||||||
text={"Add Ingredient Group"}
|
text={"Gruppe hinzufügen"}
|
||||||
buttonType={ButtonType.PrimaryButton}
|
buttonType={ButtonType.PrimaryButton}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="primary-button mt-4"
|
|
||||||
onClick={handleAdd}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="flex col-2 gap-2 -ml-1"
|
|
||||||
>
|
|
||||||
<SvgIcon
|
|
||||||
icon={Icon.Plus}
|
|
||||||
color={"text-gray-600"}
|
|
||||||
/>
|
|
||||||
Add Ingredient Group
|
|
||||||
</div>
|
|
||||||
</button>*/
|
|
||||||
|
|
@ -30,19 +30,18 @@ export function IngredientListEditor({ ingredients, onChange }: IngredientListEd
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h3 className="subsection-heading">Ingredients</h3>
|
|
||||||
{ingredients.map((ing, index) => (
|
{ingredients.map((ing, index) => (
|
||||||
<div key={index} className="horizontal-input-group">
|
<div key={index} className="horizontal-input-group">
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
className="input-field"
|
className="input-field"
|
||||||
placeholder="Amount"
|
placeholder="Menge"
|
||||||
value={ing.amount}
|
value={ing.amount}
|
||||||
onChange={e => handleUpdate(index, "amount", e.target.value)}
|
onChange={e => handleUpdate(index, "amount", e.target.value)}
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
className="input-field w-20"
|
className="input-field w-20"
|
||||||
placeholder="Unit"
|
placeholder="Einheit"
|
||||||
value={ing.unit ?? ""}
|
value={ing.unit ?? ""}
|
||||||
onChange={e => handleUpdate(index, "unit", e.target.value)}
|
onChange={e => handleUpdate(index, "unit", e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
|
@ -62,7 +61,7 @@ export function IngredientListEditor({ ingredients, onChange }: IngredientListEd
|
||||||
<Button
|
<Button
|
||||||
onClick={handleAdd}
|
onClick={handleAdd}
|
||||||
icon={Plus}
|
icon={Plus}
|
||||||
text={"Add Ingredient"}
|
text={"Zutat hinzufügen"}
|
||||||
buttonType={ButtonType.PrimaryButton}
|
buttonType={ButtonType.PrimaryButton}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,14 @@
|
||||||
* Desktop editor using drag-and-drop via @dnd-kit
|
* Desktop editor using drag-and-drop via @dnd-kit
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {closestCenter, DndContext, PointerSensor, useSensor, useSensors,} from "@dnd-kit/core";
|
||||||
DndContext,
|
import {arrayMove, SortableContext, verticalListSortingStrategy,} from "@dnd-kit/sortable";
|
||||||
closestCenter,
|
|
||||||
PointerSensor,
|
|
||||||
useSensor,
|
|
||||||
useSensors,
|
|
||||||
} from "@dnd-kit/core";
|
|
||||||
import {
|
|
||||||
arrayMove,
|
|
||||||
SortableContext,
|
|
||||||
verticalListSortingStrategy,
|
|
||||||
} from "@dnd-kit/sortable";
|
|
||||||
import type {InstructionStepModel} from "../../models/InstructionStepModel";
|
import type {InstructionStepModel} from "../../models/InstructionStepModel";
|
||||||
import {InstructionStepDesktopListItem} from "./InstructionStepDesktopListItem";
|
import {InstructionStepDesktopListItem} from "./InstructionStepDesktopListItem";
|
||||||
import { instructionStepListEditorMethods } from "./InstructionStepListEditor";
|
|
||||||
import Button from "../basics/Button";
|
import Button from "../basics/Button";
|
||||||
import {Plus} from "lucide-react";
|
import {Plus} from "lucide-react";
|
||||||
import {ButtonType} from "../basics/BasicButtonDefinitions";
|
import {ButtonType} from "../basics/BasicButtonDefinitions";
|
||||||
|
import {instructionStepListEditorMethods} from "./InstructionStepListEditorMethods.ts";
|
||||||
|
|
||||||
type InstructionStepListDesktopEditorProps = {
|
type InstructionStepListDesktopEditorProps = {
|
||||||
instructionStepList: InstructionStepModel[];
|
instructionStepList: InstructionStepModel[];
|
||||||
|
|
@ -55,7 +45,7 @@ export function InstructionStepListDesktopEditor({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h3 className="subsection-heading mb-3">Zubereitung</h3>
|
<h2 className="section-heading mb-2">Zubereitung</h2>
|
||||||
<DndContext sensors={sensors} collisionDetection={closestCenter} onDragEnd={handleDragEnd}>
|
<DndContext sensors={sensors} collisionDetection={closestCenter} onDragEnd={handleDragEnd}>
|
||||||
<SortableContext
|
<SortableContext
|
||||||
items={instructionStepList.map((i) => i.internalId)}
|
items={instructionStepList.map((i) => i.internalId)}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
* - Common functionality for adding, removing, and updating steps is centralized.
|
* - Common functionality for adding, removing, and updating steps is centralized.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useState, useEffect } from "react";
|
import {useEffect, useState} from "react";
|
||||||
import type {InstructionStepModel} from "../../models/InstructionStepModel";
|
import type {InstructionStepModel} from "../../models/InstructionStepModel";
|
||||||
import {InstructionStepListDesktopEditor} from "./InstructionStepListDesktopEditor";
|
import {InstructionStepListDesktopEditor} from "./InstructionStepListDesktopEditor";
|
||||||
import {InstructionStepListMobileEditor} from "./InstructionStepListMobileEditor";
|
import {InstructionStepListMobileEditor} from "./InstructionStepListMobileEditor";
|
||||||
|
|
@ -45,42 +45,3 @@ export function InstructionStepListEditor({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* ======= Shared hook for common logic =======
|
|
||||||
*
|
|
||||||
* Provides add/remove/update functionality used by both mobile and desktop editors.
|
|
||||||
*/
|
|
||||||
export function instructionStepListEditorMethods(
|
|
||||||
instructionStepList: InstructionStepModel[],
|
|
||||||
onChange: (steps: InstructionStepModel[]) => void
|
|
||||||
) {
|
|
||||||
/**
|
|
||||||
* Update the text of a specific step
|
|
||||||
*/
|
|
||||||
const handleUpdate = (index: number, value: string) => {
|
|
||||||
const updated = instructionStepList.map((step, i) =>
|
|
||||||
i === index ? { ...step, text: value } : step
|
|
||||||
);
|
|
||||||
onChange(updated);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a new step at the end
|
|
||||||
*/
|
|
||||||
const handleAdd = () => {
|
|
||||||
onChange([...instructionStepList,
|
|
||||||
{
|
|
||||||
text: "",
|
|
||||||
internalId: crypto.randomUUID() // add internalId required for drag & drop
|
|
||||||
}]);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a step by index
|
|
||||||
*/
|
|
||||||
const handleRemove = (index: number) => {
|
|
||||||
onChange(instructionStepList.filter((_, i) => i !== index));
|
|
||||||
};
|
|
||||||
|
|
||||||
return { handleUpdate, handleAdd, handleRemove };
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
import type {InstructionStepModel} from "../../models/InstructionStepModel.ts";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ======= Shared hook for common logic =======
|
||||||
|
*
|
||||||
|
* Provides add/remove/update functionality used by both mobile and desktop editors.
|
||||||
|
*/
|
||||||
|
export function instructionStepListEditorMethods(
|
||||||
|
instructionStepList: InstructionStepModel[],
|
||||||
|
onChange: (steps: InstructionStepModel[]) => void
|
||||||
|
) {
|
||||||
|
/**
|
||||||
|
* Update the text of a specific step
|
||||||
|
*/
|
||||||
|
const handleUpdate = (index: number, value: string) => {
|
||||||
|
const updated = instructionStepList.map((step, i) =>
|
||||||
|
i === index ? {...step, text: value} : step
|
||||||
|
);
|
||||||
|
onChange(updated);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new step at the end
|
||||||
|
*/
|
||||||
|
const handleAdd = () => {
|
||||||
|
onChange([...instructionStepList,
|
||||||
|
{
|
||||||
|
text: "",
|
||||||
|
internalId: crypto.randomUUID() // add internalId required for drag & drop
|
||||||
|
}]);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a step by index
|
||||||
|
*/
|
||||||
|
const handleRemove = (index: number) => {
|
||||||
|
onChange(instructionStepList.filter((_, i) => i !== index));
|
||||||
|
};
|
||||||
|
|
||||||
|
return {handleUpdate, handleAdd, handleRemove};
|
||||||
|
}
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
import {ArrowDown, ArrowUp, Plus, X} from "lucide-react";
|
import {ArrowDown, ArrowUp, Plus, X} from "lucide-react";
|
||||||
import type {InstructionStepModel} from "../../models/InstructionStepModel";
|
import type {InstructionStepModel} from "../../models/InstructionStepModel";
|
||||||
import Button from "../basics/Button";
|
import Button from "../basics/Button";
|
||||||
import { instructionStepListEditorMethods } from "./InstructionStepListEditor";
|
|
||||||
import {ButtonType} from "../basics/BasicButtonDefinitions";
|
import {ButtonType} from "../basics/BasicButtonDefinitions";
|
||||||
|
import {instructionStepListEditorMethods} from "./InstructionStepListEditorMethods.ts";
|
||||||
|
|
||||||
type InstructionStepListEditorMobileProps = {
|
type InstructionStepListEditorMobileProps = {
|
||||||
instructionStepList: InstructionStepModel[];
|
instructionStepList: InstructionStepModel[];
|
||||||
|
|
@ -32,6 +32,8 @@ export function InstructionStepListMobileEditor({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div>
|
||||||
|
<h2 className="section-heading mb-2">Zubereitung</h2>
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
{instructionStepList.map((step, index) => (
|
{instructionStepList.map((step, index) => (
|
||||||
<div
|
<div
|
||||||
|
|
@ -39,7 +41,7 @@ export function InstructionStepListMobileEditor({
|
||||||
className="flex items-start gap-3 bg-gray-50 rounded-xl p-3 shadow-sm"
|
className="flex items-start gap-3 bg-gray-50 rounded-xl p-3 shadow-sm"
|
||||||
>
|
>
|
||||||
<div className="flex flex-col items-center pt-1">
|
<div className="flex flex-col items-center pt-1">
|
||||||
<div className="w-8 h-8 rounded-full bg-gray-300 flex items-center justify-center text-sm font-semibold text-gray-800">
|
<div className="circular-container">
|
||||||
{index + 1}
|
{index + 1}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col mt-2">
|
<div className="flex flex-col mt-2">
|
||||||
|
|
@ -47,17 +49,19 @@ export function InstructionStepListMobileEditor({
|
||||||
icon={ArrowUp}
|
icon={ArrowUp}
|
||||||
onClick={() => moveStep(index, "up")}
|
onClick={() => moveStep(index, "up")}
|
||||||
buttonType={ButtonType.TransparentButton}
|
buttonType={ButtonType.TransparentButton}
|
||||||
|
disabled={index === 0} // disable if first item
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
icon={ArrowDown}
|
icon={ArrowDown}
|
||||||
onClick={() => moveStep(index, "down")}
|
onClick={() => moveStep(index, "down")}
|
||||||
buttonType={ButtonType.TransparentButton}
|
buttonType={ButtonType.TransparentButton}
|
||||||
|
disabled={index === instructionStepList.length - 1} // disable if last item
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<textarea
|
<textarea
|
||||||
className="input-field w-full min-h-[60px] resize-none overflow-hidden"
|
className="input-field w-full min-h-[120px] resize-none overflow-hidden"
|
||||||
placeholder={`Schritt ${index + 1}`}
|
placeholder={`Schritt ${index + 1}`}
|
||||||
value={step.text}
|
value={step.text}
|
||||||
onChange={(e) => handleUpdate(index, e.target.value)}
|
onChange={(e) => handleUpdate(index, e.target.value)}
|
||||||
|
|
@ -83,5 +87,6 @@ export function InstructionStepListMobileEditor({
|
||||||
className="mt-4"
|
className="mt-4"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ export default function RecipeDetailPage() {
|
||||||
<div className="content-container">
|
<div className="content-container">
|
||||||
{/* Header - remains in position when scrolling */}
|
{/* Header - remains in position when scrolling */}
|
||||||
<div className="sticky-header">
|
<div className="sticky-header">
|
||||||
<h1 className="content-title mb-0">{recipeWorkingCopy.title}</h1>
|
<h1 className="content-title mb-0 pb-0">{recipeWorkingCopy.title}</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Content */}
|
{/* Content */}
|
||||||
|
|
@ -132,7 +132,7 @@ export default function RecipeDetailPage() {
|
||||||
{/* Instructions - @todo add reasonable list delegate component*/}
|
{/* Instructions - @todo add reasonable list delegate component*/}
|
||||||
<ol className="space-y-4">
|
<ol className="space-y-4">
|
||||||
{recipe.instructionStepList.map((step, j) => (
|
{recipe.instructionStepList.map((step, j) => (
|
||||||
<NumberedListItem key={j} elementNumber={j + 1} text={step.text}/>
|
<NumberedListItem key={j} index={j} text={step.text}/>
|
||||||
))}
|
))}
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ export default function RecipeEditor({ recipe, onSave, onCancel }: RecipeEditorP
|
||||||
if (!draft.ingredientGroupList || draft.ingredientGroupList.length === 0) {
|
if (!draft.ingredientGroupList || draft.ingredientGroupList.length === 0) {
|
||||||
newErrors.ingredients = true
|
newErrors.ingredients = true
|
||||||
} else {
|
} else {
|
||||||
let isAnyIngredientListEmpty = draft.ingredientGroupList.some(
|
const isAnyIngredientListEmpty = draft.ingredientGroupList.some(
|
||||||
ingGrp => {
|
ingGrp => {
|
||||||
return !ingGrp.ingredientList || ingGrp.ingredientList.length === 0
|
return !ingGrp.ingredientList || ingGrp.ingredientList.length === 0
|
||||||
}
|
}
|
||||||
|
|
@ -84,23 +84,26 @@ export default function RecipeEditor({ recipe, onSave, onCancel }: RecipeEditorP
|
||||||
if (!recipe) return <div>Oops, there's no recipe in RecipeEditor...</div>
|
if (!recipe) return <div>Oops, there's no recipe in RecipeEditor...</div>
|
||||||
// @todo add handling of images
|
// @todo add handling of images
|
||||||
return (
|
return (
|
||||||
<div className="p-4 gap-10">
|
/*Container spanning entire screen used to center content horizontally */
|
||||||
<h2 className="content-title">
|
<div className="app-bg">
|
||||||
{recipe.id ? "Edit Recipe" : "New Recipe"}
|
{/* Container defining the maximum width of the content */}
|
||||||
</h2>
|
<div className="content-container">
|
||||||
|
<h1 className="content-title border-b-2 border-gray-300">
|
||||||
|
{recipe.id ? "Rezept bearbeiten" : "Neues Rezept"}
|
||||||
|
</h1>
|
||||||
|
|
||||||
{/* Title */}
|
{/* Title */}
|
||||||
<h3 className="subsection-heading">Title</h3>
|
<h2 className="section-heading">Titel</h2>
|
||||||
<input
|
<input
|
||||||
className={`input-field ${errors.title ? "error-text" : ""}`}
|
className={`input-field ${errors.title ? "error-text" : ""}`}
|
||||||
placeholder="Title"
|
placeholder="Titel"
|
||||||
value={draft.title}
|
value={draft.title}
|
||||||
onChange={e => setDraft({...draft, title: e.target.value})}
|
onChange={e => setDraft({...draft, title: e.target.value})}
|
||||||
/>
|
/>
|
||||||
{/* Servings */}
|
{/* Servings */}
|
||||||
<h3 className="subsection-heading">Servings</h3>
|
<h2 className="section-heading">Portionen</h2>
|
||||||
<div className="columns-3 gap-2 flex items-center">
|
<div className="columns-3 gap-2 flex items-center">
|
||||||
<label>For</label>
|
<label>Für</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
className="input-field w-20"
|
className="input-field w-20"
|
||||||
|
|
@ -114,7 +117,7 @@ export default function RecipeEditor({ recipe, onSave, onCancel }: RecipeEditorP
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
className="input-field"
|
className="input-field"
|
||||||
placeholder="Persons"
|
placeholder="Personen"
|
||||||
value={draft.servings.unit}
|
value={draft.servings.unit}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
const tempServings = draft.servings
|
const tempServings = draft.servings
|
||||||
|
|
@ -142,14 +145,15 @@ export default function RecipeEditor({ recipe, onSave, onCancel }: RecipeEditorP
|
||||||
{/* Save Button */}
|
{/* Save Button */}
|
||||||
<Button
|
<Button
|
||||||
onClick={() => handleSave(draft)}
|
onClick={() => handleSave(draft)}
|
||||||
text={"Save"}
|
text={"Speichern"}
|
||||||
buttonType={ButtonType.PrimaryButton}
|
buttonType={ButtonType.PrimaryButton}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => onCancel()}
|
onClick={() => onCancel()}
|
||||||
text={"Cancel"}
|
text={"Abbrechen"}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue