import gradio as gr import random from datetime import datetime # Fashion data FASHION_CATEGORIES = ["Dresses", "Tops", "Bottoms", "Outerwear", "Accessories", "Shoes"] PRODUCTS = [ {"id": 1, "name": "Elegant Evening Dress", "category": "Dresses", "price": 189.99, "rating": 4.8, "image": "šŸ‘—", "description": "Stunning floor-length gown perfect for special occasions"}, {"id": 2, "name": "Casual Summer Top", "category": "Tops", "price": 45.99, "rating": 4.5, "image": "šŸ‘•", "description": "Breathable cotton blend for everyday comfort"}, {"id": 3, "name": "Designer Jeans", "category": "Bottoms", "price": 129.99, "rating": 4.7, "image": "šŸ‘–", "description": "Premium denim with perfect fit and stretch"}, {"id": 4, "name": "Leather Jacket", "category": "Outerwear", "price": 299.99, "rating": 4.9, "image": "🧄", "description": "Genuine leather with classic biker style"}, {"id": 5, "name": "Statement Necklace", "category": "Accessories", "price": 79.99, "rating": 4.6, "image": "šŸ’Ž", "description": "Bold piece to elevate any outfit"}, {"id": 6, "name": "Ankle Boots", "category": "Shoes", "price": 159.99, "rating": 4.8, "image": "šŸ‘¢", "description": "Versatile boots for all seasons"}, {"id": 7, "name": "Silk Blouse", "category": "Tops", "price": 89.99, "rating": 4.7, "image": "šŸ‘š", "description": "Luxurious silk for professional elegance"}, {"id": 8, "name": "Maxi Skirt", "category": "Bottoms", "price": 69.99, "rating": 4.4, "image": "šŸ‘—", "description": "Flowing silhouette for effortless style"}, ] FASHION_TRENDS = [ {"trend": "Sustainable Fashion", "description": "Eco-friendly materials and ethical production", "popularity": "95%"}, {"trend": "Y2K Revival", "description": "Early 2000s aesthetics making a comeback", "popularity": "88%"}, {"trend": "Oversized Blazers", "description": "Power dressing with relaxed silhouettes", "popularity": "92%"}, {"trend": "Chunky Sneakers", "description": "Bold footwear for street style", "popularity": "85%"}, ] REVIEWS = [ {"user": "Sarah M.", "rating": 5, "comment": "Absolutely love this dress! Perfect fit and amazing quality."}, {"user": "Jessica L.", "rating": 4, "comment": "Great style, runs slightly small. Order one size up."}, {"user": "Emma K.", "rating": 5, "comment": "Best purchase ever! Received so many compliments."}, {"user": "Olivia R.", "rating": 4, "comment": "Beautiful piece, fast shipping, will buy again."}, ] class FashionApp: def __init__(self): self.cart = [] self.wishlist = [] def get_products(self, category="All"): if category == "All": return PRODUCTS return [p for p in PRODUCTS if p["category"] == category] def add_to_cart(self, product_id): product = next((p for p in PRODUCTS if p["id"] == product_id), None) if product: self.cart.append(product) return f"āœ… Added {product['name']} to cart!" return "āŒ Product not found" def add_to_wishlist(self, product_id): product = next((p for p in PRODUCTS if p["id"] == product_id), None) if product: self.wishlist.append(product) return f"ā¤ļø Added {product['name']} to wishlist!" return "āŒ Product not found" def get_cart_total(self): return sum(p["price"] for p in self.cart) def get_cart_display(self): if not self.cart: return "Your cart is empty šŸ›’" items = "\n".join([f"• {p['image']} {p['name']} - ${p['price']:.2f}" for p in self.cart]) return f"šŸ›’ Your Cart:\n{items}\n\nšŸ’° Total: ${self.get_cart_total():.2f}" def get_wishlist_display(self): if not self.wishlist: return "Your wishlist is empty ā¤ļø" items = "\n".join([f"• {p['image']} {p['name']} - ${p['price']:.2f}" for p in self.wishlist]) return f"ā¤ļø Your Wishlist:\n{items}" def style_recommendation(self, occasion, season, style_preference): recommendations = [] if occasion == "Work": recommendations.append("šŸ‘” Tailored blazer with crisp white shirt") recommendations.append("šŸ‘– High-waisted trousers in neutral tones") elif occasion == "Casual": recommendations.append("šŸ‘• Relaxed fit t-shirt with denim") recommendations.append("šŸ‘Ÿ Comfortable sneakers") elif occasion == "Evening": recommendations.append("šŸ‘— Little black dress or elegant jumpsuit") recommendations.append("šŸ’Ž Statement jewelry") elif occasion == "Date Night": recommendations.append("šŸ‘— Flattering midi dress") recommendations.append("šŸ‘  Heels or stylish boots") if season == "Spring": recommendations.append("🌸 Pastel colors and floral prints") elif season == "Summer": recommendations.append("ā˜€ļø Lightweight fabrics and bright colors") elif season == "Fall": recommendations.append("šŸ‚ Layering with warm tones") elif season == "Winter": recommendations.append("ā„ļø Cozy knits and statement coats") if style_preference == "Classic": recommendations.append("✨ Timeless pieces that never go out of style") elif style_preference == "Trendy": recommendations.append("šŸ”„ Latest runway-inspired looks") elif style_preference == "Bohemian": recommendations.append("🌿 Flowing fabrics and earthy tones") elif style_preference == "Minimalist": recommendations.append("⚪ Clean lines and monochromatic palette") return "\n\n".join(recommendations) def checkout(self): if not self.cart: return "āŒ Your cart is empty! Add items before checkout." total = self.get_cart_total() self.cart = [] return f"šŸŽ‰ Thank you for your order!\n\nTotal: ${total:.2f}\n\nYour order will be processed shortly.\n\nTracking number: FSH{random.randint(10000, 99999)}" def clear_cart(self): self.cart = [] return "šŸ—‘ļø Cart cleared!" app = FashionApp() with gr.Blocks(theme=gr.themes.Soft(), title="LUXE Fashion Boutique") as demo: gr.Markdown("""# ✨ LUXE Fashion Boutique ✨ ### Your destination for exceptional style and timeless elegance""") with gr.Tabs(): # Home Tab with gr.TabItem("šŸ  Home"): gr.Markdown("## 🌟 Featured Collection") with gr.Row(): for i, product in enumerate(PRODUCTS[:4]): with gr.Column(): gr.Markdown(f"### {product['image']} {product['name']}") gr.Markdown(f"**${product['price']:.2f}** ⭐ {product['rating']}") gr.Markdown(f"{product['description']}") add_btn = gr.Button("Add to Cart", variant="primary") add_btn.click(fn=app.add_to_cart, inputs=gr.Number(value=product['id'], visible=False), outputs=gr.Textbox(label="Status")) gr.Markdown("## šŸ”„ Current Trends") with gr.Row(): for trend in FASHION_TRENDS: with gr.Column(): gr.Markdown(f"### {trend['trend']}") gr.Markdown(f"{trend['description']}") gr.Markdown(f"**Popularity: {trend['popularity']}**") # Shop Tab with gr.TabItem("šŸ›ļø Shop"): category_dropdown = gr.Dropdown( choices=["All"] + FASHION_CATEGORIES, value="All", label="Filter by Category" ) product_display = gr.Markdown() def update_products(category): products = app.get_products(category) result = "## šŸ“¦ Available Products\n\n" for p in products: result += f"### {p['image']} {p['name']}\n" result += f"**${p['price']:.2f}** | ⭐ {p['rating']} | {p['category']}\n" result += f"{p['description']}\n\n" return result category_dropdown.change(fn=update_products, inputs=category_dropdown, outputs=product_display) product_display.value = update_products("All") with gr.Row(): product_id_input = gr.Number(label="Product ID", precision=0) add_btn = gr.Button("Add to Cart", variant="primary") wishlist_btn = gr.Button("Add to Wishlist", variant="secondary") add_btn.click(fn=app.add_to_cart, inputs=product_id_input, outputs=gr.Textbox(label="Status")) wishlist_btn.click(fn=app.add_to_wishlist, inputs=product_id_input, outputs=gr.Textbox(label="Status")) # Style Quiz Tab with gr.TabItem("šŸ’« Style Quiz"): gr.Markdown("## Get Personalized Style Recommendations") with gr.Row(): occasion = gr.Dropdown( choices=["Work", "Casual", "Evening", "Date Night"], label="Occasion" ) season = gr.Dropdown( choices=["Spring", "Summer", "Fall", "Winter"], label="Season" ) style_pref = gr.Dropdown( choices=["Classic", "Trendy", "Bohemian", "Minimalist"], label="Style Preference" ) recommend_btn = gr.Button("Get Recommendations", variant="primary") recommendation_output = gr.Textbox(label="Your Personalized Recommendations", lines=8) recommend_btn.click( fn=app.style_recommendation, inputs=[occasion, season, style_pref], outputs=recommendation_output ) # Cart Tab with gr.TabItem("šŸ›’ Cart"): cart_display = gr.Textbox(label="Shopping Cart", lines=10) def refresh_cart(): return app.get_cart_display() with gr.Row(): checkout_btn = gr.Button("Checkout", variant="primary") clear_btn = gr.Button("Clear Cart", variant="stop") checkout_output = gr.Textbox(label="Order Status", lines=5) checkout_btn.click(fn=app.checkout, outputs=checkout_output) clear_btn.click(fn=app.clear_cart, outputs=gr.Textbox(label="Status")) demo.load(fn=refresh_cart, outputs=cart_display) # Wishlist Tab with gr.TabItem("ā¤ļø Wishlist"): wishlist_display = gr.Textbox(label="Your Wishlist", lines=10) def refresh_wishlist(): return app.get_wishlist_display() demo.load(fn=refresh_wishlist, outputs=wishlist_display) # Reviews Tab with gr.TabItem("⭐ Reviews"): gr.Markdown("## Customer Reviews") for review in REVIEWS: with gr.Group(): gr.Markdown(f"**{review['user']}** - {'⭐' * review['rating']}") gr.Markdown(f"_{review['comment']}_") gr.Markdown("## Write a Review") with gr.Row(): review_name = gr.Textbox(label="Your Name", placeholder="Enter your name") review_rating = gr.Slider(minimum=1, maximum=5, step=1, label="Rating", value=5) review_text = gr.Textbox(label="Your Review", placeholder="Share your experience...") submit_review = gr.Button("Submit Review", variant="primary") review_status = gr.Textbox(label="Status") def submit_review_fn(name, rating, text): if name and text: return f"āœ… Thank you {name}! Your review has been submitted." return "āŒ Please fill in all fields." submit_review.click( fn=submit_review_fn, inputs=[review_name, review_rating, review_text], outputs=review_status ) # About Tab with gr.TabItem("ā„¹ļø About"): gr.Markdown("""## About LUXE Fashion Boutique ### Our Story Founded in 2024, LUXE Fashion Boutique is dedicated to bringing you the finest fashion pieces from around the world. We believe that exceptional style should be accessible to everyone. ### Our Values - ✨ **Quality First**: Every piece is carefully curated for excellence - 🌱 **Sustainability**: We partner with eco-conscious brands - šŸ’ **Customer Care**: Your satisfaction is our priority - šŸŽØ **Innovation**: Always ahead of the trends ### Contact Us šŸ“§ support@luxefashion.com\nšŸ“± 1-800-LUXE-STYLE\nšŸ“ 123 Fashion Avenue, New York, NY ### Shipping & Returns - Free shipping on orders over $100 - 30-day return policy - Express shipping available ### Follow Us šŸ“ø @luxefashionboutique""") if __name__ == "__main__": demo.launch(server_name="0.0.0.0", server_port=7860)