@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,316 @@
1
+ # Cart Page
2
+
3
+ ## Contents
4
+
5
+ - [Overview](#overview)
6
+ - [Layout Patterns](#layout-patterns)
7
+ - [Cart Items Display](#cart-items-display)
8
+ - [Quantity Updates](#quantity-updates)
9
+ - [Order Summary](#order-summary)
10
+ - [Promo Code Input](#promo-code-input)
11
+ - [Checkout Button](#checkout-button)
12
+ - [Empty Cart State](#empty-cart-state)
13
+ - [Backend Integration](#backend-integration)
14
+ - [Mobile Cart](#mobile-cart)
15
+ - [Checklist](#checklist)
16
+
17
+ ## Overview
18
+
19
+ The cart page displays all items a customer has added to their shopping cart. Purpose: Review items, modify cart, apply promotions, proceed to checkout. Critical conversion point.
20
+
21
+ **⚠️ CRITICAL: Always display variant details (size, color, material, etc.) for each cart item, not just product titles.**
22
+
23
+ ### Key Ecommerce Functions
24
+
25
+ - Review items before purchase (reduces buyer's remorse)
26
+ - Update quantities or remove items (cart management)
27
+ - Apply promotional codes (increase order value)
28
+ - View pricing breakdown (transparency builds trust)
29
+ - Proceed to checkout (conversion path)
30
+ - Continue shopping if needed (reduce abandonment)
31
+
32
+ ## Layout Patterns
33
+
34
+ ### Two-Column Pattern (Desktop)
35
+
36
+ **Most common:**
37
+ - Left column (60-70%): Cart items list
38
+ - Right column (30-40%): Order summary (sticky)
39
+ - Below items: Promo code input, continue shopping
40
+ - Order summary stays visible during scroll
41
+
42
+ ### Mobile Layout
43
+
44
+ Single column (stacked):
45
+ - Cart items
46
+ - Order summary
47
+ - Promo code input
48
+ - Checkout button (sticky at bottom)
49
+ - Continue shopping
50
+
51
+ ## Cart Items Display
52
+
53
+ ### Cart Item Card
54
+
55
+ **CRITICAL: Always display variant details for each cart item.**
56
+
57
+ Products with variants (size, color, material, style, etc.) must show the selected variant options. Without this, customers can't confirm they have the correct items in their cart.
58
+
59
+ **Essential information per item:**
60
+ - Product image (thumbnail, 80-120px desktop, 60-80px mobile)
61
+ - Product title (linked to product page)
62
+ - **Variant details (REQUIRED)**: Size, color, material, or other variant options selected
63
+ - Format: "Size: Large, Color: Black" or "Large / Black"
64
+ - Display below title, smaller gray text
65
+ - Show ALL selected variant options
66
+ - Unit price
67
+ - Quantity selector
68
+ - Line total (unit price × quantity)
69
+ - Remove button (X icon)
70
+
71
+ **Layout:**
72
+ Horizontal card (image left, details right), clear visual separation between items, adequate spacing (16-24px).
73
+
74
+ **Why variant details are critical:**
75
+ - Customer confirmation before checkout
76
+ - Prevents returns from wrong variant purchases
77
+ - Allows easy correction if wrong variant in cart
78
+ - Essential for clothing, shoes, configurable products
79
+
80
+ ### Price Display
81
+
82
+ **Medusa pricing (CRITICAL):**
83
+ Medusa stores prices as-is (not in cents). Display prices directly without dividing by 100. Example: If Medusa returns 49.99, display $49.99 (not $0.4999). Different from Stripe which stores prices in cents.
84
+
85
+ **Sale prices:**
86
+ Show original price (strikethrough) and sale price prominently if on sale.
87
+
88
+ **Line total:**
89
+ Total for item (price × quantity), bold or larger font, update dynamically when quantity changes.
90
+
91
+ ## Quantity Updates
92
+
93
+ ### Quantity Selector
94
+
95
+ Standard +/- buttons with number display:
96
+ ```
97
+ [-] [2] [+]
98
+ ```
99
+
100
+ **Behavior:**
101
+ - Min: 1 (can't go below, or remove item instead)
102
+ - Max: Stock available or cart limit
103
+ - Manual input allowed (type number)
104
+ - Update on change (blur or button click)
105
+ - Show loading state briefly
106
+ - Update line total immediately
107
+
108
+ ### Auto-Update (Recommended)
109
+
110
+ Changes apply immediately, no "Update Cart" button needed. Better UX, less friction. Show brief loading indicator. Update order summary automatically.
111
+
112
+ **Error handling:**
113
+ "Only X available" if exceeds stock, reset to max available quantity, show error message near item.
114
+
115
+ ## Order Summary
116
+
117
+ ### Summary Card
118
+
119
+ Position: Right column on desktop (sticky), below cart items on mobile, fixed width (300-400px desktop).
120
+
121
+ ### Price Breakdown
122
+
123
+ **Line items:**
124
+ ```
125
+ Subtotal (3 items): $149.97
126
+ Shipping: $9.99
127
+ Tax: $12.00
128
+ ─────────────────────
129
+ Total: $171.96
130
+ ```
131
+
132
+ **Subtotal:**
133
+ Sum of all cart items with item count.
134
+
135
+ **Shipping:**
136
+ Estimated shipping cost, or "Calculated at checkout" (if address needed), or "Free shipping" (if applicable). Show free shipping threshold progress (see promotions.md).
137
+
138
+ **Tax:**
139
+ Estimated tax or "Calculated at checkout" (if address needed).
140
+
141
+ **Total:**
142
+ Grand total (bold, larger font), most prominent number.
143
+
144
+ ### Savings Display
145
+
146
+ If discounts applied:
147
+ - Show total savings: "You saved $20.00" (green text)
148
+ - Or: Discount line item in breakdown
149
+ - Positive reinforcement
150
+
151
+ ## Promo Code Input
152
+
153
+ ### Input Field Design
154
+
155
+ **Layout:**
156
+ Label ("Promo code" or "Discount code"), text input (200-280px desktop, full-width mobile), "Apply" button inline or stacked (mobile). Positioned below cart items or in order summary.
157
+
158
+ **Auto-uppercase:**
159
+ On submit (codes usually uppercase).
160
+
161
+ **Expandable pattern (optional):**
162
+ "Have a promo code?" link that expands to show input. Saves vertical space.
163
+
164
+ ### Success and Error States
165
+
166
+ **Success:**
167
+ - Green checkmark or success message: "Code applied: WELCOME10"
168
+ - Discount shown in order summary: "Discount (WELCOME10) -$10.00"
169
+ - Remove option: X icon or "Remove" link
170
+ - Update cart total immediately
171
+
172
+ **Error:**
173
+ - Red error message below input: "Invalid code", "Code expired", or "Minimum purchase not met"
174
+ - Input remains visible for retry
175
+ - Don't clear input field
176
+
177
+ **See also:** [promotions.md](../features/promotions.md) for detailed promo code patterns.
178
+
179
+ ## Checkout Button
180
+
181
+ ### Button Design
182
+
183
+ **Prominence:**
184
+ Large, full-width button, brand primary color (high contrast), 48-56px height (easy to tap). Text: "Proceed to Checkout" or "Checkout". Icon optional (lock or arrow).
185
+
186
+ **Position:**
187
+ Bottom of order summary (desktop), fixed at bottom of screen (mobile, optional), always visible during scroll.
188
+
189
+ **States:**
190
+ Default enabled, hover with slight color change, loading with spinner, disabled if cart empty or error.
191
+
192
+ **Security Indicators (optional):**
193
+ Lock icon with "Secure Checkout", payment badges (Visa, Mastercard, PayPal), "SSL Encrypted" message near button.
194
+
195
+ ## Empty Cart State
196
+
197
+ ### Display
198
+
199
+ When cart is empty:
200
+ - Centered content
201
+ - Icon or illustration (empty shopping bag)
202
+ - Heading: "Your cart is empty"
203
+ - Subtext: "Start adding items to your cart"
204
+ - CTA button: "Continue Shopping" or "Browse Products"
205
+
206
+ **Additional elements:**
207
+ - Link to popular categories
208
+ - Recently viewed products (if available)
209
+ - Bestsellers or featured products
210
+
211
+ ## Backend Integration
212
+
213
+ ### Data Source (CRITICAL)
214
+
215
+ **Fetch from ecommerce backend:**
216
+ Cart stored in backend (persistent), fetch on page load, sync with backend on changes.
217
+
218
+ **When to fetch:**
219
+ - Page load (initial cart data)
220
+ - After adding/updating/removing items
221
+ - After applying promo codes
222
+
223
+ ### State Management
224
+
225
+ **Client-side cart state:**
226
+ Store cart data in global state (React Context), keep cart ID in localStorage, update state after API responses, share cart state across components (page, popup, header badge).
227
+
228
+ **Cart ID persistence:**
229
+ ```javascript
230
+ localStorage.setItem('cart_id', cartId)
231
+ ```
232
+
233
+ Send cart ID with every cart API request, create new cart if ID doesn't exist, clear cart ID on checkout completion.
234
+
235
+ ### TanStack Query for Cart Data
236
+
237
+ **Recommended** for efficient caching and revalidation:
238
+
239
+ **Benefits:**
240
+ Built-in caching with automatic revalidation, optimistic updates support, automatic refetching on focus/reconnect, loading and error states handled, query invalidation for cart updates.
241
+
242
+ **Configuration:**
243
+ Use `useQuery` for fetching cart data, set `staleTime` to 30-60 seconds, use `queryClient.invalidateQueries(['cart'])` after updates.
244
+
245
+ **See also:** [connecting-to-backend.md](../connecting-to-backend.md) for detailed backend integration patterns.
246
+
247
+ ### Medusa Integration
248
+
249
+ Use `@medusajs/medusa-js` SDK:
250
+ - Cart endpoints: `/store/carts`, `/store/carts/{id}`
251
+ - Add to cart: POST `/store/carts/{id}/line-items`
252
+ - Update quantity: POST `/store/carts/{id}/line-items/{lineId}`
253
+ - Remove item: DELETE `/store/carts/{id}/line-items/{lineId}`
254
+ - Apply discount: POST `/store/carts/{id}/promotions`
255
+
256
+ **Response data:**
257
+ Cart ID, items (product details, variants, quantities), subtotal, tax, shipping, total, applied discounts, item availability status.
258
+
259
+ **Error handling:**
260
+ Network errors (show retry option), invalid cart ID (create new cart), out of stock (show error, prevent adding), API errors (user-friendly message).
261
+
262
+ ## Mobile Cart
263
+
264
+ ### Mobile Layout
265
+
266
+ **Structure:**
267
+ Full-width cart items (stacked), simplified item cards, order summary below items, sticky checkout button at bottom.
268
+
269
+ **Cart item cards:**
270
+ Smaller product images (60-80px), truncated product titles (1-2 lines), essential info only, quantity selector (smaller, 36-40px), remove button visible.
271
+
272
+ ### Sticky Checkout Bar
273
+
274
+ **Bottom sticky bar:**
275
+ Fixed at bottom of screen, total amount visible, "Checkout" button (full-width), appears after scrolling (optional), always accessible.
276
+
277
+ **Design:**
278
+ ```
279
+ [Total: $171.96] [Checkout]
280
+ ```
281
+
282
+ **Touch-friendly:**
283
+ 44px minimum touch targets, adequate spacing between buttons, large remove buttons (40px).
284
+
285
+ ## Checklist
286
+
287
+ **Essential elements:**
288
+
289
+ - [ ] **CRITICAL: Cart items display variant details (size, color, etc.) - not just product title**
290
+ - [ ] Cart items with images, titles, variant options, prices
291
+ - [ ] Quantity selector (+/- buttons, 40-44px minimum)
292
+ - [ ] Remove button per item (X icon, clearly visible)
293
+ - [ ] Order summary (subtotal, shipping, tax, total)
294
+ - [ ] Promo code input with "Apply" button
295
+ - [ ] Applied discount displayed in summary
296
+ - [ ] "Remove" option for applied code
297
+ - [ ] Prominent "Checkout" button (48-56px height)
298
+ - [ ] Continue shopping link
299
+ - [ ] Empty cart state (icon, message, CTA)
300
+ - [ ] Trust signals (secure checkout, payment badges)
301
+ - [ ] Auto-update quantities (no "Update Cart" button)
302
+ - [ ] Undo option after removing item (toast notification)
303
+ - [ ] Mobile: Sticky checkout button at bottom
304
+ - [ ] Mobile: Simplified cart item cards
305
+ - [ ] Backend integration (fetch cart from API)
306
+ - [ ] Cart ID persistence (localStorage)
307
+ - [ ] Real-time price updates
308
+ - [ ] Loading states (skeleton or spinner)
309
+ - [ ] Optimistic updates for quantity changes
310
+ - [ ] Stock availability warnings (if low stock)
311
+ - [ ] Free shipping threshold progress (if applicable)
312
+ - [ ] Keyboard accessible (Tab, Enter, Arrow keys)
313
+ - [ ] ARIA labels on quantity controls and buttons
314
+ - [ ] Screen reader announcements (aria-live)
315
+ - [ ] High contrast text (4.5:1 minimum)
316
+ - [ ] Error handling for failed updates