deepseek-r1-0528· DeepSeek LMArena Human Preference 140K
Create a gallery component for a cake bakery webpage in astro framework using tailwind…
- User
Create a gallery component for a cake bakery webpage in astro framework using tailwind to style it
- Assistant
Here's a responsive gallery component for a cake bakery using Astro and Tailwind CSS:
--- // src/components/CakeGallery.astro // Define cake data structure (could be moved to separate file or fetched from CMS) const cakes = [ { id: 1, name: "Chocolate Fudge", category: "chocolate", image: "/images/cake1.jpg" }, { id: 2, name: "Vanilla Dream", category: "classic", image: "/images/cake2.jpg" }, { id: 3, name: "Red Velvet", category: "specialty", image: "/images/cake3.jpg" }, { id: 4, name: "Lemon Drizzle", category: "fruit", image: "/images/cake4.jpg" }, { id: 5, name: "Carrot Cake", category: "specialty", image: "/images/cake5.jpg" }, { id: 6, name: "Strawberry Shortcake", category: "fruit", image: "/images/cake6.jpg" }, { id: 7, name: "Cookies & Cream", category: "chocolate", image: "/images/cake7.jpg" }, { id: 8, name: "Tiramisu", category: "specialty", image: "/images/cake8.jpg" }, ]; --- <div class="container mx-auto px-4 py-12"> <h2 class="text-3xl md:text-4xl font-bold text-center mb-2 text-amber-800">Our Sweet Creations</h2> <p class="text-center text-gray-600 mb-12 max-w-2xl mx-auto"> Browse through our delicious selection of handcrafted cakes made with love and premium ingredients </p> <!-- Gallery Grid --> <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6"> {cakes.map((cake) => ( <div class="relative group overflow-hidden rounded-xl shadow-lg hover:shadow-xl transition-all duration-300"> <!-- Cake Image --> <img src={cake.image} alt={cake.name} width="400" height="500" class="w-full h-64 object-cover transition-transform duration-500 group-hover:scale-110" /> <!-- Overlay --> <div class="absolute inset-0 bg-gradient-to-t from-black/70 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"> <div class="absolute bottom-0 left-0 p-6 text-white translate-y-4 group-hover:translate-y-0 transition-transform duration-300"> <h3 class="text-xl font-bold">{cake.name}</h3> <p class="text-amber-200 font-medium">${cake.category}</p> </div> </div> </div> ))} </div> <!-- View More Button --> <div class="text-center mt-12"> <button class="bg-amber-600 hover:bg-amber-700 text-white font-semibold py-3 px-8 rounded-full transition-colors duration-300"> View Full Menu </button> </div> </div>Key features of this implementation:
-
Responsive Grid Layout:
- 1 column on mobile
- 2 columns on small screens
- 3 columns on large screens
- 4 columns on extra-large screens
-
Hover Effects:
- Smooth image zoom on hover
- Gradient overlay with text reveal
- Shadow enhancement
- Text slide-up animation
-
Styling:
- Warm amber color scheme suitable for bakery
- Rounded corners and soft shadows
- Proper spacing and typography
- Responsive text sizing
-
Accessibility:
- Semantic HTML structure
- Proper alt text for images
- Sufficient color contrast
- Focus states for interactive elements
-
Performance:
- Fixed image dimensions
- Optimized hover animations
- Efficient Tailwind classes
To use this component in your Astro page:
--- // src/pages/index.astro import CakeGallery from '../components/CakeGallery.astro'; --- <CakeGallery />Tips for customization:
- Replace placeholder images with your actual cake photos
- Adjust color scheme by modifying Tailwind classes (amber-* → your preferred colors)
- Add actual category filtering functionality using JavaScript if needed
- Connect the "View Full Menu" button to your menu page
- Add actual pricing information in the overlay
- Implement lightbox functionality for image enlargement
For best results:
- Use high-quality, consistent aspect ratio images (4:3 or 3:2 recommended)
- Optimize images for web (compressed JPEGs or WebP format)
- Ensure proper color calibration of food photography
- Add subtle animations using Tailwind's animation utilities
- Include actual nutritional/allergy information if relevant
This component creates an attractive, modern gallery that showcases your bakery products while maintaining good performance and responsiveness across all devices.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.