feat: implement Phase 5 Swipe Discovery Carousel #5
+13
-13
@@ -24,7 +24,7 @@ Dieses Dokument enthält den aktuellen Entwicklungsstand und detaillierte Aufgab
|
|||||||
- Admin-Erweiterung für Step-Videos
|
- Admin-Erweiterung für Step-Videos
|
||||||
- Fullscreen Cooking-Mode Overlay (mit Lenis scroll lock)
|
- Fullscreen Cooking-Mode Overlay (mit Lenis scroll lock)
|
||||||
- Timers & Looping Video Players pro Zubereitungsschritt
|
- Timers & Looping Video Players pro Zubereitungsschritt
|
||||||
- [ ] **Phase 5: Sleek Swipe Discovery (Personalisiertes Empfehlungskarussell)**
|
- [x] **Phase 5: Sleek Swipe Discovery (Personalisiertes Empfehlungskarussell)**
|
||||||
- Touch-Swipe-Karussell direkt auf index.php (unter Landing-Page)
|
- Touch-Swipe-Karussell direkt auf index.php (unter Landing-Page)
|
||||||
- Filteralgorithmus nach Benutzer-Ernährungszielen
|
- Filteralgorithmus nach Benutzer-Ernährungszielen
|
||||||
- Mikro-Animationen & Quick-Save Funktion
|
- Mikro-Animationen & Quick-Save Funktion
|
||||||
@@ -123,18 +123,18 @@ Ein immersiver Kochmodus, der Anwendern Schritt-für-Schritt durch die Zubereitu
|
|||||||
### 🎡 Phase 5: Sleek Swipe Discovery (Empfehlungskarussell)
|
### 🎡 Phase 5: Sleek Swipe Discovery (Empfehlungskarussell)
|
||||||
Ein hochgradig interaktives, touch-freundliches Karussell direkt auf der Startseite, das Nutzern Rezepte basierend auf ihren Zielen empfiehlt.
|
Ein hochgradig interaktives, touch-freundliches Karussell direkt auf der Startseite, das Nutzern Rezepte basierend auf ihren Zielen empfiehlt.
|
||||||
|
|
||||||
- [ ] **Karussell-Architektur & Integration**
|
- [x] **Karussell-Architektur & Integration**
|
||||||
- [ ] Touch-Swipe Karussell Container direkt unter der Landing-Page (vor `#basics`) auf `index.php` einbetten
|
- [x] Touch-Swipe Karussell Container direkt unter der Landing-Page (vor `#basics`) auf `index.php` einbetten
|
||||||
- [ ] CSS-Klammern (`clamp()`) für responsive Skalierung der Karten
|
- [x] CSS-Klammern (`clamp()`) für responsive Skalierung der Karten
|
||||||
- [ ] Flüssiges Einblenden per Scroll-Reveal (`reveal-target`) mit Anbindung an `LenisSmoothScroll`
|
- [x] Flüssiges Einblenden per Scroll-Reveal (`reveal-target`) mit Anbindung an `LenisSmoothScroll`
|
||||||
- [ ] **Personalisiertes Goal-Matching**
|
- [x] **Personalisiertes Goal-Matching**
|
||||||
- [ ] Falls der Benutzer eingeloggt ist, sein Ernährungsziel aus den Firebase-Profildaten abrufen
|
- [x] Falls der Benutzer eingeloggt ist, sein Ernährungsziel aus den Firebase-Profildaten abrufen
|
||||||
- [ ] Rezepte dynamisch filtern (z.B. High-Protein Rezepte bei Ziel "Muskelaufbau", Low-Carb Rezepte bei Ziel "Abnehmen")
|
- [x] Rezepte dynamisch filtern (z.B. High-Protein Rezepte bei Ziel "Muskelaufbau", Low-Carb Rezepte bei Ziel "Abnehmen")
|
||||||
- [ ] Personalisierte "Für dich empfohlen"-Badge auf den Karten anzeigen
|
- [x] Personalisierte "Für dich empfohlen"-Badge auf den Karten anzeigen
|
||||||
- [ ] **Mikro-Interaktionen & Quick-Save**
|
- [x] **Mikro-Interaktionen & Quick-Save**
|
||||||
- [ ] Touch-Gesten-Unterstützung (Wischen zum Blättern mit sanftem Trägheits-Feedback)
|
- [x] Touch-Gesten-Unterstützung (Wischen zum Blättern mit sanftem Trägheits-Feedback)
|
||||||
- [ ] Quick-Save Button direkt auf den Karussell-Karten (Herzeffekt mit direktem Firebase Firestore Sync)
|
- [x] Quick-Save Button direkt auf den Karussell-Karten (Herzeffekt mit direktem Firebase Firestore Sync)
|
||||||
- [ ] Hover-Reveal-Effekte für Rezeptdetails (Zutaten-Vorschau oder Kochzeit-Highlight schiebt sich weich hoch)
|
- [x] Hover-Reveal-Effekte für Rezeptdetails (Zutaten-Vorschau oder Kochzeit-Highlight schiebt sich weich hoch)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -2213,3 +2213,134 @@ body.nav-open { overflow: hidden; }
|
|||||||
opacity: 0.3;
|
opacity: 0.3;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ── 23. PHASE 5: SWIPE DISCOVERY CAROUSEL ────────────────────── */
|
||||||
|
.swipe-discovery {
|
||||||
|
padding: clamp(2rem, 5vw, 4rem) 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: var(--surface-2);
|
||||||
|
}
|
||||||
|
.swipe-discovery__header {
|
||||||
|
margin-bottom: 2.5rem;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
padding: 0 var(--grid-margin);
|
||||||
|
}
|
||||||
|
.eyebrow-goal {
|
||||||
|
color: var(--color-accent-gold);
|
||||||
|
font-weight: 700;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.15em;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
.swipe-track {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--grid-gap);
|
||||||
|
padding: 0 var(--grid-margin) 2rem var(--grid-margin);
|
||||||
|
overflow-x: auto;
|
||||||
|
scroll-snap-type: x mandatory;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
scrollbar-width: none;
|
||||||
|
cursor: grab;
|
||||||
|
}
|
||||||
|
.swipe-track::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.swipe-track.active {
|
||||||
|
cursor: grabbing;
|
||||||
|
}
|
||||||
|
.swipe-card {
|
||||||
|
flex: 0 0 clamp(280px, 60vw, 400px);
|
||||||
|
scroll-snap-align: center;
|
||||||
|
position: relative;
|
||||||
|
border-radius: var(--radius);
|
||||||
|
overflow: hidden;
|
||||||
|
background: var(--surface);
|
||||||
|
box-shadow: var(--shadow);
|
||||||
|
transition: transform 0.4s var(--ease-out-expo);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.swipe-card__image {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 4/3;
|
||||||
|
overflow: hidden;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.swipe-card__image img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
transition: transform 0.6s var(--ease-out-expo);
|
||||||
|
}
|
||||||
|
.swipe-card:hover .swipe-card__image img {
|
||||||
|
transform: scale(1.05);
|
||||||
|
}
|
||||||
|
.swipe-card__image .btn-favorite {
|
||||||
|
position: absolute;
|
||||||
|
top: 1rem;
|
||||||
|
right: 1rem;
|
||||||
|
z-index: 10;
|
||||||
|
background: rgba(255, 255, 255, 0.9);
|
||||||
|
border: none;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
cursor: pointer;
|
||||||
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||||
|
transition: transform 0.3s var(--ease-overshoot), background 0.3s;
|
||||||
|
}
|
||||||
|
[data-theme="dark"] .swipe-card__image .btn-favorite {
|
||||||
|
background: rgba(0, 0, 0, 0.6);
|
||||||
|
}
|
||||||
|
.swipe-card__image .btn-favorite svg {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
color: var(--muted);
|
||||||
|
transition: fill 0.3s, color 0.3s;
|
||||||
|
}
|
||||||
|
.swipe-card__image .btn-favorite.active svg {
|
||||||
|
fill: var(--color-terracotta);
|
||||||
|
color: var(--color-terracotta);
|
||||||
|
}
|
||||||
|
.swipe-card__body {
|
||||||
|
padding: 1.5rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
background: var(--surface);
|
||||||
|
position: relative;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
.swipe-card__badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.4rem;
|
||||||
|
background: var(--accent-soft);
|
||||||
|
color: var(--color-accent-gold);
|
||||||
|
padding: 0.25rem 0.75rem;
|
||||||
|
border-radius: 20px;
|
||||||
|
font-size: 0.7rem;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
.swipe-card__body h3 {
|
||||||
|
font-size: clamp(1.2rem, 2vw, 1.5rem);
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
.swipe-card__body h3 a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
.swipe-card__body h3 a::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -341,6 +341,18 @@ include __DIR__ . '/partials/head.php';
|
|||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<!-- Swipe Discovery Carousel -->
|
||||||
|
<section class="swipe-discovery reveal-target" id="swipe-discovery" style="display: none;" data-section-name="<?php echo $lang === 'de' ? 'Für Dich' : 'For You'; ?>" aria-label="<?php echo $lang === 'de' ? 'Persönliche Empfehlungen' : 'Personal Recommendations'; ?>">
|
||||||
|
<div class="section-header section-header--stack swipe-discovery__header">
|
||||||
|
<p class="eyebrow eyebrow-goal" id="swipeGoalEyebrow"></p>
|
||||||
|
<h2 id="swipeGoalTitle"><?php echo $lang === 'de' ? 'Empfohlen für dich' : 'Recommended for you'; ?></h2>
|
||||||
|
<p id="swipeGoalSub"><?php echo $lang === 'de' ? 'Basierend auf deinem Ernährungsziel' : 'Based on your dietary goal'; ?></p>
|
||||||
|
</div>
|
||||||
|
<div class="swipe-track" id="swipeTrack">
|
||||||
|
<!-- Cards inserted by JS -->
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<!-- Discover Shell: Search + Stats + Tags | Featured -->
|
<!-- Discover Shell: Search + Stats + Tags | Featured -->
|
||||||
<section class="discover-shell reveal-target" id="basics" data-section-name="<?php echo $lang === 'de' ? 'Entdecken' : 'Discover'; ?>" aria-label="<?php echo $lang === 'de' ? 'Rezepte entdecken' : 'Discover recipes'; ?>">
|
<section class="discover-shell reveal-target" id="basics" data-section-name="<?php echo $lang === 'de' ? 'Entdecken' : 'Discover'; ?>" aria-label="<?php echo $lang === 'de' ? 'Rezepte entdecken' : 'Discover recipes'; ?>">
|
||||||
<div class="discover-shell__main">
|
<div class="discover-shell__main">
|
||||||
@@ -495,6 +507,29 @@ include __DIR__ . '/partials/head.php';
|
|||||||
|
|
||||||
<?php include __DIR__ . '/partials/footer.php'; ?>
|
<?php include __DIR__ . '/partials/footer.php'; ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Expose recipe data for JS filtering
|
||||||
|
$recipesJson = json_encode(array_values(array_map(function($r) use ($lang) {
|
||||||
|
return [
|
||||||
|
'slug' => $r['slug'],
|
||||||
|
'title' => $r['title'],
|
||||||
|
'hero' => $r['hero'],
|
||||||
|
'difficulty' => $r['difficulty'],
|
||||||
|
'total_time' => (int)($r['total_time'] ?? 0),
|
||||||
|
'url' => '/recipe.php?slug=' . urlencode($r['slug']) . '&lang=' . $lang,
|
||||||
|
'tags' => $r['tags'] ?? [],
|
||||||
|
'category' => $r['category'] ?? ''
|
||||||
|
];
|
||||||
|
}, $localizedAll)));
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
const indexRecipeBank = <?php echo $recipesJson; ?>;
|
||||||
|
const i18nGoal = {
|
||||||
|
'weight_loss': '<?php echo $lang === "de" ? "Abnehmen / Low-Carb" : "Weight Loss / Low-Carb"; ?>',
|
||||||
|
'muscle_gain': '<?php echo $lang === "de" ? "Muskelaufbau / High-Protein" : "Muscle Gain / High-Protein"; ?>',
|
||||||
|
'healthy': '<?php echo $lang === "de" ? "Gesund & Ausgewogen" : "Healthy & Balanced"; ?>'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- ╔══════════════════════════════════════════════════════════════╗
|
<!-- ╔══════════════════════════════════════════════════════════════╗
|
||||||
║ JAVASCRIPT — Preloader, Lenis, GSAP Stage, Section Indicator ║
|
║ JAVASCRIPT — Preloader, Lenis, GSAP Stage, Section Indicator ║
|
||||||
@@ -807,5 +842,125 @@ include __DIR__ . '/partials/head.php';
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ───────────────────────────────────────────────────────────────
|
||||||
|
7. SWIPE DISCOVERY CAROUSEL
|
||||||
|
─────────────────────────────────────────────────────────────── */
|
||||||
|
var swipeSec = document.getElementById('swipe-discovery');
|
||||||
|
var swipeTrack = document.getElementById('swipeTrack');
|
||||||
|
var swipeEyebrow = document.getElementById('swipeGoalEyebrow');
|
||||||
|
|
||||||
|
function renderSwipeCarousel(recipes, goalLabel) {
|
||||||
|
if (!swipeSec || !swipeTrack || recipes.length === 0) return;
|
||||||
|
|
||||||
|
swipeSec.style.display = 'block';
|
||||||
|
if (goalLabel) {
|
||||||
|
swipeEyebrow.textContent = goalLabel;
|
||||||
|
} else {
|
||||||
|
swipeEyebrow.textContent = '<?php echo $lang === "de" ? "Entdecken" : "Discover"; ?>';
|
||||||
|
}
|
||||||
|
|
||||||
|
swipeTrack.innerHTML = '';
|
||||||
|
recipes.slice(0, 8).forEach(function(recipe) {
|
||||||
|
var card = document.createElement('article');
|
||||||
|
card.className = 'swipe-card';
|
||||||
|
card.innerHTML = `
|
||||||
|
<a href="${recipe.url}" class="swipe-card__image">
|
||||||
|
<img src="${recipe.hero}" alt="${recipe.title}" loading="lazy">
|
||||||
|
<button class="btn-favorite" data-slug="${recipe.slug}" aria-label="Save to favorites" onclick="event.preventDefault(); event.stopPropagation();">
|
||||||
|
<svg viewBox="0 0 24 24" stroke="currentColor" fill="none">
|
||||||
|
<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"></path>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</a>
|
||||||
|
<div class="swipe-card__body">
|
||||||
|
<div class="swipe-card__badge">
|
||||||
|
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>
|
||||||
|
<?php echo $lang === "de" ? "Für dich empfohlen" : "Recommended for you"; ?>
|
||||||
|
</div>
|
||||||
|
<h3><a href="${recipe.url}">${recipe.title}</a></h3>
|
||||||
|
<div class="meta">
|
||||||
|
<span>⏱ ${recipe.total_time} min</span>
|
||||||
|
<span>🙂 ${recipe.difficulty}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
swipeTrack.appendChild(card);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Re-bind favorite states using existing global userFavSlugs sync
|
||||||
|
if (typeof updateHeartStates === 'function') {
|
||||||
|
updateHeartStates();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add horizontal scroll mouse drag
|
||||||
|
let isDown = false;
|
||||||
|
let startX;
|
||||||
|
let scrollLeft;
|
||||||
|
|
||||||
|
swipeTrack.addEventListener('mousedown', (e) => {
|
||||||
|
isDown = true;
|
||||||
|
swipeTrack.classList.add('active');
|
||||||
|
startX = e.pageX - swipeTrack.offsetLeft;
|
||||||
|
scrollLeft = swipeTrack.scrollLeft;
|
||||||
|
});
|
||||||
|
swipeTrack.addEventListener('mouseleave', () => {
|
||||||
|
isDown = false;
|
||||||
|
swipeTrack.classList.remove('active');
|
||||||
|
});
|
||||||
|
swipeTrack.addEventListener('mouseup', () => {
|
||||||
|
isDown = false;
|
||||||
|
swipeTrack.classList.remove('active');
|
||||||
|
});
|
||||||
|
swipeTrack.addEventListener('mousemove', (e) => {
|
||||||
|
if (!isDown) return;
|
||||||
|
e.preventDefault();
|
||||||
|
const x = e.pageX - swipeTrack.offsetLeft;
|
||||||
|
const walk = (x - startX) * 2;
|
||||||
|
swipeTrack.scrollLeft = scrollLeft - walk;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hook into auth state
|
||||||
|
window.addEventListener('DOMContentLoaded', function() {
|
||||||
|
if (window.auth && window.db) {
|
||||||
|
window.auth.onAuthStateChanged(function(user) {
|
||||||
|
if (user) {
|
||||||
|
window.db.collection('users').doc(user.uid).get()
|
||||||
|
.then(function(doc) {
|
||||||
|
if (doc.exists) {
|
||||||
|
var goal = doc.data().goal;
|
||||||
|
var filtered = indexRecipeBank;
|
||||||
|
|
||||||
|
if (goal === 'weight_loss') {
|
||||||
|
filtered = indexRecipeBank.filter(r =>
|
||||||
|
r.tags.some(t => t.toLowerCase().includes('low-carb') || t.toLowerCase().includes('diet')) ||
|
||||||
|
(r.category && r.category.toLowerCase().includes('salad'))
|
||||||
|
);
|
||||||
|
} else if (goal === 'muscle_gain') {
|
||||||
|
filtered = indexRecipeBank.filter(r =>
|
||||||
|
r.tags.some(t => t.toLowerCase().includes('high-protein') || t.toLowerCase().includes('meat') || t.toLowerCase().includes('fleisch'))
|
||||||
|
);
|
||||||
|
} else if (goal === 'healthy') {
|
||||||
|
filtered = indexRecipeBank.filter(r =>
|
||||||
|
r.tags.some(t => t.toLowerCase().includes('vegetarian') || t.toLowerCase().includes('healthy'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fallback if empty
|
||||||
|
if (filtered.length === 0) filtered = indexRecipeBank;
|
||||||
|
|
||||||
|
renderSwipeCarousel(filtered, i18nGoal[goal] || null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Default unauthenticated view
|
||||||
|
renderSwipeCarousel(indexRecipeBank, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
renderSwipeCarousel(indexRecipeBank, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user