create-abcart-theme 0.10.0 → 1.0.0
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/CHANGELOG.md +133 -127
- package/LICENSE +202 -202
- package/NOTICE +2 -2
- package/README.md +65 -65
- package/bin/create-abcart-theme.mjs +4 -4
- package/package.json +49 -49
- package/src/args.mjs +113 -113
- package/src/banner.mjs +21 -21
- package/src/cli.mjs +119 -119
- package/src/create.mjs +85 -82
- package/src/package-manager.mjs +32 -32
- package/src/style.mjs +17 -17
- package/templates/default/.agents/skills/{wocart-docs → abcart-docs}/SKILL.md +146 -146
- package/templates/default/.agents/skills/{wocart-theme-from-design → abcart-theme-from-design}/SKILL.md +58 -58
- package/templates/default/.agents/skills/{wocart-theme-from-design → abcart-theme-from-design}/references/inputs-and-rights.md +47 -47
- package/templates/default/.agents/skills/{wocart-theme-from-design → abcart-theme-from-design}/references/layout-rtl-and-phone.md +36 -36
- package/templates/default/.agents/skills/{wocart-theme-from-design → abcart-theme-from-design}/references/measure-the-design.md +60 -60
- package/templates/default/.agents/skills/{wocart-theme-from-design → abcart-theme-from-design}/references/tokens-sections-content.md +103 -103
- package/templates/default/.agents/skills/{wocart-theme-from-design → abcart-theme-from-design}/references/verify-and-report.md +102 -102
- package/templates/default/.agents/skills/{wocart-theme-from-design → abcart-theme-from-design}/scripts/compare-design.cjs +230 -230
- package/templates/default/.agents/skills/{wocart-theme-from-design → abcart-theme-from-design}/scripts/qa-pages.cjs +219 -219
- package/templates/default/.agents/skills/shopify-theme-asset-collector/SKILL.md +125 -125
- package/templates/default/.agents/skills/shopify-theme-asset-collector/scripts/collect_public_assets.py +370 -370
- package/templates/default/.dev.vars.example +12 -12
- package/templates/default/AGENTS.md +240 -240
- package/templates/default/README.md +184 -184
- package/templates/default/_gitignore +11 -11
- package/templates/default/astro.config.mjs +85 -85
- package/templates/default/package.json +36 -36
- package/templates/default/public/fonts/OFL.txt +96 -96
- package/templates/default/src/actions/index.ts +22 -22
- package/templates/default/src/components/cart/AddToCartButton.astro +45 -45
- package/templates/default/src/components/cart/CartDrawer.astro +47 -47
- package/templates/default/src/components/cart/CartSummary.astro +11 -11
- package/templates/default/src/components/cart/FreeShipping.astro +7 -7
- package/templates/default/src/components/checkout/CheckoutMain.astro +29 -29
- package/templates/default/src/components/checkout/OrderForm.astro +280 -280
- package/templates/default/src/components/checkout/ThankYouMain.astro +68 -68
- package/templates/default/src/components/landing/LandingImages.astro +51 -51
- package/templates/default/src/components/landing/LandingOrder.astro +46 -46
- package/templates/default/src/components/landing/LandingProduct.astro +41 -41
- package/templates/default/src/components/listing/ListingMain.astro +93 -93
- package/templates/default/src/components/listing/PageMain.astro +52 -52
- package/templates/default/src/components/listing/Pagination.astro +31 -31
- package/templates/default/src/components/listing/SortControl.astro +35 -35
- package/templates/default/src/components/product/BuyBox.astro +96 -96
- package/templates/default/src/components/product/Description.astro +24 -24
- package/templates/default/src/components/product/Gallery.astro +66 -66
- package/templates/default/src/components/product/MobileBuyBar.astro +29 -29
- package/templates/default/src/components/product/OfferChoice.astro +66 -66
- package/templates/default/src/components/product/ProductMain.astro +40 -40
- package/templates/default/src/components/product/ProductReviews.astro +72 -72
- package/templates/default/src/components/product/RelatedProducts.astro +30 -30
- package/templates/default/src/components/product/blocks/BenefitsBlock.astro +13 -13
- package/templates/default/src/components/product/blocks/CollapsibleBlock.astro +20 -20
- package/templates/default/src/components/product/blocks/DescriptionBlock.astro +19 -19
- package/templates/default/src/components/product/blocks/DetailsBlock.astro +33 -33
- package/templates/default/src/components/product/blocks/GalleryBlock.astro +12 -12
- package/templates/default/src/components/product/blocks/OrderBlock.astro +30 -30
- package/templates/default/src/components/product/blocks/PriceBlock.astro +23 -23
- package/templates/default/src/components/product/blocks/RatingBlock.astro +16 -16
- package/templates/default/src/components/product/blocks/StockBlock.astro +22 -22
- package/templates/default/src/components/product/blocks/TextBlock.astro +11 -11
- package/templates/default/src/components/product/blocks/TitleBlock.astro +20 -20
- package/templates/default/src/components/reviews/ReviewCard.astro +46 -46
- package/templates/default/src/components/reviews/ReviewForm.astro +113 -113
- package/templates/default/src/components/reviews/VoiceNote.astro +60 -60
- package/templates/default/src/components/sections/CollectionCards.astro +65 -65
- package/templates/default/src/components/sections/Countdown.astro +57 -57
- package/templates/default/src/components/sections/Faq.astro +44 -44
- package/templates/default/src/components/sections/FeaturedProduct.astro +71 -71
- package/templates/default/src/components/sections/Hero.astro +99 -99
- package/templates/default/src/components/sections/ImageBanner.astro +46 -46
- package/templates/default/src/components/sections/ProductGrid.astro +47 -47
- package/templates/default/src/components/sections/RichText.astro +35 -35
- package/templates/default/src/components/sections/Steps.astro +46 -46
- package/templates/default/src/components/sections/Testimonials.astro +57 -57
- package/templates/default/src/components/shell/Footer.astro +80 -80
- package/templates/default/src/components/shell/Header.astro +89 -89
- package/templates/default/src/components/shell/LanguageMenu.astro +33 -33
- package/templates/default/src/components/shell/MobileMenu.astro +65 -65
- package/templates/default/src/components/shell/SearchDialog.astro +19 -19
- package/templates/default/src/components/shell/TopBar.astro +54 -54
- package/templates/default/src/components/shell/WhatsAppWidget.astro +111 -111
- package/templates/default/src/components/store/ContactMain.astro +79 -79
- package/templates/default/src/components/store/SearchMain.astro +56 -56
- package/templates/default/src/components/store/TrackOrderMain.astro +161 -161
- package/templates/default/src/components/surface/Area.astro +20 -20
- package/templates/default/src/components/surface/PreviewBridge.astro +24 -24
- package/templates/default/src/components/surface/Sections.astro +35 -35
- package/templates/default/src/components/ui/Breadcrumbs.astro +36 -36
- package/templates/default/src/components/ui/Button.astro +45 -45
- package/templates/default/src/components/ui/EditorPlaceholder.astro +24 -24
- package/templates/default/src/components/ui/Icon.astro +93 -93
- package/templates/default/src/components/ui/Logo.astro +36 -36
- package/templates/default/src/components/ui/Photo.astro +46 -46
- package/templates/default/src/components/ui/Price.astro +24 -24
- package/templates/default/src/components/ui/ProductCard.astro +41 -41
- package/templates/default/src/components/ui/Rating.astro +22 -22
- package/templates/default/src/components/ui/Section.astro +34 -34
- package/templates/default/src/components/ui/SectionHeading.astro +19 -19
- package/templates/default/src/env.d.ts +23 -23
- package/templates/default/src/layouts/StoreLayout.astro +145 -145
- package/templates/default/src/lib/browser-copy.ts +37 -37
- package/templates/default/src/lib/context.ts +89 -89
- package/templates/default/src/lib/coupon-notice.ts +47 -47
- package/templates/default/src/lib/i18n.ts +32 -32
- package/templates/default/src/lib/images.ts +38 -38
- package/templates/default/src/lib/listing-query.ts +41 -41
- package/templates/default/src/lib/money.ts +16 -16
- package/templates/default/src/lib/motion.ts +16 -16
- package/templates/default/src/lib/nav.ts +26 -26
- package/templates/default/src/lib/offer-tiles.ts +105 -105
- package/templates/default/src/lib/order-outcome.ts +66 -66
- package/templates/default/src/lib/otp-message.ts +21 -21
- package/templates/default/src/lib/products.ts +38 -38
- package/templates/default/src/lib/review-refusals.ts +31 -31
- package/templates/default/src/lib/store.ts +31 -31
- package/templates/default/src/lib/whatsapp.ts +29 -29
- package/templates/default/src/middleware.ts +23 -23
- package/templates/default/src/pages/404.astro +22 -22
- package/templates/default/src/pages/{wocart-preview.astro → abcart-preview.astro} +43 -43
- package/templates/default/src/pages/{wocart-revalidate.ts → abcart-revalidate.ts} +10 -10
- package/templates/default/src/pages/{wocart-styles.css.ts → abcart-styles.css.ts} +5 -5
- package/templates/default/src/pages/{wocart-theme.json.ts → abcart-theme.json.ts} +5 -5
- package/templates/default/src/pages/api/abandoned/convert.ts +4 -4
- package/templates/default/src/pages/api/abandoned/upsert.ts +4 -4
- package/templates/default/src/pages/api/cart/validate.ts +4 -4
- package/templates/default/src/pages/api/communes/[wilayaId].ts +4 -4
- package/templates/default/src/pages/api/otp/send.ts +4 -4
- package/templates/default/src/pages/api/otp/verify.ts +4 -4
- package/templates/default/src/pages/api/reviews/[productId].ts +3 -3
- package/templates/default/src/pages/api/reviews/eligibility.ts +3 -3
- package/templates/default/src/pages/api/reviews/submit.ts +3 -3
- package/templates/default/src/pages/api/reviews/upload.ts +3 -3
- package/templates/default/src/pages/category/[slug].astro +20 -20
- package/templates/default/src/pages/checkout.astro +25 -25
- package/templates/default/src/pages/collections/[handle].astro +20 -20
- package/templates/default/src/pages/contact.astro +17 -17
- package/templates/default/src/pages/index.astro +9 -9
- package/templates/default/src/pages/lp/[slug].astro +47 -47
- package/templates/default/src/pages/pages/[slug].astro +16 -16
- package/templates/default/src/pages/products/[handle].astro +37 -37
- package/templates/default/src/pages/products/index.astro +15 -15
- package/templates/default/src/pages/robots.txt.ts +9 -9
- package/templates/default/src/pages/search.astro +19 -19
- package/templates/default/src/pages/sitemap.xml.ts +12 -12
- package/templates/default/src/pages/thank-you.astro +33 -33
- package/templates/default/src/pages/track-order.astro +17 -17
- package/templates/default/src/scripts/cart.ts +371 -371
- package/templates/default/src/scripts/checkout/coupon.ts +96 -96
- package/templates/default/src/scripts/checkout/delivery.ts +86 -86
- package/templates/default/src/scripts/checkout/form.ts +54 -54
- package/templates/default/src/scripts/checkout/otp.ts +106 -106
- package/templates/default/src/scripts/checkout/picker.ts +169 -169
- package/templates/default/src/scripts/checkout/quote.ts +169 -169
- package/templates/default/src/scripts/checkout/submit.ts +113 -113
- package/templates/default/src/scripts/checkout/tracking.ts +74 -74
- package/templates/default/src/scripts/countdown.ts +29 -29
- package/templates/default/src/scripts/events.ts +4 -4
- package/templates/default/src/scripts/hero.ts +49 -49
- package/templates/default/src/scripts/listing.ts +13 -13
- package/templates/default/src/scripts/order-form.ts +100 -100
- package/templates/default/src/scripts/product.ts +306 -306
- package/templates/default/src/scripts/public-config.ts +79 -79
- package/templates/default/src/scripts/reviews.ts +358 -358
- package/templates/default/src/scripts/site.ts +131 -131
- package/templates/default/src/scripts/thank-you.ts +11 -11
- package/templates/default/src/scripts/voice-note.ts +94 -94
- package/templates/default/src/styles/base.css +1030 -1030
- package/templates/default/src/styles/checkout.css +1111 -1111
- package/templates/default/src/styles/global.css +12 -12
- package/templates/default/src/styles/product.css +871 -871
- package/templates/default/src/styles/reviews.css +533 -533
- package/templates/default/src/styles/sections.css +931 -931
- package/templates/default/src/styles/shell.css +970 -970
- package/templates/default/src/styles/tokens.css +583 -583
- package/templates/default/src/theme/api-routes.ts +10 -10
- package/templates/default/src/theme/content/catalog.ts +117 -117
- package/templates/default/src/theme/content/checkout.ts +168 -168
- package/templates/default/src/theme/content/editor.ts +21 -21
- package/templates/default/src/theme/content/index.ts +45 -45
- package/templates/default/src/theme/content/reviews.ts +76 -76
- package/templates/default/src/theme/content/shell.ts +59 -59
- package/templates/default/src/theme/content/types.ts +12 -12
- package/templates/default/src/theme/documents/catalog.json +11 -11
- package/templates/default/src/theme/documents/category.json +11 -11
- package/templates/default/src/theme/documents/checkout.json +11 -11
- package/templates/default/src/theme/documents/collection.json +11 -11
- package/templates/default/src/theme/documents/contact.json +11 -11
- package/templates/default/src/theme/documents/footer.area.json +11 -11
- package/templates/default/src/theme/documents/header.area.json +16 -16
- package/templates/default/src/theme/documents/home.json +313 -313
- package/templates/default/src/theme/documents/landing.json +8 -8
- package/templates/default/src/theme/documents/page.json +11 -11
- package/templates/default/src/theme/documents/product.json +125 -125
- package/templates/default/src/theme/documents/search.json +11 -11
- package/templates/default/src/theme/documents/thank-you.json +11 -11
- package/templates/default/src/theme/documents/track-order.json +11 -11
- package/templates/default/src/theme/fields.ts +61 -61
- package/templates/default/src/theme/key.ts +11 -11
- package/templates/default/src/theme/labels.ts +231 -231
- package/templates/default/src/theme/locales.ts +11 -11
- package/templates/default/src/theme/palette.ts +14 -14
- package/templates/default/src/theme/sections/collection-cards.ts +65 -65
- package/templates/default/src/theme/sections/faq.ts +74 -74
- package/templates/default/src/theme/sections/featured-product.ts +42 -42
- package/templates/default/src/theme/sections/hero.ts +47 -47
- package/templates/default/src/theme/sections/image-banner.ts +25 -25
- package/templates/default/src/theme/sections/index.ts +40 -40
- package/templates/default/src/theme/sections/landing.ts +150 -150
- package/templates/default/src/theme/sections/listing.ts +84 -84
- package/templates/default/src/theme/sections/product-grid.ts +42 -42
- package/templates/default/src/theme/sections/product.ts +297 -297
- package/templates/default/src/theme/sections/rich-text.ts +39 -39
- package/templates/default/src/theme/sections/shared.ts +54 -54
- package/templates/default/src/theme/sections/shell.ts +85 -85
- package/templates/default/src/theme/sections/store-pages.ts +101 -101
- package/templates/default/src/theme/sections/testimonials.ts +61 -61
- package/templates/default/src/theme/sections/thank-you.ts +35 -35
- package/templates/default/src/theme/settings.ts +124 -124
- package/templates/default/src/theme/theme.ts +65 -65
- package/templates/default/tests/fixtures/canvas-tote.json +62 -62
- package/templates/default/tests/fixtures/linen-shirt.json +128 -128
- package/templates/default/tests/unit/checkout.test.ts +241 -241
- package/templates/default/tests/unit/contract.test.ts +170 -169
- package/templates/default/tests/unit/contrast.test.ts +68 -68
- package/templates/default/tests/unit/copy.test.ts +101 -101
- package/templates/default/tests/unit/design-values.test.ts +95 -95
- package/templates/default/tests/unit/editability.test.ts +180 -180
- package/templates/default/tests/unit/fixtures.ts +91 -91
- package/templates/default/tests/unit/footer.test.ts +54 -54
- package/templates/default/tests/unit/guards.test.ts +340 -340
- package/templates/default/tests/unit/images.test.ts +26 -26
- package/templates/default/tests/unit/landing.test.ts +151 -151
- package/templates/default/tests/unit/languages.test.ts +42 -42
- package/templates/default/tests/unit/middleware.test.ts +53 -53
- package/templates/default/tests/unit/offer-tiles.test.ts +75 -75
- package/templates/default/tests/unit/render.ts +38 -38
- package/templates/default/tests/unit/reviews.test.ts +25 -25
- package/templates/default/tests/unit/rules.test.ts +59 -59
- package/templates/default/tests/unit/source.ts +75 -75
- package/templates/default/tests/unit/store-pages.test.ts +147 -147
- package/templates/default/tests/unit/studio.test.ts +202 -202
- package/templates/default/tests/unit/testimonials.test.ts +52 -52
- package/templates/default/tests/unit/thank-you.test.ts +52 -52
- package/templates/default/tests/unit/tracking.test.ts +29 -29
- package/templates/default/tests/unit/voice-note.test.ts +42 -42
- package/templates/default/tsconfig.json +13 -13
- package/templates/default/vitest.config.ts +15 -15
- package/templates/default/wrangler.jsonc +16 -16
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# Local secrets for `npm run dev` and `npm run preview`.
|
|
2
|
-
# Copy this file to .dev.vars and fill it in. .dev.vars is never committed.
|
|
3
|
-
|
|
4
|
-
# Your store's API: http://localhost:8787 for a store running on this machine.
|
|
5
|
-
COD_SERVER_URL=http://localhost:8787
|
|
6
|
-
|
|
7
|
-
# Your store's API key, from the store's dashboard (or your local store's seed).
|
|
8
|
-
STORE_API_KEY=your-store-api-key
|
|
9
|
-
|
|
10
|
-
# Optional: the editor's preview public key, an Ed25519 JWK on one line.
|
|
11
|
-
# Unset: /
|
|
12
|
-
#
|
|
1
|
+
# Local secrets for `npm run dev` and `npm run preview`.
|
|
2
|
+
# Copy this file to .dev.vars and fill it in. .dev.vars is never committed.
|
|
3
|
+
|
|
4
|
+
# Your store's API: http://localhost:8787 for a store running on this machine.
|
|
5
|
+
COD_SERVER_URL=http://localhost:8787
|
|
6
|
+
|
|
7
|
+
# Your store's API key, from the store's dashboard (or your local store's seed).
|
|
8
|
+
STORE_API_KEY=your-store-api-key
|
|
9
|
+
|
|
10
|
+
# Optional: the editor's preview public key, an Ed25519 JWK on one line.
|
|
11
|
+
# Unset: /abcart-preview and /abcart-revalidate answer 404.
|
|
12
|
+
# ABCART_PREVIEW_KEY=
|
|
@@ -1,240 +1,240 @@
|
|
|
1
|
-
# Instructions for coding agents
|
|
2
|
-
|
|
3
|
-
This is
|
|
4
|
-
(the store's data and commerce rules) and `@abcart/theme` (the contract
|
|
5
|
-
Studio edits). It sells cash on delivery in Algeria, in Arabic (right to left,
|
|
6
|
-
the default), French and English. Read this file before changing anything.
|
|
7
|
-
|
|
8
|
-
## Skills
|
|
9
|
-
|
|
10
|
-
Three skills ship with the theme, in `.agents/skills/`. Start from the row
|
|
11
|
-
that matches the request:
|
|
12
|
-
|
|
13
|
-
| The request | Start with |
|
|
14
|
-
| --- | --- |
|
|
15
|
-
| Build or restyle a theme that must match a design: a screenshot or image, a live website URL, or a Shopify theme measured with the collector | **`
|
|
16
|
-
| Collect a Shopify theme's public frontend to measure it | **`shopify-theme-asset-collector`**: finds the demo storefront and saves its pages, styles, scripts, images and fonts, with a manifest of the sections. Its output is for measuring, never for shipping |
|
|
17
|
-
| Any SDK name, field, platform behaviour, or a failing check | **`
|
|
18
|
-
|
|
19
|
-
A whole theme can be built unattended: give the agent the brief that `
|
|
20
|
-
|
|
21
|
-
## What it is made of
|
|
22
|
-
|
|
23
|
-
| Where | What |
|
|
24
|
-
| --- | --- |
|
|
25
|
-
| `src/theme/theme.ts` | The theme: 12 pages (surfaces), the header and footer (areas), settings, every section. What Studio reads (`/
|
|
26
|
-
| `src/theme/sections/*.ts` | One definition per section or family: its fields, its data (`load`), its presets |
|
|
27
|
-
| `src/theme/documents/*.json` | The layout each page starts with, before a merchant edits it |
|
|
28
|
-
| `src/theme/content/*.ts` | Every word the shopper reads, ar/fr/en side by side, by area |
|
|
29
|
-
| `src/theme/labels.ts` | What Studio calls each page, section, field and option |
|
|
30
|
-
| `src/theme/palette.ts` | The starter's colors, written once: the only literal colors in the theme's code (with `tokens.css`) |
|
|
31
|
-
| `src/theme/settings.ts` | Store-wide settings: color schemes, corners, product cards, promises, social links |
|
|
32
|
-
| `src/theme/key.ts`, `locales.ts` | The theme's permanent key and version; its languages |
|
|
33
|
-
| `src/components/` | Presentation. A section renders through `src/components/ui/Section.astro`; product blocks live in `src/components/product/blocks/` |
|
|
34
|
-
| `src/pages/` | Thin routes: read the resource, `return notFound(Astro)` when missing, render the surface with `src/components/surface/Sections.astro` |
|
|
35
|
-
| `src/lib/` | Server-side glue, no business rules. `store.ts` is the only file that creates an SDK client |
|
|
36
|
-
| `src/scripts/` | Everything the browser runs. `order-form.ts` binds each order form and wires its parts in `src/scripts/checkout/`: `delivery`, `quote`, `coupon`, `otp`, `submit`, `tracking` |
|
|
37
|
-
| `src/styles/` | `tokens.css` is the design system; the other files style areas from its tokens |
|
|
38
|
-
| `src/middleware.ts`, `src/actions/` | Wiring only: `createStorefrontMiddleware` decides the store, the language, redirects, the preview and the order |
|
|
39
|
-
| `tests/` | Contract, guard, Studio, checkout and copy tests |
|
|
40
|
-
| `.agents/skills/` | The three skills above, each with its own references and scripts |
|
|
41
|
-
|
|
42
|
-
## Commands
|
|
43
|
-
|
|
44
|
-
```sh
|
|
45
|
-
npm install
|
|
46
|
-
npm run dev # http://localhost:4321, needs .dev.vars (see .dev.vars.example)
|
|
47
|
-
npm run check # astro check: 0 errors, 0 warnings
|
|
48
|
-
npm test # contract, guard, Studio, checkout and copy tests
|
|
49
|
-
npm run build # Cloudflare Workers build
|
|
50
|
-
npm run build:vercel # Vercel build
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
**Definition of done:** `npm run check`, `npm test`, `npm run build` and
|
|
54
|
-
`npm run build:vercel` pass, and every page you touched was looked at on a
|
|
55
|
-
phone (390 px) and a desktop, in Arabic and in one left-to-right language.
|
|
56
|
-
|
|
57
|
-
## Restyling this theme
|
|
58
|
-
|
|
59
|
-
The look is made of tokens, fonts and colour schemes, so one file restyles the
|
|
60
|
-
store and the theme can take any brand.
|
|
61
|
-
|
|
62
|
-
**Change freely:**
|
|
63
|
-
- `src/styles/tokens.css`: every design value (type, motion, shapes, borders,
|
|
64
|
-
surfaces, corners, shadows) and the right-to-left values for Arabic.
|
|
65
|
-
- The fonts in `public/fonts/`: one Arabic and one Latin family, each limited to
|
|
66
|
-
its script. A new file needs its `@font-face` rule in `tokens.css`, its
|
|
67
|
-
preload in `src/layouts/StoreLayout.astro` and its licence line in
|
|
68
|
-
`public/fonts/OFL.txt`; a test checks all three.
|
|
69
|
-
- The starter's colours in `src/theme/palette.ts`, and the default colour schemes
|
|
70
|
-
in `src/theme/settings.ts` that use them.
|
|
71
|
-
- The layout rules in the stylesheets, and the markup of presentational
|
|
72
|
-
components.
|
|
73
|
-
|
|
74
|
-
**Keep working:**
|
|
75
|
-
- **No design value is a literal.** Every size, line height, letter-spacing,
|
|
76
|
-
weight, colour, radius, shadow, border, surface, filter, aspect ratio, motion
|
|
77
|
-
and opacity is a token (`var(--…)`). A colour inside a rule, in `tokens.css`
|
|
78
|
-
or in `palette.ts` only. Layout geometry (gaps, padding, margins, widths,
|
|
79
|
-
insets, grids, z-index) stays in the stylesheets. `design-values.test.ts`
|
|
80
|
-
names each literal that breaks this.
|
|
81
|
-
- **Token names say where they are used:** `--<category>-<role>` with an
|
|
82
|
-
optional `-narrow`, `-wide`, `-touch` or `-reduced`. A phone rule is always
|
|
83
|
-
`-narrow`, never `-phone`, and a name never ends in a number: a second value for
|
|
84
|
-
a role gets a role name. Search before you add one. A name is never reused for
|
|
85
|
-
another value.
|
|
86
|
-
- **Text is readable on its band:** every colour scheme keeps its text, headings
|
|
87
|
-
and accents at WCAG AA (4.5:1) on its background, and its button words on its
|
|
88
|
-
button. A light band takes dark ink: white words on sand are 2.3:1. `contrast.test.ts`
|
|
89
|
-
names each failing pair, and the offer ribbon's words are checked on its fill.
|
|
90
|
-
- **Names keep their own direction:** a reviewer's or customer's name carries
|
|
91
|
-
`dir="auto"`, so a Latin name's full stop stays after it. `rules.test.ts` checks it.
|
|
92
|
-
- **Card rows fill their row:** a grid of cards uses
|
|
93
|
-
`repeat(auto-fit, minmax(min(100%, 340px), 1fr))`, not a fixed column count. Two
|
|
94
|
-
cards in a three-column grid then fill the row, and six make two even rows.
|
|
95
|
-
- **A confirmation never covers a drawer:** the add-to-cart confirmation shows only
|
|
96
|
-
when no cart drawer opens with it. `rules.test.ts` checks it.
|
|
97
|
-
- **Colour-dependent tokens** (one that reads a colour of the scheme) live in the
|
|
98
|
-
`:root, .
|
|
99
|
-
- **Timings:** a script reads each timing from a motion token through
|
|
100
|
-
`motionMs()` in `src/lib/motion.ts`. A behaviour timer (a debounce, a clock
|
|
101
|
-
tick) stays literal, and the guard names it.
|
|
102
|
-
- **Inline styles carry data only**: an index, a merchant's value, never a
|
|
103
|
-
design number.
|
|
104
|
-
- **Colours a merchant picks:** `.
|
|
105
|
-
`--
|
|
106
|
-
- **Every part is editable through the SDK:** each field reaches the component
|
|
107
|
-
that renders it (or its `load`); every select says what its options mean; every
|
|
108
|
-
number is bounded; every list has a bound and a title per item; every label and
|
|
109
|
-
help text is in each language. Every insertable section starts from a preset, or
|
|
110
|
-
`NO_PRESET` in `editability.test.ts` says why it does not. A preset is rendered
|
|
111
|
-
for a shopper and in the editor's preview in every language. Use the SDK's
|
|
112
|
-
validators (`validateThemeDefinition`, `validateThemeManifest`, `validatePageData`)
|
|
113
|
-
as they are. Never invent a field kind or a rule the SDK does not have.
|
|
114
|
-
- **Help where a choice is not obvious:** `HELP` in `labels.ts`, shown as a field's
|
|
115
|
-
`description`. A field that depends on another is hidden with `visibleIf`.
|
|
116
|
-
- **Right to left:** logical properties (`margin-inline-start`,
|
|
117
|
-
`inset-inline-end`), never `left` or `right` for layout, except in a rule that
|
|
118
|
-
names one direction or the WhatsApp widget's side (a test checks it).
|
|
119
|
-
Directional icons carry `icon-directional`. Phone and order numbers stay left
|
|
120
|
-
to right.
|
|
121
|
-
- **Layouts that mirror:** a split section is a two-column grid with the photo
|
|
122
|
-
first; text on a photo sits in its own panel; a grid that replaces a flex row
|
|
123
|
-
sets its own `justify-content`.
|
|
124
|
-
- **What scripts and forms rely on:** every `name="…"` in the order form, every
|
|
125
|
-
`data-*` attribute a script reads, the `#order` anchor, and the form's `action`.
|
|
126
|
-
- **Text:** never write visible words in markup; use the copy files.
|
|
127
|
-
- **Studio:** never remove `Sections.astro`, `Area.astro` or `PreviewBridge.astro`.
|
|
128
|
-
Keep `class` and `style` from a section's props on its outer element, through
|
|
129
|
-
`Section.astro`.
|
|
130
|
-
|
|
131
|
-
## Rules
|
|
132
|
-
|
|
133
|
-
**Both hosts, every feature.** The theme builds for Cloudflare Workers and
|
|
134
|
-
for Vercel (`DEPLOY_TARGET` in `astro.config.mjs`), so
|
|
135
|
-
it wherever a merchant chooses, and it supports every feature the platform
|
|
136
|
-
has (reviews, the basket, the phone check, codes…), each shown only when the
|
|
137
|
-
store turns it on. Never remove a host or a feature; a test checks the hosts.
|
|
138
|
-
|
|
139
|
-
**The platform is the SDK's.** Import `@
|
|
140
|
-
points only. Prices, offers, delivery fees, coupons, stock and order validity
|
|
141
|
-
are the server's: show what the SDK and the server's quote say, never compute
|
|
142
|
-
them. A missing capability is an SDK change, never a second implementation
|
|
143
|
-
here.
|
|
144
|
-
|
|
145
|
-
**One client per request.** Only `src/lib/store.ts` creates an SDK client;
|
|
146
|
-
everything else reads `Astro.locals.store.client`. The API key never reaches
|
|
147
|
-
browser code.
|
|
148
|
-
|
|
149
|
-
**No validator in the browser.** Browser code never imports Zod or a schema.
|
|
150
|
-
From `@abcart/theme` it takes only `./lifecycle` and `./messages`.
|
|
151
|
-
|
|
152
|
-
**Sections read data in `load`, never in the component.** A definition's
|
|
153
|
-
`load` reads through `reads.get(key, …)` so sections share one read per page.
|
|
154
|
-
A section reads its page's product or landing page through `routeProduct` /
|
|
155
|
-
`routeLanding` (`src/theme/sections/shared.ts`).
|
|
156
|
-
|
|
157
|
-
**Every section is editable the same way.** A `scheme` field
|
|
158
|
-
(`schemeField()`), a `style` field
|
|
159
|
-
(`styleField()`), rendered through `Section.astro`; a test checks that every
|
|
160
|
-
section has both. A photo a merchant picks
|
|
161
|
-
is an `image` field, never a `url`; prose is `richtext`. A section with
|
|
162
|
-
nothing to show renders nothing for a shopper and an `EditorPlaceholder` in
|
|
163
|
-
Studio (`isPreview(blocks)`).
|
|
164
|
-
|
|
165
|
-
**The style classes win.** Never set padding or width on what a `style` field
|
|
166
|
-
controls.
|
|
167
|
-
|
|
168
|
-
**Every behaviour survives the preview.** Browser scripts bind with
|
|
169
|
-
`bindEach()` / `onEachPage()` from `@abcart/theme/lifecycle`, so Studio can
|
|
170
|
-
swap a section and the script binds the new markup once.
|
|
171
|
-
|
|
172
|
-
**The browser asks through the SDK.** The order form quotes with
|
|
173
|
-
`createQuoter`, tracks an unfinished checkout with
|
|
174
|
-
`createBrowserAbandonedCheckoutTracker`, and the review form runs a
|
|
175
|
-
`createReviewSession`. Their paths are the SDK's `STOREFRONT_API_PATHS`
|
|
176
|
-
(`storefrontApiPath` fills a parameter), each mounted by a one-line file
|
|
177
|
-
under `src/pages/api/`; a test checks both ways and that no other file
|
|
178
|
-
writes an `/api/` path.
|
|
179
|
-
|
|
180
|
-
**Words come from the copy.** Every key exists in ar, fr and en; a count is a
|
|
181
|
-
plural message with each language's CLDR forms (Arabic has six); no key that
|
|
182
|
-
nothing reads. The browser gets only the keys listed in
|
|
183
|
-
`src/lib/browser-copy.ts`.
|
|
184
|
-
|
|
185
|
-
**The theme states no fact about a store.** Delivery reach, delivery or
|
|
186
|
-
exchange periods, guarantees, percentages, opening hours, phone calls,
|
|
187
|
-
prices, phone numbers and addresses are the store's: they come from its data
|
|
188
|
-
(the catalog, its contact details, the order form's quote) or from a field
|
|
189
|
-
the merchant fills in. Copy, section defaults, presets, settings and page
|
|
190
|
-
documents say only what is true of every store; a test checks them.
|
|
191
|
-
|
|
192
|
-
**A store that cannot be read still renders.** The middleware falls back to
|
|
193
|
-
the SDK's `unavailableStoreConfig`, in this one place.
|
|
194
|
-
|
|
195
|
-
**Links go through the SDK.** Platform pages are `storefrontPath()` +
|
|
196
|
-
`localizeHref()`; a shopper on `/fr/…` stays in French. A landing page
|
|
197
|
-
(`/lp/…`) is the exception: one campaign in the store's primary language,
|
|
198
|
-
so it has no language prefix, menu or alternate links: the SDK redirects
|
|
199
|
-
`/fr/lp/…` and its `isSingleLanguagePage` empties the language menu
|
|
200
|
-
(`pageLanguages` in `src/lib/context.ts`).
|
|
201
|
-
|
|
202
|
-
**A not-found is never cached.** Return `notFound(Astro)`.
|
|
203
|
-
|
|
204
|
-
**Every cached page carries the `pages` tag** in `astro.config.mjs`
|
|
205
|
-
`routeRules`, as `PAGES_CACHE_TAG` (never the literal), so a Studio publish
|
|
206
|
-
shows at once; `src/pages/
|
|
207
|
-
`revalidateEndpoint`.
|
|
208
|
-
|
|
209
|
-
**The WhatsApp widget is the merchant's.** Every WhatsApp link comes from
|
|
210
|
-
`storeWhatsApp` (`src/lib/whatsapp.ts`); no file writes a `wa.me` link.
|
|
211
|
-
|
|
212
|
-
**The theme key is permanent.** `THEME_KEY` names every merchant's saved
|
|
213
|
-
edits; never change it once a store uses the theme. `THEME_VERSION` equals
|
|
214
|
-
`package.json` `version`; a change that removes a section, a field or a copy
|
|
215
|
-
key merchants may have edited needs a new major version.
|
|
216
|
-
|
|
217
|
-
## Testing
|
|
218
|
-
|
|
219
|
-
- `tests/unit/contract.test.ts` renders every page and area through the SDK's
|
|
220
|
-
renderer, for a shopper and in Studio's preview, from store answers in
|
|
221
|
-
`tests/fixtures/`.
|
|
222
|
-
- `tests/unit/guards.test.ts` enforces the rules above on the source
|
|
223
|
-
(`tests/unit/source.ts` is the one walker every guard reads).
|
|
224
|
-
- `tests/unit/design-values.test.ts` enforces the token rules: no literal design
|
|
225
|
-
value in a stylesheet, no literal timing in a script, data-only inline styles,
|
|
226
|
-
and colour-dependent tokens on the scheme.
|
|
227
|
-
- `tests/unit/studio.test.ts` checks the manifest, the preview and the publish
|
|
228
|
-
revalidation with real Ed25519 keys, and that every composed route is cached.
|
|
229
|
-
- `tests/unit/checkout.test.ts` maps order outcomes and checks the order form's
|
|
230
|
-
delivery fields against the store's checkout settings.
|
|
231
|
-
- `tests/unit/copy.test.ts` checks every key in every language, the plural forms,
|
|
232
|
-
no unused key, no store fact, and the browser's key list.
|
|
233
|
-
- `tests/unit/footer.test.ts` checks that the logo, social links and contact
|
|
234
|
-
details come from the store's settings.
|
|
235
|
-
- `tests/unit/middleware.test.ts` checks the SDK's middleware, wired to this
|
|
236
|
-
store: a 404 keeps the shopper's language.
|
|
237
|
-
- `tests/unit/languages.test.ts` checks that landing pages are single-language.
|
|
238
|
-
|
|
239
|
-
A new rule gets a guard, and a guard is proven by breaking the code once and
|
|
240
|
-
watching it fail.
|
|
1
|
+
# Instructions for coding agents
|
|
2
|
+
|
|
3
|
+
This is an AbCart storefront theme: an Astro project on `@abcart/storefront`
|
|
4
|
+
(the store's data and commerce rules) and `@abcart/theme` (the contract AbCart
|
|
5
|
+
Studio edits). It sells cash on delivery in Algeria, in Arabic (right to left,
|
|
6
|
+
the default), French and English. Read this file before changing anything.
|
|
7
|
+
|
|
8
|
+
## Skills
|
|
9
|
+
|
|
10
|
+
Three skills ship with the theme, in `.agents/skills/`. Start from the row
|
|
11
|
+
that matches the request:
|
|
12
|
+
|
|
13
|
+
| The request | Start with |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| Build or restyle a theme that must match a design: a screenshot or image, a live website URL, or a Shopify theme measured with the collector | **`abcart-theme-from-design`**: the route from the empty folder to a home page on a store, its design as tokens, its sections, content and claims, its layout and phone patterns, and the measured match to the design. Its steps are in its references folder |
|
|
16
|
+
| Collect a Shopify theme's public frontend to measure it | **`shopify-theme-asset-collector`**: finds the demo storefront and saves its pages, styles, scripts, images and fonts, with a manifest of the sections. Its output is for measuring, never for shipping |
|
|
17
|
+
| Any SDK name, field, platform behaviour, or a failing check | **`abcart-docs`**: find the answer in this theme's code, the installed declarations and the documentation. Never guess |
|
|
18
|
+
|
|
19
|
+
A whole theme can be built unattended: give the agent the brief that `abcart-theme-from-design` asks for in one message, and it runs to the end, committing after each gate and finishing with its report.
|
|
20
|
+
|
|
21
|
+
## What it is made of
|
|
22
|
+
|
|
23
|
+
| Where | What |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `src/theme/theme.ts` | The theme: 12 pages (surfaces), the header and footer (areas), settings, every section. What Studio reads (`/abcart-theme.json`) |
|
|
26
|
+
| `src/theme/sections/*.ts` | One definition per section or family: its fields, its data (`load`), its presets |
|
|
27
|
+
| `src/theme/documents/*.json` | The layout each page starts with, before a merchant edits it |
|
|
28
|
+
| `src/theme/content/*.ts` | Every word the shopper reads, ar/fr/en side by side, by area |
|
|
29
|
+
| `src/theme/labels.ts` | What Studio calls each page, section, field and option |
|
|
30
|
+
| `src/theme/palette.ts` | The starter's colors, written once: the only literal colors in the theme's code (with `tokens.css`) |
|
|
31
|
+
| `src/theme/settings.ts` | Store-wide settings: color schemes, corners, product cards, promises, social links |
|
|
32
|
+
| `src/theme/key.ts`, `locales.ts` | The theme's permanent key and version; its languages |
|
|
33
|
+
| `src/components/` | Presentation. A section renders through `src/components/ui/Section.astro`; product blocks live in `src/components/product/blocks/` |
|
|
34
|
+
| `src/pages/` | Thin routes: read the resource, `return notFound(Astro)` when missing, render the surface with `src/components/surface/Sections.astro` |
|
|
35
|
+
| `src/lib/` | Server-side glue, no business rules. `store.ts` is the only file that creates an SDK client |
|
|
36
|
+
| `src/scripts/` | Everything the browser runs. `order-form.ts` binds each order form and wires its parts in `src/scripts/checkout/`: `delivery`, `quote`, `coupon`, `otp`, `submit`, `tracking` |
|
|
37
|
+
| `src/styles/` | `tokens.css` is the design system; the other files style areas from its tokens |
|
|
38
|
+
| `src/middleware.ts`, `src/actions/` | Wiring only: `createStorefrontMiddleware` decides the store, the language, redirects, the preview and the order |
|
|
39
|
+
| `tests/` | Contract, guard, Studio, checkout and copy tests |
|
|
40
|
+
| `.agents/skills/` | The three skills above, each with its own references and scripts |
|
|
41
|
+
|
|
42
|
+
## Commands
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npm install
|
|
46
|
+
npm run dev # http://localhost:4321, needs .dev.vars (see .dev.vars.example)
|
|
47
|
+
npm run check # astro check: 0 errors, 0 warnings
|
|
48
|
+
npm test # contract, guard, Studio, checkout and copy tests
|
|
49
|
+
npm run build # Cloudflare Workers build
|
|
50
|
+
npm run build:vercel # Vercel build
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Definition of done:** `npm run check`, `npm test`, `npm run build` and
|
|
54
|
+
`npm run build:vercel` pass, and every page you touched was looked at on a
|
|
55
|
+
phone (390 px) and a desktop, in Arabic and in one left-to-right language.
|
|
56
|
+
|
|
57
|
+
## Restyling this theme
|
|
58
|
+
|
|
59
|
+
The look is made of tokens, fonts and colour schemes, so one file restyles the
|
|
60
|
+
store and the theme can take any brand.
|
|
61
|
+
|
|
62
|
+
**Change freely:**
|
|
63
|
+
- `src/styles/tokens.css`: every design value (type, motion, shapes, borders,
|
|
64
|
+
surfaces, corners, shadows) and the right-to-left values for Arabic.
|
|
65
|
+
- The fonts in `public/fonts/`: one Arabic and one Latin family, each limited to
|
|
66
|
+
its script. A new file needs its `@font-face` rule in `tokens.css`, its
|
|
67
|
+
preload in `src/layouts/StoreLayout.astro` and its licence line in
|
|
68
|
+
`public/fonts/OFL.txt`; a test checks all three.
|
|
69
|
+
- The starter's colours in `src/theme/palette.ts`, and the default colour schemes
|
|
70
|
+
in `src/theme/settings.ts` that use them.
|
|
71
|
+
- The layout rules in the stylesheets, and the markup of presentational
|
|
72
|
+
components.
|
|
73
|
+
|
|
74
|
+
**Keep working:**
|
|
75
|
+
- **No design value is a literal.** Every size, line height, letter-spacing,
|
|
76
|
+
weight, colour, radius, shadow, border, surface, filter, aspect ratio, motion
|
|
77
|
+
and opacity is a token (`var(--…)`). A colour inside a rule, in `tokens.css`
|
|
78
|
+
or in `palette.ts` only. Layout geometry (gaps, padding, margins, widths,
|
|
79
|
+
insets, grids, z-index) stays in the stylesheets. `design-values.test.ts`
|
|
80
|
+
names each literal that breaks this.
|
|
81
|
+
- **Token names say where they are used:** `--<category>-<role>` with an
|
|
82
|
+
optional `-narrow`, `-wide`, `-touch` or `-reduced`. A phone rule is always
|
|
83
|
+
`-narrow`, never `-phone`, and a name never ends in a number: a second value for
|
|
84
|
+
a role gets a role name. Search before you add one. A name is never reused for
|
|
85
|
+
another value.
|
|
86
|
+
- **Text is readable on its band:** every colour scheme keeps its text, headings
|
|
87
|
+
and accents at WCAG AA (4.5:1) on its background, and its button words on its
|
|
88
|
+
button. A light band takes dark ink: white words on sand are 2.3:1. `contrast.test.ts`
|
|
89
|
+
names each failing pair, and the offer ribbon's words are checked on its fill.
|
|
90
|
+
- **Names keep their own direction:** a reviewer's or customer's name carries
|
|
91
|
+
`dir="auto"`, so a Latin name's full stop stays after it. `rules.test.ts` checks it.
|
|
92
|
+
- **Card rows fill their row:** a grid of cards uses
|
|
93
|
+
`repeat(auto-fit, minmax(min(100%, 340px), 1fr))`, not a fixed column count. Two
|
|
94
|
+
cards in a three-column grid then fill the row, and six make two even rows.
|
|
95
|
+
- **A confirmation never covers a drawer:** the add-to-cart confirmation shows only
|
|
96
|
+
when no cart drawer opens with it. `rules.test.ts` checks it.
|
|
97
|
+
- **Colour-dependent tokens** (one that reads a colour of the scheme) live in the
|
|
98
|
+
`:root, .ab-scheme` block, so they resolve on each section that sets a scheme.
|
|
99
|
+
- **Timings:** a script reads each timing from a motion token through
|
|
100
|
+
`motionMs()` in `src/lib/motion.ts`. A behaviour timer (a debounce, a clock
|
|
101
|
+
tick) stays literal, and the guard names it.
|
|
102
|
+
- **Inline styles carry data only**: an index, a merchant's value, never a
|
|
103
|
+
design number.
|
|
104
|
+
- **Colours a merchant picks:** `.ab-scheme` derives the tokens from
|
|
105
|
+
`--ab-color-*`; an element wearing a scheme carries `schemeClass(id)` only.
|
|
106
|
+
- **Every part is editable through the SDK:** each field reaches the component
|
|
107
|
+
that renders it (or its `load`); every select says what its options mean; every
|
|
108
|
+
number is bounded; every list has a bound and a title per item; every label and
|
|
109
|
+
help text is in each language. Every insertable section starts from a preset, or
|
|
110
|
+
`NO_PRESET` in `editability.test.ts` says why it does not. A preset is rendered
|
|
111
|
+
for a shopper and in the editor's preview in every language. Use the SDK's
|
|
112
|
+
validators (`validateThemeDefinition`, `validateThemeManifest`, `validatePageData`)
|
|
113
|
+
as they are. Never invent a field kind or a rule the SDK does not have.
|
|
114
|
+
- **Help where a choice is not obvious:** `HELP` in `labels.ts`, shown as a field's
|
|
115
|
+
`description`. A field that depends on another is hidden with `visibleIf`.
|
|
116
|
+
- **Right to left:** logical properties (`margin-inline-start`,
|
|
117
|
+
`inset-inline-end`), never `left` or `right` for layout, except in a rule that
|
|
118
|
+
names one direction or the WhatsApp widget's side (a test checks it).
|
|
119
|
+
Directional icons carry `icon-directional`. Phone and order numbers stay left
|
|
120
|
+
to right.
|
|
121
|
+
- **Layouts that mirror:** a split section is a two-column grid with the photo
|
|
122
|
+
first; text on a photo sits in its own panel; a grid that replaces a flex row
|
|
123
|
+
sets its own `justify-content`.
|
|
124
|
+
- **What scripts and forms rely on:** every `name="…"` in the order form, every
|
|
125
|
+
`data-*` attribute a script reads, the `#order` anchor, and the form's `action`.
|
|
126
|
+
- **Text:** never write visible words in markup; use the copy files.
|
|
127
|
+
- **Studio:** never remove `Sections.astro`, `Area.astro` or `PreviewBridge.astro`.
|
|
128
|
+
Keep `class` and `style` from a section's props on its outer element, through
|
|
129
|
+
`Section.astro`.
|
|
130
|
+
|
|
131
|
+
## Rules
|
|
132
|
+
|
|
133
|
+
**Both hosts, every feature.** The theme builds for Cloudflare Workers and
|
|
134
|
+
for Vercel (`DEPLOY_TARGET` in `astro.config.mjs`), so AbCart Cloud can deploy
|
|
135
|
+
it wherever a merchant chooses, and it supports every feature the platform
|
|
136
|
+
has (reviews, the basket, the phone check, codes…), each shown only when the
|
|
137
|
+
store turns it on. Never remove a host or a feature; a test checks the hosts.
|
|
138
|
+
|
|
139
|
+
**The platform is the SDK's.** Import `@abcart/*` through published entry
|
|
140
|
+
points only. Prices, offers, delivery fees, coupons, stock and order validity
|
|
141
|
+
are the server's: show what the SDK and the server's quote say, never compute
|
|
142
|
+
them. A missing capability is an SDK change, never a second implementation
|
|
143
|
+
here.
|
|
144
|
+
|
|
145
|
+
**One client per request.** Only `src/lib/store.ts` creates an SDK client;
|
|
146
|
+
everything else reads `Astro.locals.store.client`. The API key never reaches
|
|
147
|
+
browser code.
|
|
148
|
+
|
|
149
|
+
**No validator in the browser.** Browser code never imports Zod or a schema.
|
|
150
|
+
From `@abcart/theme` it takes only `./lifecycle` and `./messages`.
|
|
151
|
+
|
|
152
|
+
**Sections read data in `load`, never in the component.** A definition's
|
|
153
|
+
`load` reads through `reads.get(key, …)` so sections share one read per page.
|
|
154
|
+
A section reads its page's product or landing page through `routeProduct` /
|
|
155
|
+
`routeLanding` (`src/theme/sections/shared.ts`).
|
|
156
|
+
|
|
157
|
+
**Every section is editable the same way.** A `scheme` field
|
|
158
|
+
(`schemeField()`), a `style` field
|
|
159
|
+
(`styleField()`), rendered through `Section.astro`; a test checks that every
|
|
160
|
+
section has both. A photo a merchant picks
|
|
161
|
+
is an `image` field, never a `url`; prose is `richtext`. A section with
|
|
162
|
+
nothing to show renders nothing for a shopper and an `EditorPlaceholder` in
|
|
163
|
+
Studio (`isPreview(blocks)`).
|
|
164
|
+
|
|
165
|
+
**The style classes win.** Never set padding or width on what a `style` field
|
|
166
|
+
controls.
|
|
167
|
+
|
|
168
|
+
**Every behaviour survives the preview.** Browser scripts bind with
|
|
169
|
+
`bindEach()` / `onEachPage()` from `@abcart/theme/lifecycle`, so Studio can
|
|
170
|
+
swap a section and the script binds the new markup once.
|
|
171
|
+
|
|
172
|
+
**The browser asks through the SDK.** The order form quotes with
|
|
173
|
+
`createQuoter`, tracks an unfinished checkout with
|
|
174
|
+
`createBrowserAbandonedCheckoutTracker`, and the review form runs a
|
|
175
|
+
`createReviewSession`. Their paths are the SDK's `STOREFRONT_API_PATHS`
|
|
176
|
+
(`storefrontApiPath` fills a parameter), each mounted by a one-line file
|
|
177
|
+
under `src/pages/api/`; a test checks both ways and that no other file
|
|
178
|
+
writes an `/api/` path.
|
|
179
|
+
|
|
180
|
+
**Words come from the copy.** Every key exists in ar, fr and en; a count is a
|
|
181
|
+
plural message with each language's CLDR forms (Arabic has six); no key that
|
|
182
|
+
nothing reads. The browser gets only the keys listed in
|
|
183
|
+
`src/lib/browser-copy.ts`.
|
|
184
|
+
|
|
185
|
+
**The theme states no fact about a store.** Delivery reach, delivery or
|
|
186
|
+
exchange periods, guarantees, percentages, opening hours, phone calls,
|
|
187
|
+
prices, phone numbers and addresses are the store's: they come from its data
|
|
188
|
+
(the catalog, its contact details, the order form's quote) or from a field
|
|
189
|
+
the merchant fills in. Copy, section defaults, presets, settings and page
|
|
190
|
+
documents say only what is true of every store; a test checks them.
|
|
191
|
+
|
|
192
|
+
**A store that cannot be read still renders.** The middleware falls back to
|
|
193
|
+
the SDK's `unavailableStoreConfig`, in this one place.
|
|
194
|
+
|
|
195
|
+
**Links go through the SDK.** Platform pages are `storefrontPath()` +
|
|
196
|
+
`localizeHref()`; a shopper on `/fr/…` stays in French. A landing page
|
|
197
|
+
(`/lp/…`) is the exception: one campaign in the store's primary language,
|
|
198
|
+
so it has no language prefix, menu or alternate links: the SDK redirects
|
|
199
|
+
`/fr/lp/…` and its `isSingleLanguagePage` empties the language menu
|
|
200
|
+
(`pageLanguages` in `src/lib/context.ts`).
|
|
201
|
+
|
|
202
|
+
**A not-found is never cached.** Return `notFound(Astro)`.
|
|
203
|
+
|
|
204
|
+
**Every cached page carries the `pages` tag** in `astro.config.mjs`
|
|
205
|
+
`routeRules`, as `PAGES_CACHE_TAG` (never the literal), so a Studio publish
|
|
206
|
+
shows at once; `src/pages/abcart-revalidate.ts` is the SDK's
|
|
207
|
+
`revalidateEndpoint`.
|
|
208
|
+
|
|
209
|
+
**The WhatsApp widget is the merchant's.** Every WhatsApp link comes from
|
|
210
|
+
`storeWhatsApp` (`src/lib/whatsapp.ts`); no file writes a `wa.me` link.
|
|
211
|
+
|
|
212
|
+
**The theme key is permanent.** `THEME_KEY` names every merchant's saved
|
|
213
|
+
edits; never change it once a store uses the theme. `THEME_VERSION` equals
|
|
214
|
+
`package.json` `version`; a change that removes a section, a field or a copy
|
|
215
|
+
key merchants may have edited needs a new major version.
|
|
216
|
+
|
|
217
|
+
## Testing
|
|
218
|
+
|
|
219
|
+
- `tests/unit/contract.test.ts` renders every page and area through the SDK's
|
|
220
|
+
renderer, for a shopper and in Studio's preview, from store answers in
|
|
221
|
+
`tests/fixtures/`.
|
|
222
|
+
- `tests/unit/guards.test.ts` enforces the rules above on the source
|
|
223
|
+
(`tests/unit/source.ts` is the one walker every guard reads).
|
|
224
|
+
- `tests/unit/design-values.test.ts` enforces the token rules: no literal design
|
|
225
|
+
value in a stylesheet, no literal timing in a script, data-only inline styles,
|
|
226
|
+
and colour-dependent tokens on the scheme.
|
|
227
|
+
- `tests/unit/studio.test.ts` checks the manifest, the preview and the publish
|
|
228
|
+
revalidation with real Ed25519 keys, and that every composed route is cached.
|
|
229
|
+
- `tests/unit/checkout.test.ts` maps order outcomes and checks the order form's
|
|
230
|
+
delivery fields against the store's checkout settings.
|
|
231
|
+
- `tests/unit/copy.test.ts` checks every key in every language, the plural forms,
|
|
232
|
+
no unused key, no store fact, and the browser's key list.
|
|
233
|
+
- `tests/unit/footer.test.ts` checks that the logo, social links and contact
|
|
234
|
+
details come from the store's settings.
|
|
235
|
+
- `tests/unit/middleware.test.ts` checks the SDK's middleware, wired to this
|
|
236
|
+
store: a 404 keeps the shopper's language.
|
|
237
|
+
- `tests/unit/languages.test.ts` checks that landing pages are single-language.
|
|
238
|
+
|
|
239
|
+
A new rule gets a guard, and a guard is proven by breaking the code once and
|
|
240
|
+
watching it fail.
|