Your website already looks clean and well-structured! To enhance beauty and interactivity, I’ll suggest and apply several improvements:
Here’s your full updated HTML with these improvements integrated (comments added for clarity):
html Copy code
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Sweet Scoops - Premium Ice Cream</title>
<script src="https://cdn.tailwindcss.com"></script>
<!-- FontAwesome for icons -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
/>
<!-- Animate On Scroll Library -->
<link
href="https://unpkg.com/aos@2.3.1/dist/aos.css"
rel="stylesheet"
/>
<style>
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
body {
font-family: "Poppins", sans-serif;
background-color: #fff9f9;
scroll-behavior: smooth;
}
.hero-gradient {
background: linear-gradient(135deg, #ffcce6 0%, #ffd9b3 100%);
}
.flavor-card {
transition: all 0.3s ease, box-shadow 0.3s ease;
cursor: pointer;
}
.flavor-card:hover {
transform: translateY(-10px);
box-shadow: 0 20px 35px rgba(255, 107, 157, 0.5);
z-index: 10;
}
.scoop-animation {
animation: float 6s ease-in-out infinite;
}
@keyframes float {
0% {
transform: translateY(0px);
}
50% {
transform: translateY(-20px);
}
100% {
transform: translateY(0px);
}
}
.nav-link:hover {
color: #ff6b9d;
}
/* Smooth color and scale transition for buttons */
.btn-primary {
background-color: #ff6b9d;
transition: background-color 0.3s ease, transform 0.3s ease;
}
.btn-primary:hover {
background-color: #ff4785;
transform: scale(1.05);
}
.newsletter-input:focus {
outline: 2px solid #ff6b9d;
outline-offset: 0;
transition: outline 0.3s ease;
}
/* Mobile nav animation */
nav.mobile-active {
animation: slideDown 0.3s ease forwards;
}
@keyframes slideDown {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Header background transition on scroll */
header.scrolled {
background-color: rgba(255 255 255 / 0.95);
backdrop-filter: saturate(180%) blur(20px);
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
/* Back to top button */
#backToTop {
position: fixed;
bottom: 30px;
right: 30px;
background-color: #ff6b9d;
color: white;
padding: 12px 14px;
border-radius: 50%;
box-shadow: 0px 4px 15px rgba(255, 107, 157, 0.6);
cursor: pointer;
display: none;
z-index: 9999;
transition: background-color 0.3s ease;
}
#backToTop:hover {
background-color: #ff4785;
}
/* Hover effect on flavor images */
.flavor-card img {
transition: transform 0.3s ease;
}
.flavor-card:hover img {
transform: scale(1.05) rotate(2deg);
}
</style>
</head>
<body>
<!-- Header / Navigation -->
<header
class="bg-white shadow-md sticky top-0 z-50 transition-colors duration-300"
id="header"
>
<div
class="container mx-auto px-4 py-3 flex justify-between items-center"
>
<div class="flex items-center">
<img
src="https://via.placeholder.com/50x50"
alt="Sweet Scoops Logo"
class="h-12 w-12 mr-2"
/>
<h1 class="text-2xl font-bold text-pink-600">Sweet Scoops</h1>
</div>
<nav
class="hidden md:flex space-x-8 text-gray-700 font-medium text-base"
id="navLinks"
>
<a href="#flavors" class="nav-link hover:text-pink-500 transition"
>Flavors</a
>
<a href="#locations" class="nav-link hover:text-pink-500 transition"
>Locations</a
>
<a href="#ourstory" class="nav-link hover:text-pink-500 transition"
>Our Story</a
>
<a href="#shop" class="nav-link hover:text-pink-500 transition">Shop</a>
<a href="#contact" class="nav-link hover:text-pink-500 transition"
>Contact</a
>
</nav>
<div class="flex items-center space-x-4">
<button
class="text-gray-700 hover:text-pink-500"
aria-label="Search"
id="searchBtn"
>
<i class="fas fa-search text-xl"></i>
</button>
<button
class="text-gray-700 hover:text-pink-500"
aria-label="Shopping Cart"
id="cartBtn"
>
<i class="fas fa-shopping-cart text-xl"></i>
</button>
<button
class="md:hidden text-gray-700 hover:text-pink-500 focus:outline-none"
aria-label="Toggle Menu"
id="mobileMenuBtn"
>
<i class="fas fa-bars text-xl"></i>
</button>
</div>
</div>
</header>
<!-- Hero Section -->
<section class="hero-gradient py-16 md:py-24">
<div
class="container mx-auto px-4 flex flex-col md:flex-row items-center"
data-aos="fade-up"
>
<div class="md:w-1/2 mb-10 md:mb-0">
<h2
class="text-4xl md:text-5xl font-bold text-gray-800 mb-4 leading-tight"
>
Handcrafted Happiness in Every Scoop
</h2>
<p class="text-lg text-gray-700 mb-8 max-w-xl">
Made with real ingredients and lots of love. Our premium ice cream
will make your taste buds dance!
</p>
<div
class="flex flex-col sm:flex-row sm:space-x-4 space-y-4 sm:space-y-0 max-w-sm"
>
<button
class="btn-primary text-white font-bold py-3 px-8 rounded-full shadow-lg hover:shadow-pink-400/70 transition duration-300"
>
Shop Flavors
</button>
<button
class="bg-white text-pink-600 font-bold py-3 px-8 rounded-full shadow-lg border border-pink-200 hover:bg-pink-50 transition duration-300"
>
Find a Store
</button>
</div>
</div>
<div class="md:w-1/2 flex justify-center relative">
<img
src="https://via.placeholder.com/500x500"
alt="Ice Cream Cone"
class="w-64 h-64 md:w-80 md:h-80 scoop-animation rounded-3xl shadow-2xl"
data-aos="zoom-in"
data-aos-delay="200"
/>
<div
class="absolute -bottom-5 -right-5 bg-pink-100 rounded-full w-16 h-16 flex items-center justify-center shadow-lg"
data-aos="fade-left"
data-aos-delay="400"
>
<span class="text-pink-600 font-bold text-xl">$4.99</span>
</div>
</div>
</div>
</section>
<!-- Featured Flavors -->
<section class="py-16 bg-white" id="flavors" data-aos="fade-up">
<div class="container mx-auto px-4">
<div class="text-center mb-12">
<h2 class="text-3xl font-bold text-gray-800 mb-2">Our Signature Flavors</h2>
<p class="text-gray-600 max-w-2xl mx-auto">
Crafted with care using the finest ingredients for an unforgettable
taste experience
</p>
</div>
<div
class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-8"
id="flavorGrid"
>
<!-- Flavor Cards -->
<!-- Each flavor card gets AOS animation and accessible roles -->
<div
class="flavor-card bg-white rounded-xl overflow-hidden shadow-md p-6 text-center"
tabindex="0"
role="button"
aria-label="Add Strawberry Cheesecake to cart"
data-aos="zoom-in"
>
<div
class="bg-pink-100 rounded-full w-40 h-40 mx-auto mb-6 flex items-center justify-center"
>
<img
src="https://via.placeholder.com/150x150"
alt="Strawberry Cheesecake"
class="w-32 h-32 object-cover rounded-full"
/>
</div>
<h3 class="text-xl font-bold text-gray-800 mb-2">
Strawberry Cheesecake
</h3>
<p class="text-gray-600 mb-4">
Creamy cheesecake ice cream with strawberry swirls and graham
cracker pieces
</p>
<button
class="btn-primary add-to-cart-btn text-white font-medium py-2 px-6 rounded-full text-sm inline-flex items-center justify-center mx-auto"
>
Add to Cart
</button>
</div>
<div
class="flavor-card bg-white rounded-xl overflow-hidden shadow-md p-6 text-center"
tabindex="0"
role="button"
aria-label="Add Salted Caramel to cart"
data-aos="zoom-in"
data-aos-delay="100"
>
<div
class="bg-yellow-100 rounded-full w-40 h-40 mx-auto mb-6 flex items-center justify-center"
>
<img
src="https://via.placeholder.com/150x150"
alt="Salted Caramel"
class="w-32 h-32 object-cover rounded-full"
/>
</div>
<h3 class="text-xl font-bold text-gray-800 mb-2">Salted Caramel</h3>
<p class="text-gray-600 mb-4">
Rich caramel ice cream with a hint of sea salt and caramel ribbon
</p>
<button
class="btn-primary add-to-cart-btn text-white font-medium py-2 px-6 rounded-full text-sm inline-flex items-center justify-center mx-auto"
>
Add to Cart
</button>
</div>
<div
class="flavor-card bg-white rounded-xl overflow-hidden shadow-md p-6 text-center"
tabindex="0"
role="button"
aria-label="Add Midnight Cookies to cart"
data-aos="zoom-in"
data-aos-delay="200"
>
<div
class="bg-blue-100 rounded-full w-40 h-40 mx-auto mb-6 flex items-center justify-center"
>
<img
src="https://via.placeholder.com/150x150"
alt="Midnight Cookies"
class="w-32 h-32 object-cover rounded-full"
/>
</div>
<h3 class="text-xl font-bold text-gray-800 mb-2">Midnight Cookies</h3>
<p class="text-gray-600 mb-4">
Dark chocolate ice cream with chocolate cookie pieces and fudge
swirls
</p>
<button
class="btn-primary add-to-cart-btn text-white font-medium py-2 px-6 rounded-full text-sm inline-flex items-center justify-center mx-auto"
>
Add to Cart
</button>
</div>
<div
class="flavor-card bg-white rounded-xl overflow-hidden shadow-md p-6 text-center"
tabindex="0"
role="button"
aria-label="Add Mint Chocolate Chip to cart"
data-aos="zoom-in"
data-aos-delay="300"
>
<div
class="bg-green-100 rounded-full w-40 h-40 mx-auto mb-6 flex items-center justify-center"
>
<img
src="https://via.placeholder.com/150x150"
alt="Mint Chocolate Chip"
class="w-32 h-32 object-cover rounded-full"
/>
</div>
<h3 class="text-xl font-bold text-gray-800 mb-2">
Mint Chocolate Chip
</h3>
<p class="text-gray-600 mb-4">
Refreshing mint ice cream with rich dark chocolate chunks
</p>
<button
class="btn-primary add-to-cart-btn text-white font-medium py-2 px-6 rounded-full text-sm inline-flex items-center justify-center mx-auto"
>
Add to Cart
</button>
</div>
</div>
<div class="text-center mt-12">
<button
class="border-2 border-pink-500 text-pink-600 font-bold py-3 px-8 rounded-full hover:bg-pink-50 transition"
>
View All Flavors
</button>
</div>
</div>
</section>
<!-- Our Story -->
<section
class="py-16 bg-pink-50"
id="ourstory"
data-aos="fade-up"
data-aos-delay="200"
>
<div class="container mx-auto px-4 flex flex-col md:flex-row items-center">
<div class="md:w-1/2 mb-10 md:mb-0 md:pr-10">
<h2 class="text-3xl font-bold text-gray-800 mb-4">Our Sweet Story</h2>
<p class="text-gray-700 mb-6">
Founded in 2010, Sweet Scoops began as a small family-owned shop with a
passion for creating the creamiest, most delicious ice cream using only
the finest ingredients.
</p>
<p class="text-gray-700 mb-6">
Today, we still make our ice cream in small batches, with each flavor
carefully crafted to perfection. We source our milk from local farms
and use real fruits, nuts, and chocolates in every recipe.
</p>
<button
class="btn-primary text-white font-bold py-3 px-8 rounded-full shadow-lg hover:shadow-pink-400/70 transition"
>
Learn More
</button>
</div>
<div class="md:w-1/2">
<div class="relative">
<img
src="https://via.placeholder.com/600x400"
alt="Ice Cream Making"
class="rounded-lg shadow-xl w-full"
/>
<div
class="absolute -bottom-5 -right-5 bg-white p-4 rounded-lg shadow-lg flex items-center"
data-aos="fade-left"
>
<div
class="bg-pink-100 rounded-full w-12 h-12 flex items-center justify-center mr-3"
>
<i class="fas fa-heart text-pink-600 text-xl"></i>
</div>
<div>
<p class="font-bold text-gray-800">100+</p>
<p class="text-sm text-gray-600">Happy Flavors</p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Testimonials -->
<section
class="py-16 bg-white"
data-aos="fade-up"
data-aos-delay="400"
id="testimonialsSection"
>
<div class="container mx-auto px-4">
<div class="text-center mb-12">
<h2 class="text-3xl font-bold text-gray-800 mb-2">
What Our Customers Say
</h2>
<p class="text-gray-600 max-w-2xl mx-auto">
Real reviews from ice cream lovers just like you
</p>
</div>
<!-- Desktop Grid -->
<div class="hidden md:grid md:grid-cols-3 gap-8" id="testimonialsGrid">
<!-- Testimonial 1 -->
<div class="bg-pink-50 rounded-xl p-8 shadow-md">
<div class="flex items-center mb-4">
<div class="text-yellow-400 mr-2" aria-label="5 stars">
<i class="fas fa-star"></i><i class="fas fa-star"></i
><i class="fas fa-star"></i><i class="fas fa-star"></i
><i class="fas fa-star"></i>
</div>
<span class="text-gray-700 text-sm">2 days ago</span>
</div>
<p class="text-gray-700 mb-6">
"The Strawberry Cheesecake flavor is absolutely divine! The perfect
balance of sweet and tangy with real cheesecake pieces. My new
favorite!"
</p>
<div class="flex items-center">
<img
src="https://via.placeholder.com/50x50"
alt="Sarah J."
class="w-10 h-10 rounded-full mr-3"
/>
<div>
<p class="font-medium text-gray-800">Sarah J.</p>
<p class="text-sm text-gray-600">Verified Buyer</p>
</div>
</div>
</div>
<!-- Testimonial 2 -->
<div class="bg-pink-50 rounded-xl p-8 shadow-md">
<div class="flex items-center mb-4">
<div class="text-yellow-400 mr-2" aria-label="5 stars">
<i class="fas fa-star"></i><i class="fas fa-star"></i
><i class="fas fa-star"></i><i class="fas fa-star"></i
><i class="fas fa-star"></i>
</div>
<span class="text-gray-700 text-sm">1 week ago</span>
</div>
<p class="text-gray-700 mb-6">
"I've tried many salted caramel ice creams, but none compare to Sweet
Scoops. The quality is exceptional and you can taste the difference!"
</p>
<div class="flex items-center">
<img
src="https://via.placeholder.com/50x50"
alt="Michael T."
class="w-10 h-10 rounded-full mr-3"
/>
<div>
<p class="font-medium text-gray-800">Michael T.</p>
<p class="text-sm text-gray-600">Verified Buyer</p>
</div>
</div>
</div>
<!-- Testimonial 3 -->
<div class="bg-pink-50 rounded-xl p-8 shadow-md">
<div class="flex items-center mb-4">
<div class="text-yellow-400 mr-2" aria-label="4.5 stars">
<i class="fas fa-star"></i><i class="fas fa-star"></i
><i class="fas fa-star"></i><i class="fas fa-star"></i
><i class="fas fa-star-half-alt"></i>
</div>
<span class="text-gray-700 text-sm">3 weeks ago</span>
</div>
<p class="text-gray-700 mb-6">
"The Mint Chocolate Chip is refreshing and not overly sweet. Perfect
for hot summer days. My whole family loves it!"
</p>
<div class="flex items-center">
<img
src="https://via.placeholder.com/50x50"
alt="Lisa M."
class="w-10 h-10 rounded-full mr-3"
/>
<div>
<p class="font-medium text-gray-800">Lisa M.</p>
<p class="text-sm text-gray-600">Verified Buyer</p>
</div>
</div>
</div>
</div>
<!-- Mobile Carousel -->
<div class="md:hidden relative" id="testimonialsCarousel" aria-label="Testimonials Carousel" tabindex="0">
<div class="overflow-hidden rounded-xl shadow-md bg-pink-50 p-8" id="carouselItem">
<!-- Content replaced by JS -->
</div>
<button aria-label="Previous testimonial" id="prevTestimonial" class="absolute top-1/2 left-2 -translate-y-1/2 bg-pink-600 text-white p-2 rounded-full hover:bg-pink-700 transition focus:outline-none focus:ring-2 focus:ring-pink-300">
<i class="fas fa-chevron-left"></i>
</button>
<button aria-label="Next testimonial" id="nextTestimonial" class="absolute top-1/2 right-2 -translate-y-1/2 bg-pink-600 text-white p-2 rounded-full hover:bg-pink-700 transition focus:outline-none focus:ring-2 focus:ring-pink-300">
<i class="fas fa-chevron-right"></i>
</button>
</div>
</div>
</section>
<!-- Newsletter -->
<section class="py-16 bg-pink-600 text-white" id="newsletter" data-aos="fade-up" data-aos-delay="600">
<div class="container mx-auto px-4 text-center">
<h2 class="text-3xl font-bold mb-4">Join Our Sweet Community</h2>
<p class="max-w-2xl mx-auto mb-8 text-pink-100">
Sign up for our newsletter and be the first to know about new flavors,
special offers, and exclusive events!
</p>
<form class="max-w-md mx-auto flex flex-col sm:flex-row gap-4" id="newsletterForm" novalidate>
<input
type="email"
name="email"
id="emailInput"
placeholder="Your email address"
required
class="newsletter-input flex-grow px-4 py-3 rounded-full text-gray-800 focus:outline-none"
aria-label="Email address"
/>
<button
type="submit"
class="bg-white text-pink-600 font-bold py-3 px-8 rounded-full hover:bg-gray-100 transition"
aria-label="Subscribe to newsletter"
>
Subscribe
</button>
</form>
<p class="mt-4 text-sm text-pink-200">
We respect your privacy. Unsubscribe at any time.
</p>
<p id="subscriptionMessage" class="text-green-300 mt-4"></p>
</div>
</section>
<!-- Footer -->
<footer class="bg-gray-900 text-white py-12" id="contact">
<div class="container mx-auto px-4">
<div class="grid grid-cols-1 md:grid-cols-4 gap-8 mb-8">
<div>
<h3 class="text-xl font-bold mb-4">Sweet Scoops</h3>
<p class="text-gray-400 mb-4">
Handcrafted happiness in every scoop since 2010.
</p>
<div class="flex space-x-4">
<a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-facebook-f"></i></a>
<a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-instagram"></i></a>
<a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-twitter"></i></a>
<a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-pinterest"></i></a>
</div>
</div>
<div>
<h4 class="font-bold mb-4">Shop</h4>
<ul class="space-y-2">
<li><a href="#flavors" class="hover:text-white transition">All Flavors</a></li>
<li><a href="#" class="hover:text-white transition">New Arrivals</a></li>
<li><a href="#" class="hover:text-white transition">Best Sellers</a></li>
<li><a href="#" class="hover:text-white transition">Gift Cards</a></li>
<li><a href="#" class="hover:text-white transition">Merchandise</a></li>
</ul>
</div>
<div>
<h4 class="font-bold mb-4">About</h4>
<ul class="space-y-2">
<li><a href="#ourstory" class="hover:text-white transition">Our Story</a></li>
<li><a href="#" class="hover:text-white transition">Ingredients</a></li>
<li><a href="#" class="hover:text-white transition">Sustainability</a></li>
<li><a href="#" class="hover:text-white transition">Careers</a></li>
<li><a href="#" class="hover:text-white transition">Press</a></li>
</ul>
</div>
<div>
<h4 class="font-bold mb-4">Help</h4>
<ul class="space-y-2">
<li><a href="#" class="hover:text-white transition">FAQs</a></li>
<li><a href="#" class="hover:text-white transition">Shipping</a></li>
<li><a href="#" class="hover:text-white transition">Returns</a></li>
<li><a href="#contact" class="hover:text-white transition">Contact Us</a></li>
<li><a href="#" class="hover:text-white transition">Store Locator</a></li>
</ul>
</div>
</div>
<div
class="pt-8 border-t border-gray-800 flex flex-col md:flex-row justify-between items-center"
>
<p class="text-gray-400 mb-4 md:mb-0">
© 2023 Sweet Scoops. All rights reserved.
</p>
<div class="flex space-x-6 text-sm">
<a href="#" class="hover:text-white transition">Privacy Policy</a>
<a href="#" class="hover:text-white transition">Terms of Service</a>
<a href="#" class="hover:text-white transition">Cookie Policy</a>
</div>
</div>
</div>
</footer>
<!-- Back to Top Button -->
<button
id="backToTop"
aria-label="Back to top"
title="Back to top"
>
<i class="fas fa-chevron-up"></i>
</button>
<!-- Scripts -->
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
AOS.init({
duration: 700,
once: true,
});
const header = document.getElementById("header");
const mobileMenuBtn = document.getElementById("mobileMenuBtn");
const navLinks = document.getElementById("navLinks");
const backToTopBtn = document.getElementById("backToTop");
// Toggle mobile menu with animation and accessible aria-expanded state
mobileMenuBtn.addEventListener("click", () => {
navLinks.classList.toggle("hidden");
navLinks.classList.toggle("flex");
navLinks.classList.toggle("flex-col");
navLinks.classList.toggle("absolute");
navLinks.classList.toggle("top-16");
navLinks.classList.toggle("left-0");
navLinks.classList.toggle("right-0");
navLinks.classList.toggle("bg-white");
navLinks.classList.toggle("p-4");
navLinks.classList.toggle("shadow-md");
navLinks.classList.toggle("space-y-4");
if (navLinks.classList.contains("hidden")) {
mobileMenuBtn.setAttribute("aria-expanded", "false");
} else {
mobileMenuBtn.setAttribute("aria-expanded", "true");
navLinks.classList.add("mobile-active");
}
});
// Change header background on scroll
window.addEventListener("scroll", () => {
if (window.scrollY > 50) {
header.classList.add("scrolled");
backToTopBtn.style.display = "block";
} else {
header.classList.remove("scrolled");
backToTopBtn.style.display = "none";
}
});
// Back to top button scroll behavior
backToTopBtn.addEventListener("click", () => {
window.scrollTo({ top: 0, behavior: "smooth" });
});
// Add to cart button feedback (with icon animation)
const addToCartButtons = document.querySelectorAll(".add-to-cart-btn");
addToCartButtons.forEach((btn) => {
btn.addEventListener("click", function () {
this.disabled = true;
const originalText = this.innerHTML;
this.innerHTML =
'<i class="fas fa-check mr-2 animate-ping"></i>Added!';
setTimeout(() => {
this.innerHTML = originalText;
this.disabled = false;
}, 2000);
});
});
// Newsletter form submission simulation
const newsletterForm = document.getElementById("newsletterForm");
const emailInput = document.getElementById("emailInput");
const subscriptionMessage = document.getElementById("subscriptionMessage");
newsletterForm.addEventListener("submit", (e) => {
e.preventDefault();
if (emailInput.validity.valid) {
// Simulate success
subscriptionMessage.textContent =
"Thanks for subscribing! 🎉 You’ll hear from us soon.";
subscriptionMessage.style.color = "#A7F3D0"; // Tailwind green-300
newsletterForm.reset();
} else {
subscriptionMessage.textContent = "Please enter a valid email address.";
subscriptionMessage.style.color = "#F87171"; // Tailwind red-400
}
});
// Testimonials Carousel data & functions for mobile
const testimonials = [
{
stars: 5,
date: "2 days ago",
text:
'"The Strawberry Cheesecake flavor is absolutely divine! The perfect balance of sweet and tangy with real cheesecake pieces. My new favorite!"',
name: "Sarah J.",
role: "Verified Buyer",
img: "https://via.placeholder.com/50x50",
},
{
stars: 5,
date: "1 week ago",
text:
"\"I've tried many salted caramel ice creams, but none compare to Sweet Scoops. The quality is exceptional and you can taste the difference!\"",
name: "Michael T.",
role: "Verified Buyer",
img: "https://via.placeholder.com/50x50",
},
{
stars: 4.5,
date: "3 weeks ago",
text:
'"The Mint Chocolate Chip is refreshing and not overly sweet. Perfect for hot summer days. My whole family loves it!"',
name: "Lisa M.",
role: "Verified Buyer",
img: "https://via.placeholder.com/50x50",
},
];
const carouselItem = document.getElementById("carouselItem");
let currentIndex = 0;
function renderTestimonial(index) {
const t = testimonials[index];
// stars display (full and half)
let starsHtml = "";
for (let i = 1; i <= 5; i++) {
if (i <= Math.floor(t.stars)) {
starsHtml += '<i class="fas fa-star"></i>';
} else if (i - t.stars === 0.5) {
starsHtml += '<i class="fas fa-star-half-alt"></i>';
} else {
starsHtml += '<i class="far fa-star"></i>';
}
}
carouselItem.innerHTML = `
<div class="flex items-center mb-4 text-yellow-400" aria-label="${t.stars} stars">${starsHtml}</div>
<span class="text-gray-700 text-sm block mb-4">${t.date}</span>
<p class="text-gray-700 mb-6 italic"> ${t.text} </p>
<div class="flex items-center">
<img src="${t.img}" alt="${t.name}" class="w-10 h-10 rounded-full mr-3" />
<div>
<p class="font-medium text-gray-800">${t.name}</p>
<p class="text-sm text-gray-600">${t.role}</p>
</div>
</div>
`;
}
renderTestimonial(currentIndex);
document.getElementById("prevTestimonial").addEventListener("click", () => {
currentIndex = (currentIndex - 1 + testimonials.length) % testimonials.length;
renderTestimonial(currentIndex);
});
document.getElementById("nextTestimonial").addEventListener("click", () => {
currentIndex = (currentIndex + 1) % testimonials.length;
renderTestimonial(currentIndex);
});
});
</script>
</body>
</html>
If you want me to help integrate real data, connect to a backend, or add more fancy animations (like parallax), just ask! But this will make your site much more engaging and polished visually.