-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
306 lines (275 loc) · 10.2 KB
/
Copy pathindex.html
File metadata and controls
306 lines (275 loc) · 10.2 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sweet Crumbs — Artisan Bakery</title>
<link rel="stylesheet" href="style.css" />
<!-- ============================================================
SELF-HEAL SYSTEM
Every actionable element has a unique, descriptive ID/class.
On toggle, selectors swap to "-action-" variants:
============================================================ -->
</head>
<body>
<!-- ===================== NAVIGATION ===================== -->
<nav>
<div class="logo">Sweet<span>Crumbs</span></div>
<!-- Self-Heal Toggle -->
<label
class="heal-toggle"
id="healToggle"
title="Swap actionable selectors to -action- variants"
>
🛡️ Self-Heal
<input type="checkbox" id="healCheck" />
<span class="switch-track"></span>
<span class="heal-badge" id="healBadge">DEFAULT</span>
</label>
<div class="links">
<a href="#menu">Menu</a>
<a href="#about">Our Story</a>
<a href="#reviews">Reviews</a>
<a href="#order">Order</a>
</div>
</nav>
<!-- ===================== HERO ===================== -->
<section class="hero">
<h1>Baked with <em>Love</em>,<br />Served with Joy</h1>
<p>
Handcrafted cakes, pastries & breads made fresh every morning from our
little kitchen to your table.
</p>
<button
id="explore-menu-btn"
onclick="document.getElementById('menu').scrollIntoView()"
>
Explore Menu
</button>
</section>
<!-- ===================== MENU GRID ===================== -->
<section class="menu" id="menu">
<h2 class="section-title">Our Bestsellers</h2>
<p class="section-sub">Freshly baked, always delightful</p>
<div class="menu-grid" id="menuGrid"></div>
</section>
<!-- ===================== ABOUT ===================== -->
<section class="about" id="about">
<div class="img-placeholder">🧁</div>
<div class="text">
<h2>A Pinch of Passion in Every Bite</h2>
<p>
Founded in 2018, Sweet Crumbs started as a weekend hobby and grew into
the neighbourhood's favourite bakery.
</p>
<p>
We source organic flour, free-range eggs, and real butter — because
shortcuts don't belong in a kitchen.
</p>
</div>
</section>
<!-- ===================== TESTIMONIALS ===================== -->
<section class="testimonials" id="reviews">
<h2 class="section-title">What People Say</h2>
<p class="section-sub">Real reviews from real cake lovers</p>
<div class="testimonial-track" id="reviewTrack"></div>
</section>
<!-- ===================== CTA ===================== -->
<section class="cta-section" id="order">
<h2>Craving Something Sweet?</h2>
<p>Order online for same-day delivery — or drop us a message!</p>
<div class="cta-buttons">
<button id="order-now-btn">Order Now →</button>
<button id="contact-us-btn">Contact Us ✉️</button>
</div>
</section>
<!-- ===================== CONTACT MODAL ===================== -->
<div class="modal-overlay" id="modalOverlay">
<div class="modal">
<button id="modal-close-btn">✕</button>
<h2>Get in Touch 💌</h2>
<p class="modal-sub">We'll get back to you within 24 hours.</p>
<form id="contact-form" onsubmit="handleSubmit(event)">
<input
type="text"
class="contact-name-input"
placeholder="Your Name"
required
/>
<input
type="email"
class="contact-email-input"
placeholder="Your Email"
required
/>
<textarea
class="contact-message-input"
placeholder="Tell us what you're looking for…"
required
></textarea>
<button type="submit" id="send-message-btn">Send Message →</button>
<!-- TODO: update id selector -->
</form>
</div>
</div>
<!-- Toast -->
<div class="toast" id="toast">✅ Message sent! We'll be in touch.</div>
<!-- ===================== FOOTER ===================== -->
<footer>© 2026 Sweet Crumbs Bakery. Made with 🤎 and flour.</footer>
<!-- ============================================================
JAVASCRIPT
============================================================ -->
<script>
/* ========== DATA ========== */
const cakes = [
{ emoji: '🎂', name: 'Classic Vanilla', price: '$28' },
{ emoji: '🍫', name: 'Dark Chocolate Fudge', price: '$32' },
{ emoji: '🍓', name: 'Strawberry Dream', price: '$30' },
{ emoji: '🧁', name: 'Red Velvet Cupcakes', price: '$18' },
{ emoji: '🥐', name: 'Butter Croissant', price: '$6' },
{ emoji: '🍰', name: 'Tiramisu Slice', price: '$12' },
];
const reviews = [
{
text: 'Best birthday cake we ever had! The chocolate layers were heavenly.',
author: 'Priya M.',
stars: 5,
},
{
text: 'Their croissants rival anything I had in Paris. Not exaggerating.',
author: 'James L.',
stars: 5,
},
{
text: 'Ordered a custom cake for our anniversary — it was a showstopper!',
author: 'Anita R.',
stars: 5,
},
{
text: 'The red velvet cupcakes are dangerously addictive. Send help.',
author: 'Tom K.',
stars: 4,
},
];
/* ========== RENDER ========== */
function renderMenu() {
document.getElementById('menuGrid').innerHTML = cakes
.map(
(c) => `
<div class="menu-card">
<div class="emoji">${c.emoji}</div>
<h3>${c.name}</h3>
<p class="price">${c.price}</p>
</div>`,
)
.join('');
}
function renderReviews() {
document.getElementById('reviewTrack').innerHTML = reviews
.map(
(r) => `
<div class="testimonial">
<div class="stars">${'★'.repeat(r.stars)}${'☆'.repeat(5 - r.stars)}</div>
<p>"${r.text}"</p>
<div class="author">— ${r.author}</div>
</div>`,
)
.join('');
}
/* ========== MODAL ========== */
const overlay = document.getElementById('modalOverlay');
/** Opens modal — works regardless of which ID the contact button currently has */
function openModal() {
overlay.classList.add('open');
}
function closeModal() {
overlay.classList.remove('open');
}
document
.getElementById('contact-us-btn')
.addEventListener('click', openModal);
document
.getElementById('modal-close-btn')
.addEventListener('click', closeModal);
overlay.addEventListener('click', (e) => {
if (e.target === overlay) closeModal();
});
/* ========== FORM SUBMIT ========== */
function handleSubmit(e) {
e.preventDefault();
closeModal();
e.target.reset();
const toast = document.getElementById('toast');
toast.classList.add('show');
setTimeout(() => toast.classList.remove('show'), 3000);
}
/* ==========================================================
SELF-HEAL ENGINE (v3)
Swaps IDs on buttons and form, classes on inputs.
Pattern: "something-name" ↔ "something-name-action-suffix"
========================================================== */
/**
* Complete mapping of every actionable element.
* type: 'id' swaps the element's id attribute
* type: 'class' swaps the element's class
*/
const selectorMap = [
// --- BUTTONS (swap IDs) ---
{ type: 'id', from: 'send-message-btn', to: 'send-message-action-btn' },
// --- FORM (swap ID) ---
{ type: 'id', from: 'contact-form', to: 'contact-action-form' },
];
const healCheck = document.getElementById('healCheck');
const healToggle = document.getElementById('healToggle');
const healBadge = document.getElementById('healBadge');
healCheck.addEventListener('change', () => {
const healed = healCheck.checked;
// Update pill state
healToggle.classList.toggle('active', healed);
healBadge.textContent = healed ? 'HEALED' : 'DEFAULT';
// Swap every mapped selector
selectorMap.forEach(({ type, from, to }) => {
const oldVal = healed ? from : to;
const newVal = healed ? to : from;
if (type === 'id') {
// Find element by its current ID and swap it
const el = document.getElementById(oldVal);
if (el) el.id = newVal;
}
if (type === 'class') {
// Find element by its current class and swap it
const el = document.querySelector(`.${oldVal}`);
if (el) {
el.classList.remove(oldVal);
el.classList.add(newVal);
}
}
});
// Re-bind event listeners to new IDs
// (since IDs changed, we re-attach click handlers)
const contactBtn = document.getElementById(
healed ? 'contact-us-action-btn' : 'contact-us-btn',
);
const closeBtn = document.getElementById(
healed ? 'modal-close-action-btn' : 'modal-close-btn',
);
if (contactBtn) contactBtn.onclick = openModal;
if (closeBtn) closeBtn.onclick = closeModal;
// Console log — full selector report for test scripts
console.log(
`\n[Self-Heal] Mode: ${healed ? '🛡️ HEALED' : '🔧 DEFAULT'}`,
);
console.log('─'.repeat(50));
selectorMap.forEach(({ type, from, to }) => {
const active = healed ? to : from;
const prefix = type === 'id' ? '#' : '.';
console.log(` ${prefix}${active}`);
});
console.log('─'.repeat(50));
});
/* ========== INIT ========== */
renderMenu();
renderReviews();
</script>
</body>
</html>