@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.
Files changed (75) hide show
  1. package/README.md +119 -0
  2. package/bin/install.js +116 -0
  3. package/commands/sf-add-view.md +21 -0
  4. package/commands/sf-init.md +16 -0
  5. package/commands/sf-theme.md +15 -0
  6. package/commands/sf-view.md +20 -0
  7. package/package.json +40 -0
  8. package/recipes/archetype.schema.json +39 -0
  9. package/recipes/archetypes.json +148 -0
  10. package/recipes/recipe.schema.json +59 -0
  11. package/recipes/recipes.json +90 -0
  12. package/recipes/sections.json +46 -0
  13. package/recipes/validate.mjs +190 -0
  14. package/skills/building-storefronts/SKILL.md +178 -0
  15. package/skills/building-storefronts/references/frontend-integration.md +229 -0
  16. package/skills/json-render-core/SKILL.md +291 -0
  17. package/skills/json-render-next/SKILL.md +194 -0
  18. package/skills/json-render-react/SKILL.md +298 -0
  19. package/skills/json-render-remotion/SKILL.md +111 -0
  20. package/skills/json-render-shadcn/SKILL.md +159 -0
  21. package/skills/json-render-solid/SKILL.md +204 -0
  22. package/skills/nextjs-shadcn/SKILL.md +303 -0
  23. package/skills/nextjs-shadcn/references/architecture.md +499 -0
  24. package/skills/nextjs-shadcn/references/project-setup.md +127 -0
  25. package/skills/nextjs-shadcn/references/shadcn-platform.md +258 -0
  26. package/skills/nextjs-shadcn/references/sidebar.md +274 -0
  27. package/skills/nextjs-shadcn/references/styling.md +555 -0
  28. package/skills/sf-scaffold/SKILL.md +118 -0
  29. package/skills/sf-theme-gen/SKILL.md +44 -0
  30. package/skills/sf-view-gen/SKILL.md +94 -0
  31. package/skills/shadcn-component-discovery/SKILL.md +273 -0
  32. package/skills/shadcn-component-discovery/references/registries.md +226 -0
  33. package/skills/shadcn-theming/SKILL.md +104 -0
  34. package/skills/shadcn-theming/references/templates/theme-setup.md +109 -0
  35. package/skills/shadcn-theming/references/theming-guide.md +90 -0
  36. package/skills/storefront-best-practices/SKILL.md +421 -0
  37. package/skills/storefront-best-practices/reference/components/breadcrumbs.md +123 -0
  38. package/skills/storefront-best-practices/reference/components/cart-popup.md +189 -0
  39. package/skills/storefront-best-practices/reference/components/country-selector.md +298 -0
  40. package/skills/storefront-best-practices/reference/components/footer.md +112 -0
  41. package/skills/storefront-best-practices/reference/components/hero.md +241 -0
  42. package/skills/storefront-best-practices/reference/components/megamenu.md +239 -0
  43. package/skills/storefront-best-practices/reference/components/navbar.md +397 -0
  44. package/skills/storefront-best-practices/reference/components/popups.md +221 -0
  45. package/skills/storefront-best-practices/reference/components/product-card.md +125 -0
  46. package/skills/storefront-best-practices/reference/components/product-reviews.md +217 -0
  47. package/skills/storefront-best-practices/reference/components/product-slider.md +174 -0
  48. package/skills/storefront-best-practices/reference/components/search.md +101 -0
  49. package/skills/storefront-best-practices/reference/connecting-to-backend.md +391 -0
  50. package/skills/storefront-best-practices/reference/design.md +388 -0
  51. package/skills/storefront-best-practices/reference/features/promotions.md +307 -0
  52. package/skills/storefront-best-practices/reference/features/wishlist.md +230 -0
  53. package/skills/storefront-best-practices/reference/layouts/account.md +380 -0
  54. package/skills/storefront-best-practices/reference/layouts/cart.md +316 -0
  55. package/skills/storefront-best-practices/reference/layouts/checkout.md +486 -0
  56. package/skills/storefront-best-practices/reference/layouts/home-page.md +264 -0
  57. package/skills/storefront-best-practices/reference/layouts/order-confirmation.md +231 -0
  58. package/skills/storefront-best-practices/reference/layouts/product-details.md +527 -0
  59. package/skills/storefront-best-practices/reference/layouts/product-listing.md +520 -0
  60. package/skills/storefront-best-practices/reference/layouts/static-pages.md +356 -0
  61. package/skills/storefront-best-practices/reference/medusa.md +307 -0
  62. package/skills/storefront-best-practices/reference/mobile-responsiveness.md +183 -0
  63. package/skills/storefront-best-practices/reference/seo.md +195 -0
  64. package/templates/app/app/[[...slug]]/page.tsx +17 -0
  65. package/templates/app/app/[[...slug]]/renderer.tsx +10 -0
  66. package/templates/app/app/globals.css +101 -0
  67. package/templates/app/app/layout.tsx +35 -0
  68. package/templates/app/lib/__STOREFRONT__/catalog.ts +132 -0
  69. package/templates/app/lib/__STOREFRONT__/handlers.ts +33 -0
  70. package/templates/app/lib/__STOREFRONT__/registry.tsx +134 -0
  71. package/templates/app/lib/__STOREFRONT__/runtime.ts +25 -0
  72. package/templates/app/lib/__STOREFRONT__/spec/home.ts +62 -0
  73. package/templates/app/lib/__STOREFRONT__/spec/index.ts +59 -0
  74. package/templates/app/lib/__STOREFRONT__/spec/types.ts +14 -0
  75. package/templates/app/lib/__STOREFRONT__/state.ts +35 -0
@@ -0,0 +1,388 @@
1
+ # Design Guidelines
2
+
3
+ ## Contents
4
+
5
+ - [Overview](#overview)
6
+ - [Discovering Existing Brand Identity](#discovering-existing-brand-identity)
7
+ - [Critical Consistency Rules](#critical-consistency-rules)
8
+ - [When to Ask User Approval](#when-to-ask-user-approval)
9
+ - [New Project Setup](#new-project-setup)
10
+ - [Decision Tree](#decision-tree)
11
+ - [Common Mistakes](#common-mistakes)
12
+
13
+ ## Overview
14
+
15
+ **Purpose:** Provide guardrails to maintain brand consistency when building UI components. This prevents agents from accidentally introducing inconsistent colors, fonts, or design patterns.
16
+
17
+ **Critical principle:** ALWAYS discover and use existing design tokens before creating new components. NEVER introduce new colors or fonts without user approval.
18
+
19
+ **When to apply:** Before creating any UI component or design-related change.
20
+
21
+ ## Discovering Existing Brand Identity
22
+
23
+ Before implementing any component, identify existing brand colors, typography, and design patterns. AI agents can do this - focus on WHAT to look for, not detailed HOW.
24
+
25
+ ### What to Look For
26
+
27
+ **Colors:**
28
+ 1. **Tailwind config** (`tailwind.config.ts/js`) - Check `theme.extend.colors` or `theme.colors`
29
+ 2. **CSS variables** (globals.css, app.css) - Look for `:root { --color-primary: ... }`
30
+ 3. **Existing components** - Scan 2-3 components for color usage patterns
31
+
32
+ **Typography:**
33
+ 1. **Tailwind config** - Check `theme.extend.fontFamily`
34
+ 2. **Font imports** - Look in layout files or CSS (Next.js `next/font`, Google Fonts, local fonts)
35
+ 3. **CSS variables** - Check for `--font-sans`, `--font-heading`
36
+ 4. **Existing components** - Identify font usage patterns
37
+
38
+ **Other patterns:**
39
+ - Spacing scale (p-4, mb-6, etc.)
40
+ - Border radius (rounded-lg, rounded-xl)
41
+ - Shadows (shadow-md, shadow-lg)
42
+ - Interactive states (hover, focus colors)
43
+
44
+ ### Detecting Tailwind Version (CRITICAL)
45
+
46
+ **ALWAYS check the Tailwind CSS version before writing utility classes.**
47
+
48
+ Tailwind v3 and v4 have different syntax, and mixing them causes errors.
49
+
50
+ **How to detect version:**
51
+ 1. **Check `package.json`**: Look for `"tailwindcss": "^3.x.x"` or `"tailwindcss": "^4.x.x"`
52
+ 2. **Check config file**:
53
+ - v3: Uses `tailwind.config.js/ts` with `module.exports` or `export default`
54
+ - v4: May use CSS-based config with `@import "tailwindcss"`
55
+ 3. **Check existing components**: Look at class usage patterns
56
+
57
+ **Key differences:**
58
+
59
+ **Tailwind v3:**
60
+ ```tsx
61
+ // v3 syntax
62
+ <div className="bg-primary text-white">Content</div>
63
+ ```
64
+
65
+ **Tailwind v4:**
66
+ ```tsx
67
+ // v4 may use CSS variables differently
68
+ // Check the project's existing patterns
69
+ <div className="bg-primary text-white">Content</div>
70
+ ```
71
+
72
+ **Common mistake:** Using v3 syntax in v4 projects or vice versa. Always verify the version first.
73
+
74
+ ### Document Discovery
75
+
76
+ Create mental inventory of:
77
+ - **Primary color(s)** and their usage
78
+ - **Font families** (sans, serif, heading, mono)
79
+ - **Common patterns** (button styles, card designs, spacing)
80
+ - **Semantic names** (primary, secondary, accent vs blue-500, red-600)
81
+
82
+ ## Critical Consistency Rules
83
+
84
+ ### ALWAYS Follow These Rules
85
+
86
+ ✅ **NEVER use emojis in storefront UI** - Always use icons or images instead
87
+
88
+ ```tsx
89
+ // ✅ CORRECT - Using icon component or image
90
+ <button className="flex items-center gap-2">
91
+ <ShoppingCartIcon className="w-5 h-5" />
92
+ Add to Cart
93
+ </button>
94
+
95
+ // ❌ WRONG - Using emoji
96
+ <button>
97
+ 🛒 Add to Cart
98
+ </button>
99
+ ```
100
+
101
+ **Why:** Emojis appear differently across platforms, lack professional appearance, and can cause accessibility issues. Use icon libraries (Heroicons, Lucide, Font Awesome) or SVG images instead.
102
+
103
+ ✅ **USE existing design tokens** (colors, fonts, spacing from theme)
104
+
105
+ ```tsx
106
+ // ✅ CORRECT - Using theme colors
107
+ <button className="bg-primary text-white hover:bg-primary-dark">
108
+ Click Me
109
+ </button>
110
+
111
+ // ❌ WRONG - Arbitrary colors when theme exists
112
+ <button className="bg-[#3B82F6] text-white hover:bg-[#2563EB]">
113
+ Click Me
114
+ </button>
115
+ ```
116
+
117
+ ✅ **USE existing font definitions**, not new font families
118
+
119
+ ```tsx
120
+ // ✅ CORRECT - Using theme font
121
+ <h1 className="font-heading text-4xl font-bold">
122
+ Welcome
123
+ </h1>
124
+
125
+ // ❌ WRONG - Introducing new font
126
+ <h1 className="font-['Montserrat'] text-4xl font-bold">
127
+ Welcome
128
+ </h1>
129
+ ```
130
+
131
+ ✅ **MATCH patterns from existing components**
132
+
133
+ ```tsx
134
+ // If existing buttons use: bg-primary px-6 py-3 rounded-lg
135
+ // New buttons should use the same pattern
136
+ <button className="bg-primary px-6 py-3 rounded-lg">
137
+ New Button
138
+ </button>
139
+ ```
140
+
141
+ ### NEVER Do These Things
142
+
143
+ ❌ **DON'T introduce new colors without user approval**
144
+ - If you need a color not in the theme, ASK first
145
+ - Don't use arbitrary values like `bg-[#FF6B6B]` when theme has colors
146
+
147
+ ❌ **DON'T add new fonts without user approval**
148
+ - If current design uses Inter, don't add Montserrat without asking
149
+ - Don't use `font-['NewFont']` syntax when theme fonts exist
150
+
151
+ ❌ **DON'T use hard-coded values when theme tokens exist**
152
+ - Use `bg-primary` not `bg-[#3B82F6]`
153
+ - Use `p-6` not `p-[24px]`
154
+ - Use `font-heading` not `font-['Poppins']`
155
+
156
+ ❌ **DON'T create inconsistent patterns**
157
+ - If buttons use `rounded-lg`, all buttons should
158
+ - If cards use `shadow-md`, all cards should
159
+ - If hover effects use `hover:bg-primary-dark`, be consistent
160
+
161
+ ## When to Ask User Approval
162
+
163
+ **ALWAYS ask before:**
164
+
165
+ ### 1. Adding New Color
166
+
167
+ ```
168
+ "I notice the current palette doesn't include an orange accent color.
169
+ Should I add one, or would you prefer to use the existing accent color?"
170
+ ```
171
+
172
+ **Scenario:** You're building a promotional banner that needs an orange color, but theme only has blue/purple.
173
+
174
+ ### 2. Adding New Font
175
+
176
+ ```
177
+ "The current design uses Inter for all text. Do you want me to add
178
+ a different font for headings, or keep using Inter throughout?"
179
+ ```
180
+
181
+ **Scenario:** Building a hero section and wondering if headings should use a different font.
182
+
183
+ ### 3. Changing Existing Definitions
184
+
185
+ ```
186
+ "Should I update the primary color to #3B82F6, or create a
187
+ new color variant?"
188
+ ```
189
+
190
+ **Scenario:** Current primary is #2563EB but new design mockup shows #3B82F6.
191
+
192
+ ### 4. Creating New Pattern
193
+
194
+ ```
195
+ "The current components don't have a ghost button style (transparent with border).
196
+ Should I create one, or use an existing button variant?"
197
+ ```
198
+
199
+ **Scenario:** Need a subtle button style that doesn't exist yet.
200
+
201
+ ### DON'T Ask About
202
+
203
+ ❌ Standard web dev decisions (responsive breakpoints, hover effects)
204
+ ❌ Component structure or layout choices
205
+ ❌ Accessibility patterns (AI agents know WCAG)
206
+ ❌ Using existing theme colors/fonts in new ways
207
+
208
+ ## New Project Setup
209
+
210
+ When starting a new project WITHOUT existing theme:
211
+
212
+ ### Ask User These Questions
213
+
214
+ **1. Brand Colors:**
215
+ ```
216
+ "What are your brand colors? Please provide:
217
+ - Primary color (main brand color)
218
+ - Secondary color (optional)
219
+ - Any specific hex codes or color preferences?"
220
+ ```
221
+
222
+ **2. Font Preferences:**
223
+ ```
224
+ "Do you have font preferences?
225
+ - Modern and clean (Inter, Poppins)
226
+ - Classic and professional (Merriweather, Lora)
227
+ - Specific fonts?
228
+ - Or should I choose appropriate fonts?"
229
+ ```
230
+
231
+ **3. Design Style:**
232
+ ```
233
+ "What design style do you prefer?
234
+ - Minimal (lots of whitespace, clean lines)
235
+ - Bold (vibrant colors, large typography)
236
+ - Professional (conservative, trust-focused)
237
+ - Modern (rounded corners, gradients, shadows)"
238
+ ```
239
+
240
+ **4. Reference Sites (Optional):**
241
+ ```
242
+ "Do you have 2-3 example websites you like the look of?
243
+ This helps me understand your aesthetic preferences."
244
+ ```
245
+
246
+ ### Setup Theme Configuration
247
+
248
+ After gathering preferences, configure Tailwind theme:
249
+
250
+ ```typescript
251
+ // tailwind.config.ts
252
+ export default {
253
+ theme: {
254
+ extend: {
255
+ colors: {
256
+ primary: '#3B82F6', // User's primary color
257
+ secondary: '#8B5CF6', // User's secondary
258
+ accent: '#F59E0B', // Accent if needed
259
+ // Full scales if sophisticated design
260
+ brand: {
261
+ 50: '#eff6ff',
262
+ 500: '#3b82f6',
263
+ 900: '#1e3a8a',
264
+ }
265
+ },
266
+ fontFamily: {
267
+ sans: ['Inter', 'system-ui', 'sans-serif'],
268
+ heading: ['Poppins', 'sans-serif'],
269
+ },
270
+ },
271
+ },
272
+ }
273
+ ```
274
+
275
+ **Use Tailwind CSS for all new projects** - industry standard for ecommerce, highly customizable, excellent DX.
276
+
277
+ ## Decision Tree
278
+
279
+ **When creating any component:**
280
+
281
+ ```
282
+ 1. Does a theme configuration exist?
283
+ ├─ Yes → Extract colors/fonts from theme
284
+ │ Use existing tokens for new component
285
+ └─ No → Ask user for brand preferences
286
+ Create theme configuration
287
+
288
+ 2. Are there similar existing components?
289
+ ├─ Yes → Follow their patterns exactly
290
+ │ (spacing, colors, hover states)
291
+ └─ No → Check ANY existing components
292
+ Extract general patterns (spacing scale, hover effects)
293
+
294
+ 3. Do you need a color/font not in theme?
295
+ ├─ Yes → ASK user for approval before adding
296
+ │ Explain why you need it
297
+ └─ No → Proceed with existing tokens
298
+
299
+ 4. Are you unsure about a design pattern?
300
+ ├─ Yes → Check 2-3 existing components for guidance
301
+ │ Follow majority pattern
302
+ └─ No → Implement using theme tokens
303
+ Maintain consistency with existing components
304
+ ```
305
+
306
+ ## Common Mistakes
307
+
308
+ ### ❌ Using Arbitrary Values When Theme Exists
309
+
310
+ **Problem:** Using `bg-[#3B82F6]` when `bg-primary` exists.
311
+
312
+ **Why it's wrong:** Bypasses theme, creates inconsistency, harder to maintain.
313
+
314
+ **Fix:** Always use semantic names from theme.
315
+
316
+ ### ❌ Introducing New Colors Without Permission
317
+
318
+ **Problem:** Adding `text-orange-500` when theme doesn't have orange.
319
+
320
+ **Why it's wrong:** User may not want orange in their brand, creates color chaos.
321
+
322
+ **Fix:** Ask user first: "Should I add an orange color, or use existing accent?"
323
+
324
+ ### ❌ Not Checking Existing Patterns
325
+
326
+ **Problem:** Creating buttons with `rounded-full` when all other buttons use `rounded-lg`.
327
+
328
+ **Why it's wrong:** Visual inconsistency confuses users.
329
+
330
+ **Fix:** Check 2-3 existing buttons, use same rounding.
331
+
332
+ ### ❌ Adding Fonts Without Permission
333
+
334
+ **Problem:** Using `font-['Montserrat']` when theme uses Inter everywhere.
335
+
336
+ **Why it's wrong:** Fonts are brand identity - can't arbitrarily change.
337
+
338
+ **Fix:** Use existing `font-heading` or `font-sans`, or ask to add Montserrat.
339
+
340
+ ### ❌ Using Inline Styles Instead of Theme
341
+
342
+ **Problem:** `style={{ backgroundColor: '#3B82F6', padding: '24px' }}`
343
+
344
+ **Why it's wrong:** Bypasses Tailwind theme, not responsive, harder to maintain.
345
+
346
+ **Fix:** Use Tailwind classes: `bg-primary p-6`
347
+
348
+ ### ❌ Mixing Tailwind v3 and v4 Syntax
349
+
350
+ **Problem:** Using Tailwind v3 syntax in a v4 project, or vice versa.
351
+
352
+ **Why it's wrong:** Different versions have different configuration and syntax patterns. Mixing them causes build errors and unexpected styling behavior.
353
+
354
+ **Fix:** Check `package.json` for Tailwind version first. Look at existing components to understand the syntax patterns used in the project. Match the version-specific patterns consistently.
355
+
356
+ ### ❌ Inconsistent Interactive States
357
+
358
+ **Problem:** Some buttons use `hover:bg-primary-600`, others use `hover:brightness-110`.
359
+
360
+ **Why it's wrong:** Inconsistent user experience.
361
+
362
+ **Fix:** Check existing buttons, use same hover pattern everywhere.
363
+
364
+ ### ❌ Creating Theme Changes Without Approval
365
+
366
+ **Problem:** Adding new color to `tailwind.config.ts` without asking.
367
+
368
+ **Why it's wrong:** Theme changes affect entire project, need user agreement.
369
+
370
+ **Fix:** Ask first, explain rationale, get approval.
371
+
372
+ ## Summary Checklist
373
+
374
+ **Before creating any component:**
375
+
376
+ - [ ] **Detected Tailwind CSS version (v3 or v4) from package.json**
377
+ - [ ] Checked for existing theme configuration (Tailwind config or CSS variables)
378
+ - [ ] Extracted existing colors and documented them
379
+ - [ ] Extracted existing fonts and documented them
380
+ - [ ] Reviewed 2-3 existing components for patterns
381
+ - [ ] Identified spacing scale, border radius, shadow patterns
382
+ - [ ] Confirmed I'm using theme tokens, not arbitrary values
383
+ - [ ] Matched hover/focus states from existing components
384
+ - [ ] Verified color contrast meets WCAG 2.1 AA (4.5:1 for text) - Use [WebAIM Contrast Checker](https://webaim.org/resources/contrastchecker/)
385
+ - [ ] Asked user before adding any new colors or fonts
386
+ - [ ] Maintained visual consistency across all components
387
+
388
+ **This is about CONSISTENCY, not creating new designs.** Match what exists, ask before changing.
@@ -0,0 +1,307 @@
1
+ # Promotions Feature
2
+
3
+ ## Contents
4
+
5
+ - [Overview](#overview)
6
+ - [Promotion Types and When to Use](#promotion-types-and-when-to-use)
7
+ - [Sale Price Display](#sale-price-display)
8
+ - [Promo Code Input](#promo-code-input)
9
+ - [Free Shipping Threshold](#free-shipping-threshold)
10
+ - [Promotional Banners](#promotional-banners)
11
+ - [Countdown Timers](#countdown-timers)
12
+ - [Mobile Considerations](#mobile-considerations)
13
+ - [Checklist](#checklist)
14
+
15
+ ## Overview
16
+
17
+ Promotions are temporary price reductions, discounts, or special offers designed to drive sales and incentivize purchases. Effective promotion UI clearly communicates value, creates urgency, and makes redemption easy.
18
+
19
+ **Backend Integration (CRITICAL):**
20
+
21
+ All promotion logic and data must come from the ecommerce backend. Do this based on backend integrated. Fetch active promotions, discount codes, and price rules from backend API. Never hardcode promotion logic in frontend.
22
+
23
+ ### Key Ecommerce Requirements
24
+
25
+ - Clear discount communication (strikethrough pricing, percentage off)
26
+ - Promo code input (cart/checkout)
27
+ - Free shipping threshold progress (increase AOV)
28
+ - Countdown timers (create urgency)
29
+ - Automatic discount application
30
+ - Sale badges (product discovery)
31
+
32
+ ### Purpose
33
+
34
+ **Conversion optimization:**
35
+ - Drive sales and increase conversion rate
36
+ - Increase average order value (free shipping thresholds, tiered discounts)
37
+ - Acquire new customers (first-order discounts)
38
+ - Create urgency (limited-time offers)
39
+ - Clear inventory (seasonal sales)
40
+ - Reward loyalty (VIP codes, member discounts)
41
+
42
+ ## Promotion Types and When to Use
43
+
44
+ ### Sales (Price Reductions)
45
+
46
+ **What it is**: Select products with reduced prices, automatically applied. No code needed.
47
+
48
+ **Use when:**
49
+ - Seasonal sales (Black Friday, holiday sales)
50
+ - Clearance or end-of-season inventory
51
+ - Product-specific promotions
52
+ - You want reduced prices visible on product pages (increases click-through)
53
+
54
+ **Display:**
55
+ - Strikethrough original price (provides context for savings)
56
+ - Sale price bold and prominent (red or brand color)
57
+ - Sale badge on product cards ("Sale", "30% Off")
58
+
59
+ **Medusa implementation:**
60
+ Use Price Lists with special prices for products. Provides automatic strikethrough pricing in cart and on product pages.
61
+
62
+ ### Discount Codes
63
+
64
+ **What it is**: Customer enters code to unlock discount (percentage, fixed amount, or free shipping).
65
+
66
+ **Use when:**
67
+ - Newsletter signups ("Get 10% off with WELCOME10")
68
+ - VIP or loyalty program members (exclusive codes)
69
+ - Targeted marketing campaigns (email, social media)
70
+ - First-time customer incentives
71
+ - Friends and family discounts (limited distribution)
72
+
73
+ **Display:**
74
+ - Promo code input field in cart/checkout
75
+ - Success message: "Code applied: WELCOME10"
76
+ - Discount shown in order summary with code name
77
+ - Remove option (X icon or "Remove" link)
78
+
79
+ **Medusa implementation:**
80
+ Discount/promo code system with advanced logic (order-level discounts, usage limits, expiration dates).
81
+
82
+ ### Automatic Discounts
83
+
84
+ **What it is**: Discount automatically applied when conditions met. No code entry required.
85
+
86
+ **Use when:**
87
+ - Free shipping thresholds ("Free shipping over $50")
88
+ - Volume discounts ("Spend $100, get $20 off")
89
+ - Buy One Get One (BOGO) offers
90
+ - Encouraging larger cart values (increase AOV)
91
+
92
+ **Display:**
93
+ - Banner announcing the promotion
94
+ - Progress indicator toward threshold (see Free Shipping Threshold section)
95
+ - "Discount applied" message in cart
96
+ - Automatic addition to order summary
97
+
98
+ ### Buy X, Get Y (BOGO)
99
+
100
+ **What it is**: Purchase certain products to unlock free/discounted items.
101
+
102
+ **Use when:**
103
+ - Moving inventory (clear out slow-moving products)
104
+ - Cross-selling related products ("Buy sunscreen, get beach bag 50% off")
105
+ - Increasing units per transaction
106
+
107
+ **Display:**
108
+ - Clear promotion text on product page ("Buy 2, Get 1 Free")
109
+ - Free/discounted item shown in cart with explanation
110
+ - Discount line in order summary
111
+
112
+ **Medusa implementation:**
113
+ Buy X Get Y automatic discount. Free/discounted item must be added to cart to activate.
114
+
115
+ ## Sale Price Display
116
+
117
+ ### Strikethrough Pricing Pattern
118
+
119
+ **Format:**
120
+ ```
121
+ $49.99 $34.99
122
+ (Original, strikethrough) (Sale price, bold)
123
+ ```
124
+
125
+ **Design:**
126
+ - Original price: Strikethrough, muted gray color, smaller
127
+ - Sale price: Bold, larger, red or accent color
128
+ - Clear visual hierarchy (sale price dominates)
129
+
130
+ **Placement:**
131
+ - Product cards: Below image
132
+ - Product page: Near "Add to Cart" button
133
+ - Cart: Item price column
134
+
135
+ ### Percentage Off Display
136
+
137
+ Show savings to emphasize value.
138
+
139
+ **Options:**
140
+ - "Save 30%" badge
141
+ - "30% off" label
142
+ - "$15 off" (absolute savings)
143
+
144
+ **Placement:**
145
+ - Badge on product image (top-left or top-right corner)
146
+ - Near price (inline or below)
147
+ - In cart summary ("Total savings: $45")
148
+
149
+ ### Sale Badge
150
+
151
+ Bright badge on product image (red, orange, yellow) in top corner. 48-64px desktop, 40-48px mobile. Text: "Sale", "30% Off", or "Save $15".
152
+
153
+ ## Promo Code Input
154
+
155
+ ### Placement and Design
156
+
157
+ **Location:**
158
+ Cart page order summary or checkout page. Position in right sidebar (desktop) or below items (mobile).
159
+
160
+ **Layout:**
161
+ - Label: "Promo code" or "Discount code"
162
+ - Text input (200-280px desktop, full-width mobile)
163
+ - "Apply" button inline or stacked (mobile)
164
+ - Auto-uppercase on submit (codes usually uppercase)
165
+
166
+ **Expandable pattern (optional):**
167
+ "Have a promo code?" link that expands to show input. Saves vertical space, reduces visual clutter.
168
+
169
+ ### Success and Error States
170
+
171
+ **Success:**
172
+ - Green checkmark or success message: "Code applied: WELCOME10"
173
+ - Discount shown in order summary with code name: "Discount (WELCOME10) -$10.00"
174
+ - Remove option: X icon or "Remove" link
175
+ - Update cart total immediately
176
+
177
+ **Error:**
178
+ - Red error message below input: "Invalid code", "Code expired", or "Minimum purchase not met"
179
+ - Input remains visible for retry
180
+ - Don't clear input field (user may have typo)
181
+
182
+ **Applied code display in order summary:**
183
+ ```
184
+ Subtotal $100.00
185
+ Discount (WELCOME10) -$10.00
186
+ Shipping $5.00
187
+ ─────────────────────
188
+ Total $95.00
189
+ ```
190
+
191
+ ## Free Shipping Threshold
192
+
193
+ **Purpose (CRITICAL)**: Increase average order value by encouraging customers to add more items to reach free shipping.
194
+
195
+ ### Progress Bar Pattern
196
+
197
+ **Display in cart:**
198
+ - "Add $25 more for FREE SHIPPING"
199
+ - Horizontal progress bar showing proximity to threshold
200
+ - Updates automatically as cart value changes
201
+ - Green when threshold reached
202
+
203
+ **Example:**
204
+ ```
205
+ Add $25.00 more for FREE SHIPPING
206
+ [███████░░░░░░░░] 50%
207
+ ```
208
+
209
+ **When threshold met:**
210
+ - "You've unlocked free shipping!" (success message)
211
+ - Green checkmark or badge
212
+ - Crossed-out shipping charge in order summary
213
+
214
+ **Why it works:**
215
+ - Visualizes proximity to goal (loss aversion)
216
+ - Increases AOV by 15-30% on average
217
+ - Reduces cart abandonment (free shipping is top reason to complete purchase)
218
+
219
+ ### Free Shipping Banner
220
+
221
+ Sitewide announcement: "Free shipping on orders over $50". Display in top banner or near cart icon. Visible on all pages for awareness.
222
+
223
+ ## Promotional Banners
224
+
225
+ ### Top Banner
226
+
227
+ Full-width strip at top of page (48-64px height). Bright color contrasting with navbar. Short message: "Free shipping on orders over $50" or "Sale: Up to 50% off - Shop Now".
228
+
229
+ **Position:**
230
+ - Above navbar (most common)
231
+ - Below navbar (alternative)
232
+ - Sticky (stays visible on scroll, optional)
233
+
234
+ **CTA:**
235
+ Link to sale page ("Shop Now", "Learn More") or whole banner clickable.
236
+
237
+ ### Hero Banner
238
+
239
+ Large hero section on homepage with promotional message. Background image, headline ("Black Friday Sale"), subheading ("Up to 60% off sitewide"), CTA button ("Shop the Sale"), optional countdown timer.
240
+
241
+ ### Inline Banners
242
+
243
+ Within page content (product pages, cart). Examples: Free shipping reminder on cart page, "Sale ends soon" on product page. Less prominent than hero.
244
+
245
+ ## Countdown Timers
246
+
247
+ Use for time-sensitive promotions to create urgency and FOMO.
248
+
249
+ **When to use:**
250
+ - Flash sales (24-hour sales)
251
+ - Limited-time offers
252
+ - Holiday promotions
253
+ - Never for permanent sales (fake urgency harms trust)
254
+
255
+ **Display format:**
256
+ - "Sale ends in: 2d 14h 32m 15s"
257
+ - Or simpler: "Ends in 2 days"
258
+ - Or: "Hurry! Only 14 hours left"
259
+
260
+ **Placement:**
261
+ Top banner, product page near price, cart page, or hero section.
262
+
263
+ **Implementation:**
264
+ Server-side time to prevent client manipulation, auto-hide when expired, update in real-time.
265
+
266
+ ## Mobile Considerations
267
+
268
+ **Top banner:**
269
+ Shorter text (fewer words), smaller height (40-48px), dismissible (X button).
270
+
271
+ **Sale badges:**
272
+ Slightly smaller (40-48px), still clearly visible, don't obstruct product image.
273
+
274
+ **Promo code input:**
275
+ Full-width input and button, stacked layout (input above button), large touch targets (48px height), expandable section to save space.
276
+
277
+ **Countdown timer:**
278
+ Simplified format ("Ends in 14 hours" vs full d:h:m:s), larger text for readability.
279
+
280
+ ## Checklist
281
+
282
+ **Essential features:**
283
+
284
+ - [ ] Strikethrough original price for sales
285
+ - [ ] Sale price bold, prominent, colored
286
+ - [ ] Sale badges on product images (40-64px)
287
+ - [ ] Percentage off displayed ("30% Off")
288
+ - [ ] Promo code input field in cart/checkout
289
+ - [ ] "Apply" button next to promo input
290
+ - [ ] Success message after applying code
291
+ - [ ] Error message for invalid codes
292
+ - [ ] Applied code displayed in order summary with name
293
+ - [ ] Remove code option (X icon or "Remove" link)
294
+ - [ ] Total savings highlighted in cart
295
+ - [ ] Free shipping progress bar (if applicable)
296
+ - [ ] Progress updates as cart value changes
297
+ - [ ] Success message when threshold met
298
+ - [ ] Countdown timer for time-limited offers (server-side)
299
+ - [ ] Promotional banners (top banner, hero)
300
+ - [ ] Backend integration (fetch promotions from API)
301
+ - [ ] Mobile: Full-width promo input, stacked layout
302
+ - [ ] Mobile: Large touch targets (48px)
303
+ - [ ] Expandable promo section (optional, saves space)
304
+ - [ ] ARIA labels on promo input
305
+ - [ ] Screen reader announcements for price changes
306
+ - [ ] Keyboard accessible (Tab, Enter)
307
+ - [ ] High contrast text (4.5:1 minimum)