create-magic-storefront 0.1.1 → 0.1.3

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 (109) hide show
  1. package/package.json +1 -1
  2. package/template/.claude/skills/storefront-design/SKILL.md +19 -8
  3. package/template/.claude/skills/storefront-verify/SKILL.md +85 -0
  4. package/template/.claude/skills/vercel-react-best-practices/AGENTS.md +3810 -0
  5. package/template/.claude/skills/vercel-react-best-practices/README.md +123 -0
  6. package/template/.claude/skills/vercel-react-best-practices/SKILL.md +149 -0
  7. package/template/.claude/skills/vercel-react-best-practices/SOURCE.md +7 -0
  8. package/template/.claude/skills/vercel-react-best-practices/metadata.json +15 -0
  9. package/template/.claude/skills/vercel-react-best-practices/rules/_sections.md +46 -0
  10. package/template/.claude/skills/vercel-react-best-practices/rules/_template.md +28 -0
  11. package/template/.claude/skills/vercel-react-best-practices/rules/advanced-effect-event-deps.md +56 -0
  12. package/template/.claude/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  13. package/template/.claude/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
  14. package/template/.claude/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
  15. package/template/.claude/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
  16. package/template/.claude/skills/vercel-react-best-practices/rules/async-cheap-condition-before-await.md +37 -0
  17. package/template/.claude/skills/vercel-react-best-practices/rules/async-defer-await.md +82 -0
  18. package/template/.claude/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
  19. package/template/.claude/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
  20. package/template/.claude/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
  21. package/template/.claude/skills/vercel-react-best-practices/rules/bundle-analyzable-paths.md +63 -0
  22. package/template/.claude/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +60 -0
  23. package/template/.claude/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
  24. package/template/.claude/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
  25. package/template/.claude/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  26. package/template/.claude/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
  27. package/template/.claude/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
  28. package/template/.claude/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
  29. package/template/.claude/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
  30. package/template/.claude/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
  31. package/template/.claude/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
  32. package/template/.claude/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
  33. package/template/.claude/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
  34. package/template/.claude/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
  35. package/template/.claude/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
  36. package/template/.claude/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
  37. package/template/.claude/skills/vercel-react-best-practices/rules/js-flatmap-filter.md +60 -0
  38. package/template/.claude/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
  39. package/template/.claude/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
  40. package/template/.claude/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
  41. package/template/.claude/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
  42. package/template/.claude/skills/vercel-react-best-practices/rules/js-request-idle-callback.md +105 -0
  43. package/template/.claude/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
  44. package/template/.claude/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
  45. package/template/.claude/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
  46. package/template/.claude/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  47. package/template/.claude/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
  48. package/template/.claude/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
  49. package/template/.claude/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  50. package/template/.claude/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  51. package/template/.claude/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
  52. package/template/.claude/skills/vercel-react-best-practices/rules/rendering-resource-hints.md +85 -0
  53. package/template/.claude/skills/vercel-react-best-practices/rules/rendering-script-defer-async.md +68 -0
  54. package/template/.claude/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
  55. package/template/.claude/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
  56. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
  57. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
  58. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
  59. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
  60. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
  61. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  62. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
  63. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
  64. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
  65. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-no-inline-components.md +82 -0
  66. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
  67. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-split-combined-hooks.md +64 -0
  68. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
  69. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-use-deferred-value.md +59 -0
  70. package/template/.claude/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
  71. package/template/.claude/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
  72. package/template/.claude/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
  73. package/template/.claude/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
  74. package/template/.claude/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
  75. package/template/.claude/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
  76. package/template/.claude/skills/vercel-react-best-practices/rules/server-hoist-static-io.md +149 -0
  77. package/template/.claude/skills/vercel-react-best-practices/rules/server-no-shared-module-state.md +50 -0
  78. package/template/.claude/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
  79. package/template/.claude/skills/vercel-react-best-practices/rules/server-parallel-nested-fetching.md +34 -0
  80. package/template/.claude/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
  81. package/template/.claude/skills/web-interface-guidelines/LICENSE +21 -0
  82. package/template/.claude/skills/web-interface-guidelines/SKILL.md +40 -0
  83. package/template/.claude/skills/web-interface-guidelines/SOURCE.md +9 -0
  84. package/template/.claude/skills/web-interface-guidelines/guidelines.md +155 -0
  85. package/template/AGENTS.md +19 -12
  86. package/template/PAGES.md +25 -2
  87. package/template/README.md +1 -1
  88. package/template/_gitignore +1 -0
  89. package/template/app/account/page.tsx +31 -11
  90. package/template/app/cart/page.tsx +50 -54
  91. package/template/app/checkout/page.tsx +86 -38
  92. package/template/app/collections/[handle]/page.tsx +3 -2
  93. package/template/app/error.tsx +6 -4
  94. package/template/app/globals.css +29 -0
  95. package/template/app/layout.tsx +4 -2
  96. package/template/app/not-found.tsx +5 -2
  97. package/template/app/pages/[handle]/page.tsx +3 -2
  98. package/template/app/search/page.tsx +11 -6
  99. package/template/components/buy-box.tsx +7 -4
  100. package/template/components/cart-link.tsx +8 -2
  101. package/template/components/pager.tsx +3 -1
  102. package/template/components/product-grid.tsx +9 -5
  103. package/template/components/sections/banner.tsx +7 -1
  104. package/template/components/sections/deal-of-day.tsx +16 -5
  105. package/template/components/sections/product-shelves.tsx +8 -7
  106. package/template/components/sections/store-reviews.tsx +7 -5
  107. package/template/lib/errors.ts +1 -4
  108. package/template/lib/i18n.ts +315 -0
  109. package/template/llms.txt +8 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-magic-storefront",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Scaffold a Next.js storefront on the MagicStore Storefront API v2",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,11 +15,17 @@ merchant's own store, not like a template and not like an AI landing page. The d
15
15
  server owns it: prices, stock, discounts, images, reviews. Design never invents or recomputes any of
16
16
  it.
17
17
 
18
- Two skills work together:
18
+ The design skills work together (all in `.claude/skills/`):
19
19
 
20
20
  - **This skill** decides what a store needs and what is off limits.
21
- - **`design-taste-frontend`** (next to this one) supplies taste: the design read, the three dials,
22
- the anti-slop rules (its Sections 0, 1, 4, 9). Load it too.
21
+ - **`design-taste-frontend`** supplies taste: the design read, the three dials, the anti-slop
22
+ rules (its Sections 0, 1, 4, 9). Load it too.
23
+ - **`web-interface-guidelines`**: keyboard, focus, forms, touch targets. Apply it to every
24
+ interactive part (options, cart, checkout, account).
25
+ - **`vercel-react-best-practices`**: keep the design fast; server components stay server
26
+ components, no client JS for what CSS can do.
27
+ - **`storefront-verify`**: run last. Screenshots of every page type at 390 and 1280px, checked
28
+ against the pre-flight below.
23
29
 
24
30
  When they disagree, **this skill wins**. The overrides are listed in [Overrides](#overrides).
25
31
 
@@ -30,7 +36,7 @@ Design from the merchant's data, not from a guess. Read, through `lib/api.ts`:
30
36
  | What | Why |
31
37
  | ------------------------------------------------- | ----------------------------------------------------------------- |
32
38
  | `api.shop()`: `name`, `description`, `branding` | Identity: logo, favicon, colors, theme |
33
- | `api.home()`: the sections in the merchant's order | What the home page must hold; a design never drops or reorders them |
39
+ | `api.home()`: the sections in the merchant's order | On a merchant-managed home, what it must hold. A custom home may skip it (`PAGES.md`, Home) |
34
40
  | `api.collectionsIndex()`, a few `api.productsIndex()` | Category, price range, how many products, how good the photos are |
35
41
 
36
42
  `shop.branding`:
@@ -106,9 +112,12 @@ animation, no decorative imagery, no experimental layout. Trust beats taste here
106
112
  **Account, search, content pages.** Same tokens, quiet layout. Search results reuse the product
107
113
  card.
108
114
 
109
- **Home** (`app/page.tsx`, `components/sections/`). The one place for a strong visual idea. Each
110
- section type keeps its renderer; restyle it, do not replace the data it renders. The merchant's
111
- banners and stories are the hero imagery.
115
+ **Home** (`app/page.tsx`). The one place for a strong visual idea, and the page a design may
116
+ rebuild from scratch: `GET /home` is optional (`PAGES.md`, Home). On a **merchant-managed** home,
117
+ each section type keeps its renderer in `components/sections/`, restyled, in the merchant's order.
118
+ On a **custom** home, compose the layout the design needs from catalog, collection, review and
119
+ content data; merchant sections (banners, stories) may be pulled in as hero imagery where the
120
+ design wants them. Either way every block shows real API data, and an empty read renders nothing.
112
121
 
113
122
  ## 4. Telegram Mini App
114
123
 
@@ -152,7 +161,8 @@ Before calling a design done, tick every box:
152
161
  (hero banner or first product image) is not lazy-loaded.
153
162
  - [ ] No invented data: prices, badges, ratings, reviews, stock, urgency, customer logos.
154
163
  - [ ] Money only through `<Money>` / `formatMoney`.
155
- - [ ] Every home section type from `api.home()` still renders, in the merchant's order.
164
+ - [ ] Home: merchant-managed — every section type from `api.home()` renders, in the merchant's
165
+ order; custom — every block reads real API data and hides when that read is empty.
156
166
  - [ ] Product page: price and add to cart visible without scrolling at 390×844.
157
167
  - [ ] Cart and checkout: one column on mobile, labelled fields, errors next to fields, no motion.
158
168
  - [ ] Mobile 360px: no horizontal scroll, tap targets ≥ 44px, nothing hover-only.
@@ -161,3 +171,4 @@ Before calling a design done, tick every box:
161
171
  - [ ] Empty, error and not-found states styled, not bare text.
162
172
  - [ ] Taste skill Section 14 run for the home page and content pages.
163
173
  - [ ] `npm run typecheck`, `npm run build` and `npx create-magic-storefront check` pass.
174
+ - [ ] `storefront-verify` done: every page type looked at, at 390 and 1280px.
@@ -0,0 +1,85 @@
1
+ ---
2
+ name: storefront-verify
3
+ description: >-
4
+ Look at the storefront before calling visual work done: build it, run it against the real shop,
5
+ screenshot every page type at phone and desktop width, check the screenshots against the
6
+ `storefront-design` pre-flight and the Web Interface Guidelines, fix, repeat. Use after any change
7
+ to how the storefront looks or behaves (a design, a restyle, a new section or component), and
8
+ whenever asked to "check", "verify", "screenshot" or "show" the storefront.
9
+ ---
10
+
11
+ # Verify the storefront
12
+
13
+ Code that type-checks can still look broken. After visual work, **look at the result** before
14
+ saying it is done. Never describe a page you have not looked at.
15
+
16
+ ## 1. Build and run
17
+
18
+ ```bash
19
+ npm run typecheck
20
+ npm run build
21
+ npx create-magic-storefront check
22
+ npm start -- -p 3100 # in the background; needs .env.local (MAGICSTORE_SHOP_DOMAIN)
23
+ ```
24
+
25
+ A build or `check` failure is fixed first; screenshots of a broken build prove nothing. Stop the
26
+ server when you are done.
27
+
28
+ ## 2. Pick the pages
29
+
30
+ Real data only, from the running shop:
31
+
32
+ | Page | URL |
33
+ | ---------- | ----------------------------------------------------------------- |
34
+ | Home | `/` |
35
+ | Collection | the first `/collections/…` link in the home page's HTML or its menu |
36
+ | Product | the first `/products/…` link, plus one sold out or with options if the shop has one |
37
+ | Search | `/search?q=<a word from a product title>` and one with no results |
38
+ | Cart | `/cart` (empty), then again after adding a product |
39
+ | Checkout | `/checkout` with that cart |
40
+ | Not found | `/products/this-does-not-exist` |
41
+
42
+ Never place an order while verifying: stop at the checkout form.
43
+
44
+ ## 3. Screenshot at two widths
45
+
46
+ Phone **390×844** (also the Telegram Mini App) and desktop **1280×800**, full page.
47
+
48
+ - With a browser tool in your environment (Playwright MCP, Chrome DevTools, Claude in Chrome), use
49
+ it: resize, navigate, screenshot. It can also click through the cart and read the console.
50
+ - Otherwise, with the Playwright CLI (the first run downloads Chromium,
51
+ `npx -y playwright install chromium`):
52
+
53
+ ```bash
54
+ mkdir -p .screenshots
55
+ npx -y playwright screenshot --viewport-size "390,844" --full-page \
56
+ http://localhost:3100/ .screenshots/home-390.png
57
+ npx -y playwright screenshot --viewport-size "1280,800" --full-page \
58
+ http://localhost:3100/ .screenshots/home-1280.png
59
+ ```
60
+
61
+ Then open each image and look at it. `.screenshots/` is ignored by git.
62
+
63
+ In a browser tool, also check each phone-width page for horizontal scroll:
64
+ `document.documentElement.scrollWidth > window.innerWidth` must be `false`. And read the console:
65
+ no errors, no hydration warnings.
66
+
67
+ ## 4. Check what you see
68
+
69
+ For every screenshot, against `storefront-design`'s pre-flight:
70
+
71
+ - Nothing overflows, overlaps or is cut off; no horizontal scroll at 390px.
72
+ - Product page at 390×844: price and add to cart visible in the first screen.
73
+ - Header readable on the merchant's colors; logo not stretched; badges readable.
74
+ - Images keep their aspect ratio; a missing image shows the fallback, not a broken icon.
75
+ - Empty cart, no search results and not found look designed, not like bare text.
76
+ - Text is in the storefront's language, with no placeholder or invented copy.
77
+
78
+ Then run a `web-interface-guidelines` review of the files you changed.
79
+
80
+ ## 5. Fix and repeat
81
+
82
+ Fix what you found, rebuild, re-shoot only the affected pages. At most three rounds; if something
83
+ still fails after that, report it with the screenshot's path instead of looping.
84
+
85
+ Finish with a short report: pages checked, at which widths, what was fixed, what is left.