Feat: Dynamic gallery page with Fetch API and improved product card layout

Refactor gallery page to dynamically load product data using the Fetch API. This addresses
a SyntaxError from incorrect script loading and updates the page to handle a new
flattened data structure.

- Replaced hardcoded product data with the Fetch API in `gallery-carousel.js`.
- Updated selectors and logic to handle the new data structure.
- Removed conflicting CSS rules for product cards.
- Shortened all `longDescription` fields to 175 characters or less.
- Widened the focused product card for better visibility without vertical scrolling.
- Reduced vertical spacing between elements in product cards (title, description, price, button).
This commit is contained in:
2025-09-08 19:48:27 -05:00
parent 80c6d8866d
commit c5fd50bd35
5 changed files with 554 additions and 591 deletions

View File

@@ -13,8 +13,15 @@
gap: 20px;
}
#product-carousel-feature {
align-items: center;
display: flex;
flex-direction: column;
}
#product-carousel-feature h2 {
font-size: 1.875rem;
width: 50%;
text-align: center;
text-shadow: var(--text-shadow-layered);
color: var(--color-destin-sand);
@@ -35,42 +42,69 @@
}
#product-carousel {
display: flex; /* Flexbox layout for horizontal row */
display: flex;
flex-direction: row; /* Flexbox layout for horizontal row */
gap: 20px; /* Space between product cards */
overflow-x: auto; /* Enable horizontal scrolling */
overflow-x: hidden; /* Changed from 'auto' to 'hidden' */
scroll-behavior: smooth; /* Smooth scrolling for buttons */
padding: 10px; /* Optional padding inside the carousel */
white-space: nowrap; /* Prevent wrapping to a new row */
transform: translateX(4vw);
min-height: 600px;
align-items: center;
}
.product-card {
display: inline-block; /* Ensure cards stay in a row */
min-width: 150px; /* Set the card size */
max-width: 200px;
max-height: auto;
display: flex;
flex-direction: column;
width: 300px;
min-width: 300px;
max-height: 350px;
flex: 0 0 auto; /* Prevent resizing of cards */
border: 1px solid #ddd; /* Optional border */
border-radius: 8px;
border: 1px solid var(--color-dark-green);
border-radius: 15px;
padding: 10px;
margin-left: 20px;
align-items: center;
text-align: center;
white-space: wrap;
background-color: var(--color-destin-sand); /* Optional background */
background-color: var(--color-destin-sand);
box-shadow: var(--shadow-subtle);
transition: all 0.5s ease-in-out; /* Added for smooth transitions */
}
.product-card h3,
.product-card .description,
.product-card p,
.product-card button {
margin-top: 5px; /* reduce vertical spacing */
margin-bottom: 5px;
}
.product-card img {
margin-bottom: 5px; /* space between image and title */
}
.product-card img {
max-width: 100%;
height: auto;
display: block;
border: solid var(--color-mid-green);
border-radius: 8px;
align-items: center;
}
/* New style for the centered card */
.product-card.is-centered {
width: 340px;
transform: scale(1.4);
box-shadow: var(--shadow-strong);
background-color: var(--color-destin-sand);
white-space: normal;
}
#scroll-left, #scroll-right {
cursor: pointer; /* Show pointer to indicate clickable buttons */
background-color: var(--color-dark-green); /* Dark green background */
cursor: pointer;
background-color: var(--color-dark-green);
color: white;
border: none;
padding: 10px;
@@ -90,81 +124,16 @@
}
}
#main-gallery #right-aside {
width: 25vw;
}
#main-gallery #right-aside h2 {
font-size: 1.675rem;
background-color: var(--color-light-teal);
color: var(--color-dark-green);
border: solid var(--color-dark-green);
border-radius: 5px;
padding: 0 5px;
white-space: nowrap;
box-shadow: var(--shadow-strong);
}
#main-gallery .categories ul {
#product-list {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
list-style-type: none;
}
#main-gallery .categories ul li {
border: solid var(--color-dark-green);
border-radius: 5px;
background-color: var(--color-mid-green);
margin-top: 20px;
margin-right: 35px;
min-width: 100%;
box-shadow: var(--shadow-strong);
}
#main-gallery .categories a {
color: var(--color-dark-green);
font-size: 1.3rem;
}
button#cart-details {
background-color: var(--color-destin-sand);
border: solid var(--color-dark-green);
border-radius: 15px;
color: var(--color-dark-green);
font-weight: bold;
font-size: 1.4em;
text-align: center; /* Align text horizontally */
height: 30px; /* Adjust height to fit text comfortably */
padding: 0 15px; /* Horizontal padding for spacing */
margin-top: 10px;
margin-bottom: 10px;
box-shadow: var(--shadow-subtle);
transform: translateX(-15vw) translateY(-5vh);
transition: background-color 0.3s ease, color 0.3s ease;
display: flex; /* Flexbox ensures content alignment */
align-items: center; /* Center text vertically */
justify-content: center; /* Center text horizontally */
}
button#cart-details:hover {
background-color: var(--color-dark-green);
color: var(--color-destin-sand);
border: solid var(--color-destin-sand);
border-radius: 15px;
}
.product-card {
box-shadow: var(--shadow-subtle);
transition: background-color 0.3s ease, color 0.3s ease;
flex-direction: row;
gap: 50px;
}
.add-to-cart-btn {
cursor: pointer;
background-color: var(--color-destin-sand);
border: solid var(--color-dark-green);
background-color: var(--color-mid-green);
border: solid 1px var(--color-dark-green);
color: var(--color-dark-green);
font-weight: bold;
border-radius: 5px;
@@ -173,10 +142,25 @@ button#cart-details:hover {
}
.add-to-cart-btn:hover {
background-color: var(--color-dark-green);
border: solid var(--color-destin-sand);
color: var(--color-destin-sand);
background-color: var(--color-destin-sand);
border: solid var(--color-dark-green);
color: var(--color-dark-green);
border-radius: 5px;
box-shadow: var(--shadow-strong);
}
#cart-details {
color: var(--color-dark-green);
font-size: 1.3rem;
font-weight: bold;
border: solid var(--color-dark-green);
border-radius: 10px;
transition: background-color 0.3s ease, color 0.3s ease;
}
#cart-details:hover {
background-color: var(--color-mid-green);
color: var(--color-destin-sand);
box-shadow: var(--shadow-medium);
}
/* |--↑-↑-↑ End gallery.html ↑-↑-↑--| */