feat(ui): Favoriten-Liste, Dismiss-from-Recent, Inline-Rename, Lucide-Icons
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m31s

Homepage:
- Neue Sektion "Deine Favoriten" über "Zuletzt hinzugefügt" (alphabetisch
  sortiert, lädt wenn Profil aktiv ist; versteckt sonst)
- Jede Karte in "Zuletzt hinzugefügt" hat jetzt oben-rechts ein X-Icon
  zum Ausblenden. Das Rezept selbst bleibt in der DB — nur die
  Anzeige in der Recent-Liste wird per recipe.hidden_from_recent = 1
  unterdrückt. Section versteckt sich, wenn die Liste leer wird.

DB:
- Neue Migration 004_recipe_hidden_from_recent.sql (+Index)
- listFavoritesForProfile in search-local.ts (ORDER BY title NOCASE)
- setRecipeHiddenFromRecent in actions.ts

API:
- GET /api/recipes/favorites?profile_id=X
- PATCH /api/recipes/[id] akzeptiert jetzt title und/oder
  hidden_from_recent (Zod-Schema mit refine)

Rezept-Detail:
- Titel ist jetzt inline editierbar: kleines Stift-Icon rechts neben
  H1. Click öffnet Input, Enter speichert (PATCH), Escape bricht ab.
  Kein location.reload() mehr.
- RecipeView bekommt neuen Snippet-Prop titleSlot für Title-Override.
- Neue Aktionsreihenfolge:
  Zeile 1: Favorit | Wunschliste | Drucken
  Zeile 2: Heute gekocht | Löschen
  (Umbenennen ist jetzt am Titel statt in der Leiste.)

Icons (lucide-svelte, neues Dep):
- Emoji-Icons durch Lucide-SVGs ersetzt auf Startseite, Header,
  Rezept-Detail, Wunschliste, Header-Dropdown:
    🍽️→Heart/Utensils, ⚙️→Settings, 🥘→CookingPot, 🌐→Globe,
    ♥/♡→Heart(filled), 🖨→Printer, ✎→Pencil, 🗑→Trash2, ✓→Check,
    🍳→ChefHat, X→X
- Header-Brand-Badge auf Mobile behält sein 🍳 (ist im ::after-Pseudo,
  Lucide käme da nicht sauber rein).
- SearchLoader-Emojis bleiben — die sind Teil der Animations-Charme.

Tests: 99/99 grün (bestehend), Typecheck 0 Fehler.
This commit is contained in:
hsiegeln
2026-04-17 18:57:17 +02:00
parent 657d006441
commit 7cac02de5a
12 changed files with 420 additions and 87 deletions

View File

@@ -1,13 +1,16 @@
<script lang="ts">
import { onMount } from 'svelte';
import { CookingPot, Globe, X } from 'lucide-svelte';
import type { SearchHit } from '$lib/server/recipes/search-local';
import type { WebHit } from '$lib/server/search/searxng';
import { randomQuote } from '$lib/quotes';
import SearchLoader from '$lib/components/SearchLoader.svelte';
import { profileStore } from '$lib/client/profile.svelte';
let query = $state('');
let quote = $state('');
let recent = $state<SearchHit[]>([]);
let favorites = $state<SearchHit[]>([]);
let hits = $state<SearchHit[]>([]);
let webHits = $state<WebHit[]>([]);
let searching = $state(false);
@@ -15,11 +18,34 @@
let webError = $state<string | null>(null);
let searchedFor = $state<string | null>(null);
onMount(async () => {
quote = randomQuote();
async function loadRecent() {
const res = await fetch('/api/recipes/search');
const body = await res.json();
recent = body.hits;
}
async function loadFavorites(profileId: number) {
const res = await fetch(`/api/recipes/favorites?profile_id=${profileId}`);
if (!res.ok) {
favorites = [];
return;
}
const body = await res.json();
favorites = body.hits;
}
onMount(() => {
quote = randomQuote();
void loadRecent();
});
$effect(() => {
const active = profileStore.active;
if (!active) {
favorites = [];
return;
}
void loadFavorites(active.id);
});
let debounceTimer: ReturnType<typeof setTimeout> | null = null;
@@ -82,6 +108,17 @@
void runSearch(q);
}
async function dismissFromRecent(recipeId: number, e: MouseEvent) {
e.preventDefault();
e.stopPropagation();
recent = recent.filter((r) => r.id !== recipeId);
await fetch(`/api/recipes/${recipeId}`, {
method: 'PATCH',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ hidden_from_recent: true })
});
}
const activeSearch = $derived(query.trim().length > 3);
</script>
@@ -112,7 +149,7 @@
{#if r.image_path}
<img src={`/images/${r.image_path}`} alt="" loading="lazy" />
{:else}
<div class="placeholder">🥘</div>
<div class="placeholder"><CookingPot size={36} /></div>
{/if}
<div class="card-body">
<div class="title">{r.title}</div>
@@ -125,10 +162,12 @@
{/each}
</ul>
<a class="web-more" href={`/search/web?q=${encodeURIComponent(query.trim())}`}>
🌐 Im Internet weitersuchen
<Globe size={18} strokeWidth={2} /> Im Internet weitersuchen
</a>
{:else if searchedFor === query.trim()}
<p class="muted no-local-msg">Keine lokalen Rezepte für „{searchedFor}" — Ergebnisse aus dem Internet:</p>
<p class="muted no-local-msg">
Keine lokalen Rezepte für „{searchedFor}" — Ergebnisse aus dem Internet:
</p>
{#if webSearching}
<SearchLoader scope="web" />
{:else if webError}
@@ -141,7 +180,7 @@
{#if w.thumbnail}
<img src={w.thumbnail} alt="" loading="lazy" />
{:else}
<div class="placeholder">🍽️</div>
<div class="placeholder"><CookingPot size={36} /></div>
{/if}
<div class="card-body">
<div class="title">{w.title}</div>
@@ -156,29 +195,62 @@
{/if}
{/if}
</section>
{:else if recent.length > 0}
<section class="recent">
<h2>Zuletzt hinzugefügt</h2>
<ul class="cards">
{#each recent as r (r.id)}
<li>
<a href={`/recipes/${r.id}`} class="card">
{#if r.image_path}
<img src={`/images/${r.image_path}`} alt="" loading="lazy" />
{:else}
<div class="placeholder">🥘</div>
{/if}
<div class="card-body">
<div class="title">{r.title}</div>
{#if r.source_domain}
<div class="domain">{r.source_domain}</div>
{:else}
{#if profileStore.active && favorites.length > 0}
<section class="listing">
<h2>Deine Favoriten</h2>
<ul class="cards">
{#each favorites as r (r.id)}
<li class="card-wrap">
<a href={`/recipes/${r.id}`} class="card">
{#if r.image_path}
<img src={`/images/${r.image_path}`} alt="" loading="lazy" />
{:else}
<div class="placeholder"><CookingPot size={36} /></div>
{/if}
</div>
</a>
</li>
{/each}
</ul>
</section>
<div class="card-body">
<div class="title">{r.title}</div>
{#if r.source_domain}
<div class="domain">{r.source_domain}</div>
{/if}
</div>
</a>
</li>
{/each}
</ul>
</section>
{/if}
{#if recent.length > 0}
<section class="listing">
<h2>Zuletzt hinzugefügt</h2>
<ul class="cards">
{#each recent as r (r.id)}
<li class="card-wrap">
<a href={`/recipes/${r.id}`} class="card">
{#if r.image_path}
<img src={`/images/${r.image_path}`} alt="" loading="lazy" />
{:else}
<div class="placeholder"><CookingPot size={36} /></div>
{/if}
<div class="card-body">
<div class="title">{r.title}</div>
{#if r.source_domain}
<div class="domain">{r.source_domain}</div>
{/if}
</div>
</a>
<button
class="dismiss"
aria-label="Aus Zuletzt-hinzugefügt entfernen"
onclick={(e) => dismissFromRecent(r.id, e)}
>
<X size={16} strokeWidth={2.5} />
</button>
</li>
{/each}
</ul>
</section>
{/if}
{/if}
<style>
@@ -219,10 +291,10 @@
outline-offset: 1px;
}
.results,
.recent {
.listing {
margin-top: 1.5rem;
}
.recent h2 {
.listing h2 {
font-size: 1.05rem;
color: #444;
margin: 0 0 0.75rem;
@@ -249,6 +321,9 @@
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 0.75rem;
}
.card-wrap {
position: relative;
}
.card {
display: block;
background: white;
@@ -270,7 +345,7 @@
background: #eef3ef;
display: grid;
place-items: center;
font-size: 2rem;
color: #8fb097;
}
.card-body {
padding: 0.6rem 0.75rem 0.75rem;
@@ -285,8 +360,41 @@
color: #888;
margin-top: 0.25rem;
}
.dismiss {
position: absolute;
top: 0.4rem;
right: 0.4rem;
width: 28px;
height: 28px;
border-radius: 999px;
border: 0;
background: rgba(255, 255, 255, 0.9);
color: #444;
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
opacity: 0;
transition: opacity 0.1s;
}
.card-wrap:hover .dismiss,
.dismiss:focus-visible {
opacity: 1;
}
@media (max-width: 640px) {
.dismiss {
opacity: 1; /* always visible on touch devices */
}
}
.dismiss:hover {
background: #fff;
color: #c53030;
}
.web-more {
display: inline-block;
display: inline-flex;
align-items: center;
gap: 0.4rem;
margin-top: 1rem;
padding: 0.7rem 1.1rem;
border: 1px solid #b7d6c2;