Skip to content

Commit 14efe17

Browse files
Refactor baked-goods renderer and update styles
Clean up and refactor baked goods rendering and minor style tweaks. Move Holiday Specials to the top of section order, remove duplicate entry, and rename archived -> seasoned across the renderer for clearer semantics; only show past flavors for non-holiday sections. Simplify some formatting/whitespace in renderNewProducts and add clarifying comments. CSS: add will-change rule and a small comment to improve rendering/scroll animation behavior.
1 parent 5a4a86a commit 14efe17

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

main.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ document.addEventListener('DOMContentLoaded', () => {
7878
reviews.forEach((el) => observer.observe(el));
7979
});
8080

81-
// Function for the endless cycle in Home Page
82-
function renderNewProducts() {
81+
// -------------------------------------- Function for the endless cycle in Home Page ----------------------------------------------------------
82+
function renderNewProducts(){
8383
const scrollContainer = document.querySelector('.bago_card_box');
84-
if (!scrollContainer) return;
84+
if(!scrollContainer) return;
8585

8686
const newProducts = Object.entries(productData).filter(([id, product]) => {
8787
return product.new === true;
@@ -110,7 +110,7 @@ function renderNewProducts() {
110110
// Run the function when the page loads
111111
document.addEventListener('DOMContentLoaded', renderNewProducts);
112112

113-
// ─── Baked Goods Page Renderer ────────────────────────────────────────────────
113+
// ------------------------------------------ Baked Goods Page Renderer -------------------------------------------------------------
114114
// Reads productData and builds all sections in bakedGoods.html automatically.
115115
// To add/remove a product, just update products.js — no HTML changes needed.
116116

@@ -119,11 +119,10 @@ function renderBakedGoods(){
119119
if(!container) return; // Only runs on bakedGoods.html
120120

121121
// --- Section definitions: order on the page + display titles ---
122-
// ongoingSubtitle: optional label shown above the active products in that section
123122
const sections = [
123+
{category: '_holiday-specials', title: 'Holiday Specials', ongoingSubtitle: null},
124124
{category: '_sourdough', title: 'Sourdough Breads', ongoingSubtitle: null},
125125
{category: '_other-treats', title: 'Our Other Treats', ongoingSubtitle: null},
126-
{category: '_holiday-specials', title: 'Holiday Specials', ongoingSubtitle: null},
127126
{category: '_cookie', title: 'Cookies', ongoingSubtitle: "Cookies of the Month"},
128127
];
129128

@@ -137,17 +136,17 @@ function renderBakedGoods(){
137136

138137
if(sectionProducts.length === 0) return; // Skip empty sections
139138

140-
// Separate ongoing (purchasable) from archived (display-only)
139+
// Separate ongoing (purchasable) from seasoned (display-only)
141140
const ongoing = sectionProducts.filter(([, p]) => p.ongoing);
142-
const archived = sectionProducts.filter(([, p]) => !p.ongoing);
141+
const seasoned = sectionProducts.filter(([, p]) => !p.ongoing);
143142

144143
// For holiday specials, only show the section if there are active items
145144
if(section.category === '_holiday-specials' && ongoing.length === 0) return;
146145

147146
// Helper: build a single <li> card
148147
function buildCard(id, product){
149148
const isOngoing = product.ongoing;
150-
const multipleChoices = !!(product.sizes || product.toppings);
149+
const multipleChoices = !!(product.sizes || product.toppings); // Checks to see if the product has either of the variables
151150

152151
let priceHTML = '';
153152
if(isOngoing){
@@ -185,21 +184,21 @@ function renderBakedGoods(){
185184
</li>`;
186185
}
187186

188-
// Optional subtitle above the ongoing products
187+
// Subtitle above the ongoing products
189188
const ongoingSubtitleHTML = section.ongoingSubtitle
190189
? `<h4 class="container_sub_title">${section.ongoingSubtitle}</h4>`
191190
: '';
192191

193192
const ongoingCardsHTML = ongoing.map(([id, p]) => buildCard(id, p)).join('');
194193

195-
// Archived / past flavors block
196-
let archivedHTML = '';
197-
if(archived.length > 0){
198-
const archivedCards = archived.map(([id, p]) => buildCard(id, p)).join('');
199-
archivedHTML = `
194+
// Past flavors block
195+
let seasonedHTML = '';
196+
if(seasoned.length > 0 && !(section.category === '_holiday-specials')){
197+
const seasonedCards = seasoned.map(([id, p]) => buildCard(id, p)).join('');
198+
seasonedHTML = `
200199
<div class="section_divider"><hr></div>
201200
<h4 class="container_sub_title cookies_title_pf">Past Flavors</h4>
202-
<ul class="card_content">${archivedCards}</ul>`;
201+
<ul class="card_content">${seasonedCards}</ul>`;
203202
}
204203

205204
// Divider between sections — only if something has already been rendered
@@ -213,7 +212,7 @@ function renderBakedGoods(){
213212
<h3 class="container_title">${section.title}</h3>
214213
${ongoingSubtitleHTML}
215214
<ul class="card_content">${ongoingCardsHTML}</ul>
216-
${archivedHTML}
215+
${seasonedHTML}
217216
</div>`;
218217
});
219218

style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ body{
343343

344344
/* Calculate animation duration based on content length */
345345
animation: horizontal-scroll 80s linear infinite;
346+
346347
will-change: transform; /* Makes sure that this part of the page keeps being loeaded and doesn't stop due to recourse optimization*/
347348
}
348349
.bago_card_container .bago_card_box:hover{

0 commit comments

Comments
 (0)