1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
# Frontend Component Structure
This document outlines the component structure for the e-commerce frontend, inspired by turntupfashion.com.
## Core Components
### Layout Components
- `Layout.jsx` - Main layout wrapper with header and footer
- `Header.jsx` - Site header with navigation, search, and cart
- `Footer.jsx` - Site footer with links and newsletter signup
- `MobileMenu.jsx` - Responsive navigation for mobile devices
- `Breadcrumbs.jsx` - Navigation breadcrumbs component
### Navigation Components
- `MainNav.jsx` - Primary navigation menu
- `CategoryMenu.jsx` - Category dropdown navigation
- `CountrySelector.jsx` - Country and currency selector component
- `PromoBanner.jsx` - Promotional announcement banner (e.g., "A24" discount code)
### Product Components
- `ProductCard.jsx` - Card display for product in listings
- `ProductGrid.jsx` - Grid layout for product listings
- `ProductGallery.jsx` - Image gallery for product detail page
- `ProductDetails.jsx` - Product information display
- `ProductVariants.jsx` - Size/color selection component
- `AddToCartButton.jsx` - Button with quantity selector
### Cart Components
- `CartIcon.jsx` - Cart icon with item count indicator
- `CartDrawer.jsx` - Slide-out cart drawer
- `CartItem.jsx` - Individual item in cart
- `CartSummary.jsx` - Order summary with subtotal and discounts
### Checkout Components
- `CheckoutForm.jsx` - Multi-step checkout form
- `ShippingForm.jsx` - Shipping information form
- `PaymentForm.jsx` - Payment information with Stripe integration
- `OrderSummary.jsx` - Order review component
### User Account Components
- `LoginForm.jsx` - User login form
- `RegisterForm.jsx` - New user registration
- `AccountDashboard.jsx` - User account overview
- `OrderHistory.jsx` - Past order display
### UI Components
- `Button.jsx` - Styled button component
- `Input.jsx` - Form input field
- `Select.jsx` - Dropdown select component
- `Modal.jsx` - Popup modal component
- `Spinner.jsx` - Loading spinner
- `Toast.jsx` - Notification toast
## Page Structure
### Home Page (`pages/index.js`)
```jsx
<Layout>
<PromoBanner code="A24" message="Special discount on all items!" />
<HeroSection />
<FeaturedProducts />
<NewArrivals />
<CollectionShowcase />
<Newsletter />
</Layout>
```
### Product Listing Page (`pages/products/index.js`)
```jsx
<Layout>
<Breadcrumbs />
<div className="grid grid-cols-12 gap-6">
<div className="col-span-3">
<FilterSidebar />
</div>
<div className="col-span-9">
<ProductSorting />
<ProductGrid products={products} />
<Pagination />
</div>
</div>
</Layout>
```
### Product Detail Page (`pages/products/[slug].js`)
```jsx
<Layout>
<Breadcrumbs />
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
<ProductGallery images={product.images} />
<div>
<ProductDetails product={product} />
<ProductVariants variants={product.variants} />
<AddToCartButton product={product} />
<ProductTabs tabs={['Description', 'Details', 'Reviews']} />
</div>
</div>
<RelatedProducts products={relatedProducts} />
</Layout>
```
### Cart Page (`pages/cart.js`)
```jsx
<Layout>
<Breadcrumbs />
<h1>Your Cart</h1>
{cartItems.length > 0 ? (
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
<div className="lg:col-span-2">
{cartItems.map(item => (
<CartItem key={item.id} item={item} />
))}
</div>
<div>
<CartSummary />
<PromoCodeInput />
<CheckoutButton />
</div>
</div>
) : (
<EmptyCart />
)}
</Layout>
```
### Checkout Page (`pages/checkout.js`)
```jsx
<Layout>
<Breadcrumbs />
<CheckoutSteps currentStep={currentStep} />
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
<div className="lg:col-span-2">
{currentStep === 'information' && <ShippingForm />}
{currentStep === 'shipping' && <ShippingMethodForm />}
{currentStep === 'payment' && <PaymentForm />}
</div>
<div>
<OrderSummary />
</div>
</div>
</Layout>
```
## Component Examples
### Promo Banner Component
```jsx
// components/PromoBanner.jsx
import { useState } from 'react';
export default function PromoBanner({ code, message }) {
const [isVisible, setIsVisible] = useState(true);
if (!isVisible) return null;
return (
<div className="bg-indigo-600 text-white text-center py-2 px-4 relative">
<span>{message} Use code <strong>{code}</strong> at checkout</span>
<button
onClick={() => setIsVisible(false)}
className="absolute right-4 top-1/2 transform -translate-y-1/2"
aria-label="Dismiss banner"
>
<svg className="h-4 w-4" viewBox="0 0 20 20" fill="currentColor">
<path fillRule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clipRule="evenodd" />
</svg>
</button>
</div>
);
}
```
### Product Card Component
```jsx
// components/ProductCard.jsx
import Image from 'next/image';
import Link from 'next/link';
export default function ProductCard({ product }) {
return (
<div className="group">
<div className="relative overflow-hidden rounded-lg">
<Link href={`/products/${product.slug}`}>
<div className="aspect-w-1 aspect-h-1 w-full">
<Image
src={product.images[0].url}
alt={product.name}
layout="fill"
objectFit="cover"
className="group-hover:scale-105 transition-transform duration-300"
/>
</div>
{product.compareAtPrice && (
<span className="absolute top-2 left-2 bg-red-500 text-white px-2 py-1 text-xs font-medium rounded">
Sale
</span>
)}
</Link>
</div>
<div className="mt-4 flex justify-between">
<div>
<h3 className="text-sm font-medium text-gray-700">
<Link href={`/products/${product.slug}`}>
{product.name}
</Link>
</h3>
</div>
<div>
{product.compareAtPrice ? (
<div className="flex space-x-2">
<span className="text-sm font-medium text-red-600">
${product.price.toFixed(2)}
</span>
<span className="text-sm text-gray-500 line-through">
${product.compareAtPrice.toFixed(2)}
</span>
</div>
) : (
<span className="text-sm font-medium text-gray-900">
${product.price.toFixed(2)}
</span>
)}
</div>
</div>
</div>
);
}
```
### Add to Cart Button
```jsx
// components/AddToCartButton.jsx
import { useState } from 'react';
import { useCart } from '@/contexts/CartContext';
export default function AddToCartButton({ product, selectedVariant }) {
const [quantity, setQuantity] = useState(1);
const { addItem } = useCart();
const handleAddToCart = () => {
if (!selectedVariant) {
// Show error - need to select size/color
return;
}
addItem(product, quantity, selectedVariant);
// Show success toast
};
return (
<div className="mt-6">
<div className="flex items-center mb-4">
<button
onClick={() => setQuantity(Math.max(1, quantity - 1))}
className="w-10 h-10 border border-gray-300 flex items-center justify-center"
>
-
</button>
<input
type="number"
value={quantity}
onChange={(e) => setQuantity(Math.max(1, parseInt(e.target.value) || 1))}
className="w-16 h-10 border-t border-b border-gray-300 text-center"
/>
<button
onClick={() => setQuantity(quantity + 1)}
className="w-10 h-10 border border-gray-300 flex items-center justify-center"
>
+
</button>
</div>
<button
onClick={handleAddToCart}
className="w-full bg-black text-white py-3 px-6 hover:bg-gray-800 transition"
>
Add to Cart
</button>
</div>
);
}
```
## CSS and Styling
The project uses Tailwind CSS for styling with some additional custom styles where needed. Key style considerations:
1. **Color Scheme**
- Primary: Black (#000000)
- Accent: Indigo (#4F46E5)
- Backgrounds: White/light grays
- Text: Dark gray for body, black for headings
2. **Typography**
- Primary font: Inter (sans-serif)
- Heading sizes: h1 (2rem), h2 (1.5rem), h3 (1.25rem)
- Body text: 1rem (16px)
3. **Spacing System**
- Based on Tailwind's default spacing scale
- Consistent padding/margins for sections (py-16, px-4)
4. **Responsive Breakpoints**
- Mobile first approach
- Key breakpoints: sm (640px), md (768px), lg (1024px), xl (1280px)
## Component State Management
The application uses React Context for global state management:
1. **CartContext** - Manages shopping cart items and operations
2. **AuthContext** - Handles user authentication state
3. **UIContext** - Controls UI elements like modals and notifications
For complex state logic, we use the reducer pattern with the `useReducer` hook.
|