-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecipe.html
More file actions
184 lines (168 loc) · 12.4 KB
/
recipe.html
File metadata and controls
184 lines (168 loc) · 12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Recipe Generator - Genie ✨</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="styles.css">
<style>
body { font-family: 'Inter', sans-serif; }
.spinner { animation: spin 1s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.mic-listening { animation: pulse-mic 1.5s infinite; } @keyframes pulse-mic { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.7); } 70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(236, 72, 153, 0); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fadeIn 0.5s ease-out forwards; }
</style>
</head>
<body class="bg-gray-900 text-white">
<div id="modal-container" class="hidden"><div class="modal-backdrop"></div><div class="modal-content bg-gray-800 rounded-2xl shadow-2xl w-11/12 md:w-1/2 lg:w-1/3 p-6 border border-gray-700"><div class="flex justify-between items-center mb-4"><h2 id="modal-title" class="text-2xl font-bold"></h2><button id="modal-close-btn" class="text-gray-400 hover:text-white">×</button></div><div id="modal-body"></div></div></div>
<div id="toast" class="fixed bottom-[-100px] left-1/2 -translate-x-1/2 px-6 py-3 bg-green-500 text-white font-semibold rounded-full shadow-lg transition-all duration-500"></div>
<button id="voice-btn" class="fixed bottom-8 right-8 w-16 h-16 bg-gradient-to-r from-purple-500 to-pink-500 rounded-full flex items-center justify-center shadow-2xl text-white transform hover:scale-110 transition-transform z-30" title="Activate Voice Command"><svg id="mic-icon" xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="22"></line></svg></button>
<div class="min-h-screen p-4 sm:p-8">
<main class="max-w-5xl mx-auto space-y-12">
<header><div class="flex justify-between items-center mb-6"><div><h1 class="text-4xl sm:text-5xl font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-purple-400 to-pink-500 mb-1">Genie ✨</h1><p class="text-gray-400">Your home's vibe manager. Scene sorted.</p></div><button id="settings-btn" class="p-3 bg-gray-800 rounded-full hover:bg-gray-700 transition" title="Settings"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 0 2.12l-.15.1a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.38a2 2 0 0 0-.73-2.73l-.15-.1a2 2 0 0 1 0-2.12l.15-.1a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg></button></div>
<nav class="flex flex-wrap items-center justify-center gap-2 rounded-full bg-gray-800/50 p-3 sm:gap-4 sm:space-x-6">
<a href="index.html" class="rounded-full px-4 py-2 text-sm font-medium text-gray-300 transition hover:bg-gray-700">Mood-buddy</a>
<a href="recipe.html" class="rounded-full px-4 py-2 text-sm font-medium text-white bg-pink-600">Recipes</a>
<a href="chai-time.html" class="rounded-full px-4 py-2 text-sm font-medium text-gray-300 transition hover:bg-gray-700">Chai Time</a>
<a href="expenses.html" class="rounded-full px-4 py-2 text-sm font-medium text-gray-300 transition hover:bg-gray-700">Expenses</a>
<button id="logout-btn" class="rounded-full px-4 py-2 text-sm font-medium text-red-400 transition hover:bg-red-500 hover:text-white">Logout</button>
</nav>
</header>
<section id="recipe-module"><div class="bg-gray-800/50 backdrop-blur-lg border border-gray-700 rounded-2xl shadow-lg p-6 animate-fade-in"><h2 class="text-2xl font-semibold mb-4">Leftover Scene Sorted 🍳</h2><form id="recipe-form" class="flex flex-col sm:flex-row gap-3"><input id="ingredients-input" type="text" placeholder="e.g., paneer, pyaaz, Shimla mirch..." class="flex-grow p-3 bg-gray-700 border border-gray-600 rounded-lg focus:ring-2 focus:ring-pink-500" /><button id="surprise-btn" type="button" class="bg-amber-500 text-white font-bold p-3 rounded-lg hover:bg-amber-600 transition" title="Surprise Me!">💡</button><button id="generate-btn" type="submit" class="flex items-center justify-center bg-gradient-to-r from-purple-500 to-pink-500 text-white font-bold py-3 px-6 rounded-lg shadow-md hover:scale-105 transition"><span id="btn-text">Cook Up a Vibe</span><div id="btn-spinner" class="hidden flex items-center"><div class="w-5 h-5 border-2 rounded-full spinner mr-2 border-t-transparent"></div>Cooking...</div></button></form><p id="error-message" class="text-red-400 mt-2 text-center font-medium"></p></div><div id="content-container" class="mt-8"></div></section>
<footer class="text-center text-gray-500 pt-8 pb-16"><p>© 2025 Genie ✨ | Your Home's Vibe Manager</p><p class="mt-2 text-sm">Made with 💜 for a better home experience</p></footer>
</main>
</div>
<script src="script.js"></script>
<script type="module" src="app-auth.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
// Global elements
const voiceBtn = document.getElementById('voice-btn');
const settingsBtn = document.getElementById('settings-btn');
const modalContainer = document.getElementById('modal-container');
const modalCloseBtn = document.getElementById('modal-close-btn');
const modalTitle = document.getElementById('modal-title');
const modalBody = document.getElementById('modal-body');
const toastEl = document.getElementById('toast');
// Toast notification function
function showToast(message, isSuccess = true) {
if (!toastEl) return;
toastEl.textContent = message;
toastEl.className = toastEl.className.replace(/bg-green-500|bg-red-500/, '');
toastEl.classList.add(isSuccess ? 'bg-green-500' : 'bg-red-500');
toastEl.classList.remove('bottom-[-100px]');
toastEl.classList.add('bottom-8');
setTimeout(() => {
toastEl.classList.remove('bottom-8');
toastEl.classList.add('bottom-[-100px]');
}, 3000);
}
// Settings modal logic
if (settingsBtn && modalContainer && modalCloseBtn) {
settingsBtn.addEventListener('click', () => {
modalTitle.textContent = "Settings";
modalBody.innerHTML = `<p>Welcome to your settings panel. More options coming soon!</p>`;
modalContainer.classList.remove('hidden');
});
const closeModal = () => {
modalContainer.classList.add('hidden');
};
modalCloseBtn.addEventListener('click', closeModal);
modalContainer.querySelector('.modal-backdrop').addEventListener('click', closeModal);
}
// Recipe page logic
if (document.getElementById('recipe-module')) {
const recipeForm = document.getElementById('recipe-form');
const ingredientsInput = document.getElementById('ingredients-input');
const generateBtn = document.getElementById('generate-btn');
const surpriseBtn = document.getElementById('surprise-btn');
const contentContainer = document.getElementById('content-container');
const errorMessage = document.getElementById('error-message');
// Submit handler for recipe form
recipeForm.addEventListener('submit', (e) => {
e.preventDefault();
if (ingredientsInput.value.trim() === '') {
errorMessage.textContent = 'Please enter at least one ingredient.';
return;
}
errorMessage.textContent = '';
generateBtn.querySelector('#btn-text').classList.add('hidden');
generateBtn.querySelector('#btn-spinner').classList.remove('hidden');
generateBtn.disabled = true;
setTimeout(() => {
const ingredients = ingredientsInput.value;
contentContainer.innerHTML = `
<div class="bg-gray-800/50 backdrop-blur-lg border border-gray-700 rounded-2xl p-6 animate-fade-in">
<h3 class="text-2xl font-bold text-pink-400 mb-3">Vibe-a-licious ${ingredients.split(',')[0]} Dish!</h3>
<p class="text-gray-300 mb-4">Here is a delicious recipe based on your ingredients: <strong>${ingredients}</strong>.</p>
<ol class="list-decimal list-inside space-y-2 text-gray-400">
<li>Preheat your oven and prepare your ingredients.</li>
<li>Combine the wet and dry ingredients in a large bowl.</li>
<li>Cook for 20-25 minutes or until golden brown.</li>
<li>Serve hot and enjoy the vibe!</li>
</ol>
</div>`;
generateBtn.querySelector('#btn-text').classList.remove('hidden');
generateBtn.querySelector('#btn-spinner').classList.add('hidden');
generateBtn.disabled = false;
}, 2000);
});
// Surprise ingredients button
surpriseBtn.addEventListener('click', () => {
const surpriseIngredients = ['Chicken, ginger, garlic', 'Tomato, onion, capsicum', 'Paneer, cream, spices', 'Potato, peas, carrots'];
const randomIndex = Math.floor(Math.random() * surpriseIngredients.length);
ingredientsInput.value = surpriseIngredients[randomIndex];
showToast('Ingredients surprised!');
});
// Voice recognition logic
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
if (SpeechRecognition) {
const recognition = new SpeechRecognition();
let isListening = false;
recognition.lang = 'en-IN';
recognition.interimResults = false;
recognition.maxAlternatives = 1;
voiceBtn.addEventListener('click', () => {
if (isListening) {
recognition.stop();
return;
}
recognition.start();
});
recognition.onstart = () => {
isListening = true;
voiceBtn.classList.add('mic-listening');
showToast("Listening for ingredients...");
};
recognition.onresult = (event) => {
const transcript = event.results[0][0].transcript;
ingredientsInput.value = transcript.replace(/\.$/, '');
showToast(`Genie heard: ${transcript}`);
generateBtn.click();
};
recognition.onerror = (event) => {
let errMessage = `Error: ${event.error}. Please try again.`;
if (event.error === 'not-allowed') errMessage = "Mic access denied. Please allow it in browser settings.";
else if (event.error === 'no-speech') errMessage = "No speech was detected. Please try again.";
showToast(errMessage, false);
};
recognition.onend = () => {
isListening = false;
voiceBtn.classList.remove('mic-listening');
};
} else {
voiceBtn.addEventListener('click', () => {
showToast("Sorry, your browser doesn't support voice commands.", false);
});
}
}
// You can add other page-specific logic here similarly, condensed into this single DOMContentLoaded event
});
</script>
</body>
</html>