Add HorizontalInputGroupLayout Component
This commit is contained in:
parent
c188639b1c
commit
0b549c878c
4 changed files with 44 additions and 14 deletions
|
|
@ -29,6 +29,14 @@
|
|||
@apply text-gray-600;
|
||||
}
|
||||
|
||||
|
||||
/* errors */
|
||||
.error-text {
|
||||
@apply text-sm text-red-600;
|
||||
}
|
||||
|
||||
/* @todo replace by components!
|
||||
|
||||
/* background */
|
||||
.app-bg {
|
||||
@apply flex items-center w-screen justify-center min-h-screen bg-gray-50;
|
||||
|
|
@ -42,15 +50,6 @@
|
|||
@apply p-6 max-w-2xl mx-auto;
|
||||
}
|
||||
|
||||
/* errors */
|
||||
.error-text {
|
||||
@apply text-sm text-red-600;
|
||||
}
|
||||
|
||||
/* @todo replace by components!
|
||||
.horizontal-input-group {
|
||||
@apply flex gap-2 mb-2 items-center;
|
||||
}
|
||||
|
||||
/* containers */
|
||||
.circular-container {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
import type {ReactNode} from "react";
|
||||
import clsx from "clsx";
|
||||
|
||||
type HorizontalInputGroupLayoutProps = {
|
||||
/** Content to render inside the header */
|
||||
children: ReactNode;
|
||||
|
||||
/** Optional additional Tailwind classes */
|
||||
className?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* A layout for horizontally aligning inputs and buttons - designed for pages with several input items in a row
|
||||
* @param children Children of the layout, i.e., inputs
|
||||
* @param className Optional additional styles
|
||||
* @constructor
|
||||
*/
|
||||
export default function HorizontalInputGroupLayout({children, className = ""}: HorizontalInputGroupLayoutProps) {
|
||||
return (
|
||||
<div
|
||||
className={clsx(
|
||||
"flex gap-2 mb-2 items-center",
|
||||
className
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ import {ButtonType} from "../basics/BasicButtonDefinitions.ts";
|
|||
import {IngredientListEditor} from "./IngredientListEditor.tsx";
|
||||
import type {IngredientGroupModel} from "../../models/IngredientGroupModel.ts";
|
||||
import type {IngredientModel} from "../../models/IngredientModel.ts";
|
||||
import HorizontalInputGroupLayout from "../basics/HorizontalInputGroupLayout.tsx";
|
||||
|
||||
type IngredientGroupListItemProps = {
|
||||
/** The list item's index */
|
||||
|
|
@ -33,7 +34,7 @@ export default function IngredientGroupListItem({
|
|||
}
|
||||
return (
|
||||
<div key={index} className="pb-4 border-b border-gray-400 mb-4">
|
||||
<div className="horizontal-input-group columns-2">
|
||||
<HorizontalInputGroupLayout className="columns-2">
|
||||
<input
|
||||
placeholder="Titel (Optional)"
|
||||
value={ingredientGroupModel.title}
|
||||
|
|
@ -44,7 +45,7 @@ export default function IngredientGroupListItem({
|
|||
text={"Gruppe entfernen"}
|
||||
buttonType={ButtonType.DarkButton}
|
||||
/>
|
||||
</div>
|
||||
</HorizontalInputGroupLayout>
|
||||
<IngredientListEditor
|
||||
ingredients={ingredientGroupModel.ingredientList}
|
||||
onChange={list => updateIngredientList(index, list)}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {Plus, X} from "lucide-react"
|
|||
import type {IngredientModel} from "../../models/IngredientModel"
|
||||
import Button from "../basics/Button"
|
||||
import {ButtonType} from "../basics/BasicButtonDefinitions"
|
||||
import HorizontalInputGroupLayout from "../basics/HorizontalInputGroupLayout.tsx";
|
||||
|
||||
|
||||
type IngredientListEditorProps = {
|
||||
|
|
@ -54,7 +55,7 @@ export function IngredientListEditor({ingredients, onChange}: IngredientListEdit
|
|||
return (
|
||||
<div>
|
||||
{ingredients.map((ing, index) => (
|
||||
<div key={index} className="horizontal-input-group">
|
||||
<HorizontalInputGroupLayout key={index}>
|
||||
<input
|
||||
type="number"
|
||||
placeholder="Menge"
|
||||
|
|
@ -80,7 +81,7 @@ export function IngredientListEditor({ingredients, onChange}: IngredientListEdit
|
|||
icon={X}
|
||||
buttonType={ButtonType.DarkButton}
|
||||
/>
|
||||
</div>
|
||||
</HorizontalInputGroupLayout>
|
||||
))}
|
||||
<Button
|
||||
onClick={handleAdd}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue