IngredientRow rendert eine einzelne editierbare Zutat-Zeile. DraftIng und DraftStep sind jetzt in recipe-editor-types.ts, damit Parent und Sub-Components auf dieselbe Form referenzieren. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
130 lines
2.9 KiB
Svelte
130 lines
2.9 KiB
Svelte
<script lang="ts">
|
|
import { Trash2, ChevronUp, ChevronDown } from 'lucide-svelte';
|
|
import type { DraftIng } from './recipe-editor-types';
|
|
|
|
type Props = {
|
|
ing: DraftIng;
|
|
idx: number;
|
|
total: number;
|
|
onmove: (dir: -1 | 1) => void;
|
|
onremove: () => void;
|
|
};
|
|
|
|
let { ing, idx, total, onmove, onremove }: Props = $props();
|
|
</script>
|
|
|
|
<li class="ing-row">
|
|
<div class="move">
|
|
<button
|
|
class="move-btn"
|
|
type="button"
|
|
aria-label="Zutat nach oben"
|
|
disabled={idx === 0}
|
|
onclick={() => onmove(-1)}
|
|
>
|
|
<ChevronUp size={14} strokeWidth={2.5} />
|
|
</button>
|
|
<button
|
|
class="move-btn"
|
|
type="button"
|
|
aria-label="Zutat nach unten"
|
|
disabled={idx === total - 1}
|
|
onclick={() => onmove(1)}
|
|
>
|
|
<ChevronDown size={14} strokeWidth={2.5} />
|
|
</button>
|
|
</div>
|
|
<input class="qty" type="text" bind:value={ing.qty} placeholder="Menge" aria-label="Menge" />
|
|
<input class="unit" type="text" bind:value={ing.unit} placeholder="Einheit" aria-label="Einheit" />
|
|
<input class="name" type="text" bind:value={ing.name} placeholder="Zutat" aria-label="Zutat" />
|
|
<input class="note" type="text" bind:value={ing.note} placeholder="Notiz" aria-label="Notiz" />
|
|
<button class="del" type="button" aria-label="Zutat entfernen" onclick={onremove}>
|
|
<Trash2 size={16} strokeWidth={2} />
|
|
</button>
|
|
</li>
|
|
|
|
<style>
|
|
.ing-row {
|
|
display: grid;
|
|
grid-template-columns: 28px 70px 70px 1fr 1fr 40px;
|
|
gap: 0.35rem;
|
|
align-items: center;
|
|
}
|
|
.move {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 2px;
|
|
}
|
|
.move-btn {
|
|
width: 28px;
|
|
height: 20px;
|
|
border: 1px solid #cfd9d1;
|
|
background: white;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
color: #555;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 0;
|
|
}
|
|
.move-btn:hover:not(:disabled) {
|
|
background: #f4f8f5;
|
|
}
|
|
.move-btn:disabled {
|
|
opacity: 0.3;
|
|
cursor: not-allowed;
|
|
}
|
|
.ing-row input {
|
|
padding: 0.5rem 0.55rem;
|
|
border: 1px solid #cfd9d1;
|
|
border-radius: 8px;
|
|
font-size: 0.9rem;
|
|
min-height: 38px;
|
|
font-family: inherit;
|
|
min-width: 0;
|
|
}
|
|
.del {
|
|
width: 40px;
|
|
height: 40px;
|
|
border: 1px solid #f1b4b4;
|
|
background: white;
|
|
color: #c53030;
|
|
border-radius: 8px;
|
|
cursor: pointer;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.del:hover {
|
|
background: #fdf3f3;
|
|
}
|
|
@media (max-width: 560px) {
|
|
.ing-row {
|
|
grid-template-columns: 28px 70px 1fr 40px;
|
|
grid-template-areas:
|
|
'move qty name del'
|
|
'move unit unit del'
|
|
'note note note note';
|
|
}
|
|
.ing-row .move {
|
|
grid-area: move;
|
|
}
|
|
.ing-row .qty {
|
|
grid-area: qty;
|
|
}
|
|
.ing-row .unit {
|
|
grid-area: unit;
|
|
}
|
|
.ing-row .name {
|
|
grid-area: name;
|
|
}
|
|
.ing-row .note {
|
|
grid-area: note;
|
|
}
|
|
.ing-row .del {
|
|
grid-area: del;
|
|
}
|
|
}
|
|
</style>
|