@thorprovider/create-storefront 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -0
- package/bin/install.js +116 -0
- package/commands/sf-add-view.md +21 -0
- package/commands/sf-init.md +16 -0
- package/commands/sf-theme.md +15 -0
- package/commands/sf-view.md +20 -0
- package/package.json +40 -0
- package/recipes/archetype.schema.json +39 -0
- package/recipes/archetypes.json +148 -0
- package/recipes/recipe.schema.json +59 -0
- package/recipes/recipes.json +90 -0
- package/recipes/sections.json +46 -0
- package/recipes/validate.mjs +190 -0
- package/skills/building-storefronts/SKILL.md +178 -0
- package/skills/building-storefronts/references/frontend-integration.md +229 -0
- package/skills/json-render-core/SKILL.md +291 -0
- package/skills/json-render-next/SKILL.md +194 -0
- package/skills/json-render-react/SKILL.md +298 -0
- package/skills/json-render-remotion/SKILL.md +111 -0
- package/skills/json-render-shadcn/SKILL.md +159 -0
- package/skills/json-render-solid/SKILL.md +204 -0
- package/skills/nextjs-shadcn/SKILL.md +303 -0
- package/skills/nextjs-shadcn/references/architecture.md +499 -0
- package/skills/nextjs-shadcn/references/project-setup.md +127 -0
- package/skills/nextjs-shadcn/references/shadcn-platform.md +258 -0
- package/skills/nextjs-shadcn/references/sidebar.md +274 -0
- package/skills/nextjs-shadcn/references/styling.md +555 -0
- package/skills/sf-scaffold/SKILL.md +118 -0
- package/skills/sf-theme-gen/SKILL.md +44 -0
- package/skills/sf-view-gen/SKILL.md +94 -0
- package/skills/shadcn-component-discovery/SKILL.md +273 -0
- package/skills/shadcn-component-discovery/references/registries.md +226 -0
- package/skills/shadcn-theming/SKILL.md +104 -0
- package/skills/shadcn-theming/references/templates/theme-setup.md +109 -0
- package/skills/shadcn-theming/references/theming-guide.md +90 -0
- package/skills/storefront-best-practices/SKILL.md +421 -0
- package/skills/storefront-best-practices/reference/components/breadcrumbs.md +123 -0
- package/skills/storefront-best-practices/reference/components/cart-popup.md +189 -0
- package/skills/storefront-best-practices/reference/components/country-selector.md +298 -0
- package/skills/storefront-best-practices/reference/components/footer.md +112 -0
- package/skills/storefront-best-practices/reference/components/hero.md +241 -0
- package/skills/storefront-best-practices/reference/components/megamenu.md +239 -0
- package/skills/storefront-best-practices/reference/components/navbar.md +397 -0
- package/skills/storefront-best-practices/reference/components/popups.md +221 -0
- package/skills/storefront-best-practices/reference/components/product-card.md +125 -0
- package/skills/storefront-best-practices/reference/components/product-reviews.md +217 -0
- package/skills/storefront-best-practices/reference/components/product-slider.md +174 -0
- package/skills/storefront-best-practices/reference/components/search.md +101 -0
- package/skills/storefront-best-practices/reference/connecting-to-backend.md +391 -0
- package/skills/storefront-best-practices/reference/design.md +388 -0
- package/skills/storefront-best-practices/reference/features/promotions.md +307 -0
- package/skills/storefront-best-practices/reference/features/wishlist.md +230 -0
- package/skills/storefront-best-practices/reference/layouts/account.md +380 -0
- package/skills/storefront-best-practices/reference/layouts/cart.md +316 -0
- package/skills/storefront-best-practices/reference/layouts/checkout.md +486 -0
- package/skills/storefront-best-practices/reference/layouts/home-page.md +264 -0
- package/skills/storefront-best-practices/reference/layouts/order-confirmation.md +231 -0
- package/skills/storefront-best-practices/reference/layouts/product-details.md +527 -0
- package/skills/storefront-best-practices/reference/layouts/product-listing.md +520 -0
- package/skills/storefront-best-practices/reference/layouts/static-pages.md +356 -0
- package/skills/storefront-best-practices/reference/medusa.md +307 -0
- package/skills/storefront-best-practices/reference/mobile-responsiveness.md +183 -0
- package/skills/storefront-best-practices/reference/seo.md +195 -0
- package/templates/app/app/[[...slug]]/page.tsx +17 -0
- package/templates/app/app/[[...slug]]/renderer.tsx +10 -0
- package/templates/app/app/globals.css +101 -0
- package/templates/app/app/layout.tsx +35 -0
- package/templates/app/lib/__STOREFRONT__/catalog.ts +132 -0
- package/templates/app/lib/__STOREFRONT__/handlers.ts +33 -0
- package/templates/app/lib/__STOREFRONT__/registry.tsx +134 -0
- package/templates/app/lib/__STOREFRONT__/runtime.ts +25 -0
- package/templates/app/lib/__STOREFRONT__/spec/home.ts +62 -0
- package/templates/app/lib/__STOREFRONT__/spec/index.ts +59 -0
- package/templates/app/lib/__STOREFRONT__/spec/types.ts +14 -0
- package/templates/app/lib/__STOREFRONT__/state.ts +35 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# Hero Section Component
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- [Overview](#overview)
|
|
6
|
+
- [Hero Types and When to Use](#hero-types-and-when-to-use)
|
|
7
|
+
- [Content Guidelines](#content-guidelines)
|
|
8
|
+
- [Multiple Heroes (Carousel)](#multiple-heroes-carousel)
|
|
9
|
+
- [Mobile Hero](#mobile-hero)
|
|
10
|
+
- [Performance](#performance)
|
|
11
|
+
- [Checklist](#checklist)
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
Hero section is the prominent banner at top of homepage, immediately below navigation. First content users see - sets tone for shopping experience.
|
|
16
|
+
|
|
17
|
+
**Assumed knowledge**: AI agents know how to build full-width banners with images and text overlays. This focuses on ecommerce hero patterns.
|
|
18
|
+
|
|
19
|
+
**Key requirements:**
|
|
20
|
+
- Above the fold (immediately visible)
|
|
21
|
+
- Clear value proposition or promotional message
|
|
22
|
+
- High-quality imagery
|
|
23
|
+
- Strong call-to-action
|
|
24
|
+
- Fast loading (critical for first impression)
|
|
25
|
+
|
|
26
|
+
## Hero Types and When to Use
|
|
27
|
+
|
|
28
|
+
### 1. Full-Width Banner (Most Common)
|
|
29
|
+
|
|
30
|
+
**Characteristics:**
|
|
31
|
+
- Spans entire viewport width
|
|
32
|
+
- Large background image or video
|
|
33
|
+
- Text overlay with headline + CTA
|
|
34
|
+
- Single focused message
|
|
35
|
+
|
|
36
|
+
**Best for:**
|
|
37
|
+
- Seasonal campaigns ("Summer Sale")
|
|
38
|
+
- New product arrivals
|
|
39
|
+
- Brand storytelling
|
|
40
|
+
- Single promotional focus
|
|
41
|
+
- Simple, bold message
|
|
42
|
+
|
|
43
|
+
**Example:** Background image of products, headline "40% Off Summer Sale", CTA "Shop Now"
|
|
44
|
+
|
|
45
|
+
### 2. Split Hero (Image + Content)
|
|
46
|
+
|
|
47
|
+
**Characteristics:**
|
|
48
|
+
- 50/50 or 60/40 split layout
|
|
49
|
+
- Image on one side, text content on other
|
|
50
|
+
- No text overlay on image
|
|
51
|
+
- Cleaner, easier to read
|
|
52
|
+
|
|
53
|
+
**Best for:**
|
|
54
|
+
- Product launches (show product clearly)
|
|
55
|
+
- Detailed messaging (more text space)
|
|
56
|
+
- Accessibility (no text-on-image contrast issues)
|
|
57
|
+
- Professional/B2B stores
|
|
58
|
+
|
|
59
|
+
**Example:** Product image (left 50%), headline + benefits + CTA (right 50%)
|
|
60
|
+
|
|
61
|
+
### 3. Minimal Hero
|
|
62
|
+
|
|
63
|
+
**Characteristics:**
|
|
64
|
+
- Large image, minimal text
|
|
65
|
+
- Image does storytelling
|
|
66
|
+
- Subtle headline, small CTA
|
|
67
|
+
- Emphasis on visual brand
|
|
68
|
+
|
|
69
|
+
**Best for:**
|
|
70
|
+
- Luxury brands (sophisticated aesthetic)
|
|
71
|
+
- Lifestyle brands (aspirational imagery)
|
|
72
|
+
- Photography-focused products
|
|
73
|
+
- Brand over promotion
|
|
74
|
+
|
|
75
|
+
### 4. Video Hero
|
|
76
|
+
|
|
77
|
+
**Characteristics:**
|
|
78
|
+
- Background video (muted, looping)
|
|
79
|
+
- Text overlay on video
|
|
80
|
+
- Fallback image for slow connections
|
|
81
|
+
|
|
82
|
+
**Best for:**
|
|
83
|
+
- Fashion brands (show products in motion)
|
|
84
|
+
- Lifestyle products (demonstrate usage)
|
|
85
|
+
- High-budget campaigns
|
|
86
|
+
- Brand storytelling with motion
|
|
87
|
+
|
|
88
|
+
**Important:** Auto-play muted, provide play/pause controls, optimize file size (<5MB), use poster image fallback.
|
|
89
|
+
|
|
90
|
+
### 5. Product Showcase Hero
|
|
91
|
+
|
|
92
|
+
**Characteristics:**
|
|
93
|
+
- Multiple featured products in hero
|
|
94
|
+
- Grid of 2-4 products
|
|
95
|
+
- Quick links to product pages
|
|
96
|
+
- Less promotional, more discovery
|
|
97
|
+
|
|
98
|
+
**Best for:**
|
|
99
|
+
- Multi-category stores
|
|
100
|
+
- Product-focused (not campaign-focused)
|
|
101
|
+
- Quick product discovery
|
|
102
|
+
- Minimal marketing, maximum browsing
|
|
103
|
+
|
|
104
|
+
## Content Guidelines
|
|
105
|
+
|
|
106
|
+
**Headline best practices:**
|
|
107
|
+
- Short and impactful (5-10 words)
|
|
108
|
+
- Clear value proposition ("Free Shipping on All Orders")
|
|
109
|
+
- Urgency if time-sensitive ("48-Hour Flash Sale")
|
|
110
|
+
- Benefit-focused ("Upgrade Your Style")
|
|
111
|
+
- Avoid generic ("Welcome to Our Store")
|
|
112
|
+
|
|
113
|
+
**Subtext (optional):**
|
|
114
|
+
- 10-20 words maximum
|
|
115
|
+
- Expand on headline benefit
|
|
116
|
+
- Add context or details
|
|
117
|
+
- Not always necessary (clean design)
|
|
118
|
+
|
|
119
|
+
**Call-to-action:**
|
|
120
|
+
- Single primary CTA button
|
|
121
|
+
- Action-oriented text ("Shop Now", "Explore Category", "Get Started")
|
|
122
|
+
- High contrast (stands out on image)
|
|
123
|
+
- Large enough (48px height minimum)
|
|
124
|
+
- Link to relevant landing page (sale, category, product listing)
|
|
125
|
+
|
|
126
|
+
**Image selection:**
|
|
127
|
+
- High quality, professional photography
|
|
128
|
+
- Shows products or lifestyle context
|
|
129
|
+
- Represents brand aesthetic
|
|
130
|
+
- Optimized for web (<500KB)
|
|
131
|
+
- Responsive (different crops for mobile)
|
|
132
|
+
- Ensure text overlay is readable (adequate contrast)
|
|
133
|
+
|
|
134
|
+
## Multiple Heroes (Carousel)
|
|
135
|
+
|
|
136
|
+
**Carousel pattern:**
|
|
137
|
+
- 2-4 slides rotating automatically
|
|
138
|
+
- Each slide = independent hero (own message, image, CTA)
|
|
139
|
+
- Auto-rotate every 5-7 seconds (slow enough to read)
|
|
140
|
+
- Manual controls (prev/next arrows, dot indicators)
|
|
141
|
+
- Pause on hover (accessibility)
|
|
142
|
+
|
|
143
|
+
**When to use carousel:**
|
|
144
|
+
- Multiple concurrent campaigns (Winter Sale + New Arrivals)
|
|
145
|
+
- Different audience segments (Men/Women/Kids)
|
|
146
|
+
- Seasonal variety showcase
|
|
147
|
+
- Limited above-fold space
|
|
148
|
+
|
|
149
|
+
**When NOT to use carousel:**
|
|
150
|
+
- Single focused campaign (just use one hero)
|
|
151
|
+
- Users rarely see slides beyond first (carousel blindness)
|
|
152
|
+
- Slower page load (multiple images)
|
|
153
|
+
- Accessibility concerns (auto-rotating content)
|
|
154
|
+
|
|
155
|
+
**Carousel best practices:**
|
|
156
|
+
- Max 3-4 slides (more = ignored)
|
|
157
|
+
- First slide most important (most viewed)
|
|
158
|
+
- Consistent layout across slides
|
|
159
|
+
- Clear indicators showing progress
|
|
160
|
+
- Don't rely on later slides for critical info
|
|
161
|
+
- Pause on interaction (hover, focus)
|
|
162
|
+
|
|
163
|
+
## Mobile Hero
|
|
164
|
+
|
|
165
|
+
**Mobile adjustments (CRITICAL):**
|
|
166
|
+
|
|
167
|
+
**Layout:**
|
|
168
|
+
- Full-width, portrait aspect (2:3 or 3:4)
|
|
169
|
+
- Vertical composition (text overlays center/bottom)
|
|
170
|
+
- Larger text for readability
|
|
171
|
+
- Simplified message (shorter headline)
|
|
172
|
+
|
|
173
|
+
**Split hero on mobile:**
|
|
174
|
+
- Stack vertically (image top, text bottom)
|
|
175
|
+
- Don't use side-by-side (too cramped)
|
|
176
|
+
|
|
177
|
+
**Performance:**
|
|
178
|
+
- Smaller images (<300KB)
|
|
179
|
+
- Different image crop for mobile portrait
|
|
180
|
+
- Use `srcset` or `<picture>` for responsive images
|
|
181
|
+
- Consider static image instead of video (mobile data)
|
|
182
|
+
|
|
183
|
+
**Touch interactions:**
|
|
184
|
+
- Large CTA button (48px height minimum)
|
|
185
|
+
- Easy carousel controls (if used)
|
|
186
|
+
- Swipe gesture for carousel slides
|
|
187
|
+
|
|
188
|
+
## Performance
|
|
189
|
+
|
|
190
|
+
**Critical for first impression:**
|
|
191
|
+
|
|
192
|
+
**Image optimization:**
|
|
193
|
+
- WebP format with JPEG fallback
|
|
194
|
+
- Lazy load below-fold content (not hero - it's above fold)
|
|
195
|
+
- Responsive images (mobile gets smaller size)
|
|
196
|
+
- Target: <500KB desktop, <300KB mobile
|
|
197
|
+
- Use CDN for faster delivery
|
|
198
|
+
|
|
199
|
+
**Video optimization:**
|
|
200
|
+
- <5MB file size maximum
|
|
201
|
+
- Muted, autoplay, loop
|
|
202
|
+
- Poster image (shows before video loads)
|
|
203
|
+
- Fallback to image on slow connections
|
|
204
|
+
- Consider not using on mobile (data/performance)
|
|
205
|
+
|
|
206
|
+
**LCP optimization:**
|
|
207
|
+
- Hero image is often Largest Contentful Paint
|
|
208
|
+
- Preload hero image: `<link rel="preload" as="image" href="hero.jpg">`
|
|
209
|
+
- Inline critical CSS for hero
|
|
210
|
+
- Avoid layout shift (set image dimensions)
|
|
211
|
+
|
|
212
|
+
**Target metrics:**
|
|
213
|
+
- LCP < 2.5 seconds
|
|
214
|
+
- No layout shift (CLS < 0.1)
|
|
215
|
+
- Fast interaction (hero CTA clickable immediately)
|
|
216
|
+
|
|
217
|
+
## Checklist
|
|
218
|
+
|
|
219
|
+
**Essential features:**
|
|
220
|
+
|
|
221
|
+
- [ ] Above the fold (immediately visible)
|
|
222
|
+
- [ ] Clear headline (5-10 words, value proposition)
|
|
223
|
+
- [ ] High-quality image (professional, on-brand)
|
|
224
|
+
- [ ] Primary CTA button (action-oriented, high contrast)
|
|
225
|
+
- [ ] Fast loading (<500KB image desktop, <300KB mobile)
|
|
226
|
+
- [ ] Responsive images (different sizes/crops for devices)
|
|
227
|
+
- [ ] Mobile: Portrait aspect ratio (2:3 or 3:4)
|
|
228
|
+
- [ ] Mobile: Vertical text placement (center/bottom)
|
|
229
|
+
- [ ] Mobile: Large CTA (48px height minimum)
|
|
230
|
+
- [ ] Text overlay readable (adequate contrast, background overlay)
|
|
231
|
+
- [ ] If carousel: Max 3-4 slides
|
|
232
|
+
- [ ] If carousel: Auto-rotate 5-7 seconds
|
|
233
|
+
- [ ] If carousel: Pause on hover/focus
|
|
234
|
+
- [ ] If carousel: Manual controls (arrows, dots)
|
|
235
|
+
- [ ] If video: Muted, autoplay, loop
|
|
236
|
+
- [ ] If video: Poster image fallback
|
|
237
|
+
- [ ] If video: <5MB file size
|
|
238
|
+
- [ ] Preload hero image (LCP optimization)
|
|
239
|
+
- [ ] No layout shift (set image dimensions)
|
|
240
|
+
- [ ] ARIA labels on carousel controls
|
|
241
|
+
- [ ] Keyboard accessible (Tab to CTA, arrow keys for carousel)
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# Megamenu Component
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- [Overview](#overview)
|
|
6
|
+
- [When to Use Megamenu](#when-to-use-megamenu)
|
|
7
|
+
- [Content Organization](#content-organization)
|
|
8
|
+
- [Layout Patterns](#layout-patterns)
|
|
9
|
+
- [Trigger Behavior](#trigger-behavior)
|
|
10
|
+
- [Mobile Alternative](#mobile-alternative)
|
|
11
|
+
- [Checklist](#checklist)
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
Megamenu is a large, full-width dropdown navigation showing multiple columns of categories, links, and promotional content. Opens from navbar trigger items (e.g., "Shop", "Men", "Women").
|
|
16
|
+
|
|
17
|
+
**Assumed knowledge**: AI agents know how to build dropdown menus with hover/click triggers. This focuses on ecommerce megamenu patterns.
|
|
18
|
+
|
|
19
|
+
**Key requirements:**
|
|
20
|
+
- Full-width display (spans viewport)
|
|
21
|
+
- Multiple columns for categories
|
|
22
|
+
- Positioned directly below navbar
|
|
23
|
+
- Optional promotional images
|
|
24
|
+
- Mobile alternative (hamburger menu, not megamenu)
|
|
25
|
+
|
|
26
|
+
## When to Use Megamenu
|
|
27
|
+
|
|
28
|
+
**Use megamenu when:**
|
|
29
|
+
- Large product catalog (10+ top-level categories)
|
|
30
|
+
- Deep hierarchy (parent → child → grandchild levels)
|
|
31
|
+
- Want to showcase featured products/campaigns
|
|
32
|
+
- Multiple segments (Men, Women, Kids, etc.)
|
|
33
|
+
- Visual storytelling needed
|
|
34
|
+
|
|
35
|
+
**Use simple dropdown when:**
|
|
36
|
+
- Small catalog (<10 categories)
|
|
37
|
+
- Flat category structure (1-2 levels)
|
|
38
|
+
- Text-only navigation sufficient
|
|
39
|
+
- Minimalist design preference
|
|
40
|
+
|
|
41
|
+
**Common megamenu triggers:**
|
|
42
|
+
- "Shop" (all categories)
|
|
43
|
+
- "Men", "Women", "Kids" (segmented)
|
|
44
|
+
- "New Arrivals" (curated)
|
|
45
|
+
- "Sale" (promotional)
|
|
46
|
+
|
|
47
|
+
## Content Organization
|
|
48
|
+
|
|
49
|
+
**Backend Integration (CRITICAL):**
|
|
50
|
+
|
|
51
|
+
Fetch categories dynamically from ecommerce backend - never hardcode categories. Categories change frequently (new products, seasonal updates, inventory changes). Fetch from API on component mount or during SSR.
|
|
52
|
+
|
|
53
|
+
**Column structure (3-5 columns recommended):**
|
|
54
|
+
|
|
55
|
+
**Column 1-3: Category columns**
|
|
56
|
+
- Parent category header (bold, non-clickable or clickable to "View All")
|
|
57
|
+
- Child categories below (clickable links)
|
|
58
|
+
- 5-10 links per column maximum
|
|
59
|
+
- Group related subcategories
|
|
60
|
+
|
|
61
|
+
**Example:**
|
|
62
|
+
|
|
63
|
+
```plaintext
|
|
64
|
+
Electronics (header)
|
|
65
|
+
Laptops
|
|
66
|
+
Desktops
|
|
67
|
+
Monitors
|
|
68
|
+
Accessories
|
|
69
|
+
View All Electronics
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Column 4-5: Promotional/Featured**
|
|
73
|
+
- Product image card (1-2 featured products)
|
|
74
|
+
- Campaign banner ("Summer Sale", "New Arrivals")
|
|
75
|
+
- "Shop the Look" curated sets
|
|
76
|
+
- Seasonal promotions
|
|
77
|
+
|
|
78
|
+
**Content limits:**
|
|
79
|
+
|
|
80
|
+
- Max 5 columns (avoid overcrowding)
|
|
81
|
+
- Max 10 links per column
|
|
82
|
+
- 1-2 promotional images maximum
|
|
83
|
+
- Keep height reasonable (<600px)
|
|
84
|
+
|
|
85
|
+
## Layout Patterns
|
|
86
|
+
|
|
87
|
+
### ⚠️ CRITICAL: Megamenu Positioning (Common Mistake)
|
|
88
|
+
|
|
89
|
+
**Common positioning errors that MUST be avoided:**
|
|
90
|
+
|
|
91
|
+
❌ **Mistake 1: Navbar doesn't have `position: relative`**
|
|
92
|
+
- Without positioning context on navbar, megamenu won't position correctly
|
|
93
|
+
- Megamenu will position relative to document body instead of navbar
|
|
94
|
+
|
|
95
|
+
❌ **Mistake 2: Megamenu positioned relative to trigger button**
|
|
96
|
+
- Causes megamenu to appear offset, not aligned to left edge
|
|
97
|
+
- Megamenu won't span full width of navbar
|
|
98
|
+
- Different trigger positions cause inconsistent megamenu placement
|
|
99
|
+
|
|
100
|
+
❌ **Mistake 3: Megamenu doesn't span full width**
|
|
101
|
+
- Using `width: auto` or no width constraint
|
|
102
|
+
- Missing `left: 0` and `right: 0` properties
|
|
103
|
+
- Results in narrow dropdown instead of full-width panel
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
**REQUIRED positioning pattern:**
|
|
108
|
+
|
|
109
|
+
**Visual structure:**
|
|
110
|
+
```
|
|
111
|
+
┌─────────────────────────────────────────────────┐
|
|
112
|
+
│ NAVBAR (position: relative) │
|
|
113
|
+
│ [Logo] [Shop ▼] [Men] [Women] [Cart] │
|
|
114
|
+
└─────────────────────────────────────────────────┘
|
|
115
|
+
┌───────────────────────────────────────────────┐
|
|
116
|
+
│ MEGAMENU (absolute, left: 0, full width) │
|
|
117
|
+
│ ┌─────────────────────────────────────────┐ │
|
|
118
|
+
│ │ Container (centered content) │ │
|
|
119
|
+
│ │ [Col1] [Col2] [Col3] [Promo] │ │
|
|
120
|
+
│ └─────────────────────────────────────────┘ │
|
|
121
|
+
└───────────────────────────────────────────────┘
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Required structure:**
|
|
125
|
+
|
|
126
|
+
1. **Navbar container**
|
|
127
|
+
- MUST have `position: relative`
|
|
128
|
+
- Creates positioning context for megamenu
|
|
129
|
+
- Contains both trigger button and megamenu dropdown
|
|
130
|
+
|
|
131
|
+
2. **Megamenu dropdown**
|
|
132
|
+
- MUST have `position: absolute`
|
|
133
|
+
- MUST have `left: 0` (aligns to left edge of navbar)
|
|
134
|
+
- MUST have `right: 0` OR `width: 100%` (spans full navbar width)
|
|
135
|
+
- MUST have `top: 100%` (positioned directly below navbar)
|
|
136
|
+
- Should have appropriate `z-index` (above content, below modals)
|
|
137
|
+
|
|
138
|
+
3. **Content wrapper (inside megamenu)**
|
|
139
|
+
- Use constrained width container (e.g., `max-width`, `container`)
|
|
140
|
+
- Center content with `margin: 0 auto`
|
|
141
|
+
- Contains grid/columns for megamenu content
|
|
142
|
+
|
|
143
|
+
**Why this pattern is mandatory:**
|
|
144
|
+
- Navbar `position: relative` creates positioning context
|
|
145
|
+
- Megamenu `absolute` + `left: 0` + full width ensures consistent, full-width layout
|
|
146
|
+
- Positioning relative to navbar (not trigger) prevents offset issues
|
|
147
|
+
- Inner container centers content while maintaining full-width background
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### Other Layout Considerations
|
|
152
|
+
|
|
153
|
+
- Positioned below navbar (no gap)
|
|
154
|
+
- White/light background, boxed padding
|
|
155
|
+
- Shadow or border for depth
|
|
156
|
+
- High z-index (above page content, below modals)
|
|
157
|
+
|
|
158
|
+
**Column layout:**
|
|
159
|
+
- Equal-width columns or flexible grid
|
|
160
|
+
- Adequate spacing (24-32px between columns)
|
|
161
|
+
- Left-aligned text in category columns
|
|
162
|
+
- Right column(s) for promotional content
|
|
163
|
+
- Responsive: Stack columns on tablet if needed
|
|
164
|
+
|
|
165
|
+
**Promotional images:**
|
|
166
|
+
- Right-aligned (1-2 columns)
|
|
167
|
+
- Aspect ratio: 2:3 or square
|
|
168
|
+
- Product images or lifestyle photography
|
|
169
|
+
- Clickable to product/category page
|
|
170
|
+
- Include caption or CTA ("Shop Now")
|
|
171
|
+
|
|
172
|
+
## Trigger Behavior
|
|
173
|
+
|
|
174
|
+
**Desktop hover (recommended):**
|
|
175
|
+
- Megamenu opens on trigger hover
|
|
176
|
+
- **CRITICAL: Megamenu MUST stay open while hovering over the dropdown content**
|
|
177
|
+
- Stays open while hovering trigger OR dropdown area
|
|
178
|
+
- Closes only when mouse leaves both trigger and dropdown areas
|
|
179
|
+
- Debounce close (200-300ms delay) to prevent accidental closure
|
|
180
|
+
- Smooth fade-in/out transition (200-300ms)
|
|
181
|
+
|
|
182
|
+
**Why this is critical:**
|
|
183
|
+
- If dropdown closes when moving from trigger to content, users can't access links
|
|
184
|
+
- Frustrating UX - users can't interact with megamenu items
|
|
185
|
+
- Common mistake: Only listening for hover on trigger, not on dropdown
|
|
186
|
+
|
|
187
|
+
**Desktop click (alternative):**
|
|
188
|
+
- Click trigger to toggle open/close
|
|
189
|
+
- Click outside to close
|
|
190
|
+
- Better for touch-enabled laptops
|
|
191
|
+
- Less accidental openings
|
|
192
|
+
|
|
193
|
+
**Hover flickering prevention:**
|
|
194
|
+
- No gap between navbar and dropdown
|
|
195
|
+
- Dropdown should slightly overlap navbar
|
|
196
|
+
- Debounce close delay prevents flickering
|
|
197
|
+
|
|
198
|
+
## Mobile Alternative
|
|
199
|
+
|
|
200
|
+
**Do NOT use megamenu on mobile:**
|
|
201
|
+
- Too large for mobile screens
|
|
202
|
+
- Hard to navigate multi-column layout
|
|
203
|
+
- Poor touch experience
|
|
204
|
+
|
|
205
|
+
**Mobile alternative (hamburger menu):**
|
|
206
|
+
- Hamburger icon opens slide-in drawer
|
|
207
|
+
- Vertical accordion for categories
|
|
208
|
+
- Parent category expands to show children
|
|
209
|
+
- Simple, scrollable list
|
|
210
|
+
- See navbar.md for mobile navigation patterns
|
|
211
|
+
|
|
212
|
+
**Breakpoint:**
|
|
213
|
+
- Megamenu: Desktop only (>1024px)
|
|
214
|
+
- Hamburger: Tablet and mobile (<1024px)
|
|
215
|
+
|
|
216
|
+
## Checklist
|
|
217
|
+
|
|
218
|
+
**Essential features:**
|
|
219
|
+
- [ ] Triggered from navbar items ("Shop", segments)
|
|
220
|
+
- [ ] **CRITICAL: Navbar container has `position: relative` (creates positioning context)**
|
|
221
|
+
- [ ] **CRITICAL: Megamenu has `position: absolute` with `left: 0` (NOT positioned relative to trigger button)**
|
|
222
|
+
- [ ] **CRITICAL: Megamenu spans full width (`right: 0` or `w-full`, NOT just `w-auto`)**
|
|
223
|
+
- [ ] **CRITICAL: Megamenu positioned at `top: 100%` or `top-full` (directly below navbar)**
|
|
224
|
+
- [ ] Full-width dropdown below navbar, spans entire navbar width
|
|
225
|
+
- [ ] 3-5 columns for organization
|
|
226
|
+
- [ ] Category hierarchy (parent → children links)
|
|
227
|
+
- [ ] Optional promotional images (1-2)
|
|
228
|
+
- [ ] **CRITICAL: Megamenu stays open when hovering over dropdown content (not just trigger)**
|
|
229
|
+
- [ ] Hover trigger with debounced close (200-300ms)
|
|
230
|
+
- [ ] Smooth fade-in/out transition
|
|
231
|
+
- [ ] No flickering (no gap between navbar and dropdown)
|
|
232
|
+
- [ ] Mobile: Use hamburger menu, NOT megamenu
|
|
233
|
+
- [ ] Keyboard accessible (Tab through links, Escape closes)
|
|
234
|
+
- [ ] `role="navigation"` on dropdown panel
|
|
235
|
+
- [ ] ARIA labels on trigger buttons
|
|
236
|
+
- [ ] Screen reader friendly (announce expand/collapse)
|
|
237
|
+
- [ ] Max 10 links per column
|
|
238
|
+
- [ ] Max 5 columns total
|
|
239
|
+
- [ ] Fetched dynamically from backend (don't hardcode categories)
|