// Product Data
const products = [
// Clothing Items
{
id: 1,
name: "Silk Evening Gown",
category: "clothing",
price: 1299,
originalPrice: 1599,
image: "https://images.unsplash.com/photo-1594633312681-425c7b97ccd1?w=400&q=80",
badge: "NEW",
rating: 5,
description: "Exquisite silk evening gown with intricate beadwork"
},
{
id: 2,
name: "Cashmere Coat",
category: "clothing",
price: 899,
originalPrice: 1199,
image: "https://images.unsplash.com/photo-1551028719-00167b16eac5?w=400&q=80",
badge: "SALE",
rating: 4.5,
description: "Luxurious 100% cashmere winter coat"
},
{
id: 3,
name: "Designer Blazer",
category: "clothing",
price: 699,
originalPrice: null,
image: "https://images.unsplash.com/photo-1539533113208-f6df8cc8b543?w=400&q=80",
badge: null,
rating: 4,
description: "Tailored wool blazer with gold buttons"
},
{
id: 4,
name: "Lace Evening Dress",
category: "clothing",
price: 999,
originalPrice: 1299,
image: "https://images.unsplash.com/photo-1596755094514-f87e34085b2c?w=400&q=80",
badge: "NEW",
rating: 5,
description: "Elegant lace dress perfect for formal occasions"
},
{
id: 5,
name: "Silk Blouse",
category: "clothing",
price: 449,
originalPrice: null,
image: "https://images.unsplash.com/photo-1583743814966-8936f5b7be1a?w=400&q=80",
badge: null,
rating: 4.5,
description: "Classic silk blouse with French cuffs"
},
// Bedding Items
{
id: 6,
name: "Egyptian Cotton Set",
category: "bedding",
price: 599,
originalPrice: 799,
image: "https://images.unsplash.com/photo-1586023492125-27b2c045efd7?w=400&q=80",
badge: "BESTSELLER",
rating: 5,
description: "1000 thread count Egyptian cotton bedding set"
},
{
id: 7,
name: "Silk Duvet Cover",
category: "bedding",
price: 449,
originalPrice: null,
image: "https://images.unsplash.com/photo-1615874959474-d609969a20ed?w=400&q=80",
badge: "NEW",
rating: 4.5,
description: "Luxurious 100% mulberry silk duvet cover"
},
{
id: 8,
name: "Luxury Throw Pillows",
category: "bedding",
price: 199,
originalPrice: 249,
image: "https://images.unsplash.com/photo-1595526114035-0d45ed16cfbf?w=400&q=80",
badge: null,
rating: 4,
description: "Set of 2 decorative throw pillows with gold embroidery"
},
{
id: 9,
name: "Premium Comforter",
category: "bedding",
price: 799,
originalPrice: null,
image: "https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=400&q=80",
badge: null,
rating: 5,
description: "Hypoallergenic down alternative comforter"
},
{
id: 10,
name: "Bamboo Sheet Set",
category: "bedding",
price: 349,
originalPrice: 449,
image: "https://images.unsplash.com/photo-1616627561950-6d7e08b38c0a?w=400&q=80",
badge: "ECO",
rating: 4.5,
description: "Sustainable bamboo fiber sheet set"
}
];
// Cart State
let cart = JSON.parse(localStorage.getItem('cart')) || [];
let wishlist = JSON.parse(localStorage.getItem('wishlist')) || [];
// Initialize
document.addEventListener('DOMContentLoaded', function() {
feather.replace();
renderProducts('all');
updateCartBadge();
setupEventListeners();
// Hide loading screen
setTimeout(() => {
document.querySelector('.loading-screen').classList.add('hidden');
}, 1000);
});
// Setup Event Listeners
function setupEventListeners() {
// Back to top button
const backToTop = document.getElementById('backToTop');
window.addEventListener('scroll', () => {
if (window.scrollY > 500) {
backToTop.classList.remove('opacity-0', 'invisible');
backToTop.classList.add('opacity-100', 'visible');
} else {
backToTop.classList.add('opacity-0', 'invisible');
backToTop.classList.remove('opacity-100', 'visible');
}
});
}
// Render Products
function renderProducts(category) {
const grid = document.getElementById('products-grid');
const filteredProducts = category === 'all'
? products
: category === 'new'
? products.filter(p => p.badge === 'NEW')
: products.filter(p => p.category === category);
grid.innerHTML = filteredProducts.map(product => `

${product.badge ? `
${product.badge}` : ''}
${product.name}
${generateStars(product.rating)}
(${product.rating})
$${product.price}
${product.originalPrice ? `$${product.originalPrice}` : ''}
`).join('');
feather.replace();
}
// Generate Star Rating
function generateStars(rating) {
let stars = '';
for (let i = 1; i <= 5; i++) {
if (i <= Math.floor(rating)) {
stars += '';
} else if (i - 0.5 <= rating) {
stars += '';
} else {
stars += '';
}
}
return stars;
}
// Filter Products
function filterProducts(category) {
// Update active button
document.querySelectorAll('.filter-btn').forEach(btn => {
btn.classList.remove('active', 'bg-amber-500', 'text-white', 'border-amber-500');
btn.classList.add('border-gray-300', 'text-gray-600');
});
event.target.classList.add('active', 'bg-amber-500', 'text-white', 'border-amber-500');
event.target.classList.remove('border-gray-300', 'text-gray-600');
renderProducts(category);
}
// Cart Functions
function addToCart(productId) {
const product = products.find(p => p.id === productId);
const existingItem = cart.find(item => item.id === productId);
if (existingItem) {
existingItem.quantity++;
} else {
cart.push({ ...product, quantity: 1 });
}
localStorage.setItem('cart', JSON.stringify(cart));
updateCartBadge();
showNotification('Product added to cart!', 'success');
openCartSidebar();
}
function removeFromCart(productId) {
cart = cart.filter(item => item.id !== productId);
localStorage.setItem('cart', JSON.stringify(cart));
updateCartBadge();
renderCart();
}
function updateQuantity(productId, change) {
const item = cart.find(item => item.id === productId);
if (item) {
item.quantity += change;
if (item.quantity <= 0) {
removeFromCart(productId);
} else {
localStorage.setItem('cart', JSON.stringify(cart));
renderCart();
}
}
}
function updateCartBadge() {
const totalItems = cart.reduce((sum, item) => sum + item.quantity, 0);
const badge = document.querySelector('.cart-badge');
if (badge) {
badge.textContent = totalItems;
badge.style.display = totalItems > 0 ? 'flex' : 'none';
}
}
// Wishlist Functions
function toggleWishlist(productId) {
const index = wishlist.indexOf(productId);
if (index > -1) {
wishlist.splice(index, 1);
showNotification('Removed from wishlist', 'info');
} else {
wishlist.push(productId);
showNotification('Added to wishlist!', 'success');
}
localStorage.setItem('wishlist', JSON.stringify(wishlist));
// Update button state
const btn = event.target.closest('.wishlist-btn');
btn.classList.toggle('active');
}
// Quick View
function quickView(productId) {
const product = products.find(p => p.id === productId);
const modal = document.querySelector('.quick-view-modal');
const content = modal.querySelector('.quick-view-content');
content.innerHTML = `

${product.badge ? `
${product.badge}` : ''}
${product.name}
${generateStars(product.rating)}
(${product.rating} ratings)
${product.description}
$${product.price}
${product.originalPrice ? `$${product.originalPrice}` : ''}
`;
modal.classList.add('active');
feather.replace();
}
function updateQuantityInput(change) {
const input = document.getElementById('quickViewQuantity');
const newValue = parseInt(input.value) + change;
if (newValue >= 1) {
input.value = newValue;
}
}
function addToCartFromQuickView(productId) {
const quantity = parseInt(document.getElementById('quickViewQuantity').value);
const product = products.find(p => p.id === productId);
const existingItem = cart.find(item => item.id === productId);
if (existingItem) {
existingItem.quantity += quantity;
} else {
cart.push({ ...product, quantity });
}
localStorage.setItem('cart', JSON.stringify(cart));
updateCartBadge();
closeQuickView();
showNotification('Product added to cart!', 'success');
openCartSidebar();
}
function closeQuickView() {
document.querySelector('.quick-view-modal').classList.remove('active');
}
// Cart Sidebar
function openCartSidebar() {
document.querySelector('.cart-sidebar').classList.add('active');
document.querySelector('.cart-overlay').classList.add('active');
renderCart();
}
function closeCartSidebar() {
document.querySelector('.cart-sidebar').classList.remove('active');
document.querySelector('.cart-overlay').classList.remove('active');
}
function renderCart() {
const cartItems = document.querySelector('.cart-items');
const cartTotal = document.querySelector('.cart-total');
if (cart.length === 0) {
cartItems.innerHTML = `
`;
} else {
cartItems.innerHTML = cart.map(item => `
${item.name}
$${item.price}
${item.quantity}
`).join('');
}
const total = cart.reduce((sum, item) => sum + (item.price * item.quantity), 0);
cartTotal.innerHTML = `