create-abcart-theme 0.0.0-stage → 0.10.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.
Files changed (253) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +2 -0
  4. package/README.md +64 -2
  5. package/bin/create-abcart-theme.mjs +4 -0
  6. package/package.json +47 -4
  7. package/src/args.mjs +113 -0
  8. package/src/banner.mjs +21 -0
  9. package/src/cli.mjs +119 -0
  10. package/src/create.mjs +82 -0
  11. package/src/package-manager.mjs +32 -0
  12. package/src/style.mjs +17 -0
  13. package/templates/default/.agents/skills/shopify-theme-asset-collector/SKILL.md +125 -0
  14. package/templates/default/.agents/skills/shopify-theme-asset-collector/scripts/collect_public_assets.py +370 -0
  15. package/templates/default/.agents/skills/wocart-docs/SKILL.md +146 -0
  16. package/templates/default/.agents/skills/wocart-theme-from-design/SKILL.md +58 -0
  17. package/templates/default/.agents/skills/wocart-theme-from-design/references/inputs-and-rights.md +47 -0
  18. package/templates/default/.agents/skills/wocart-theme-from-design/references/layout-rtl-and-phone.md +36 -0
  19. package/templates/default/.agents/skills/wocart-theme-from-design/references/measure-the-design.md +60 -0
  20. package/templates/default/.agents/skills/wocart-theme-from-design/references/tokens-sections-content.md +103 -0
  21. package/templates/default/.agents/skills/wocart-theme-from-design/references/verify-and-report.md +102 -0
  22. package/templates/default/.agents/skills/wocart-theme-from-design/scripts/compare-design.cjs +230 -0
  23. package/templates/default/.agents/skills/wocart-theme-from-design/scripts/qa-pages.cjs +219 -0
  24. package/templates/default/.dev.vars.example +12 -0
  25. package/templates/default/AGENTS.md +240 -0
  26. package/templates/default/README.md +184 -0
  27. package/templates/default/_gitignore +11 -0
  28. package/templates/default/astro.config.mjs +85 -0
  29. package/templates/default/package.json +36 -0
  30. package/templates/default/public/fonts/OFL.txt +96 -0
  31. package/templates/default/public/fonts/alexandria-arabic.woff2 +0 -0
  32. package/templates/default/public/fonts/fraunces-latin.woff2 +0 -0
  33. package/templates/default/src/actions/index.ts +22 -0
  34. package/templates/default/src/components/cart/AddToCartButton.astro +45 -0
  35. package/templates/default/src/components/cart/CartDrawer.astro +47 -0
  36. package/templates/default/src/components/cart/CartSummary.astro +11 -0
  37. package/templates/default/src/components/cart/FreeShipping.astro +7 -0
  38. package/templates/default/src/components/checkout/CheckoutMain.astro +29 -0
  39. package/templates/default/src/components/checkout/OrderForm.astro +280 -0
  40. package/templates/default/src/components/checkout/ThankYouMain.astro +68 -0
  41. package/templates/default/src/components/landing/LandingImages.astro +51 -0
  42. package/templates/default/src/components/landing/LandingOrder.astro +46 -0
  43. package/templates/default/src/components/landing/LandingProduct.astro +41 -0
  44. package/templates/default/src/components/listing/ListingMain.astro +93 -0
  45. package/templates/default/src/components/listing/PageMain.astro +52 -0
  46. package/templates/default/src/components/listing/Pagination.astro +31 -0
  47. package/templates/default/src/components/listing/SortControl.astro +35 -0
  48. package/templates/default/src/components/product/BuyBox.astro +96 -0
  49. package/templates/default/src/components/product/Description.astro +24 -0
  50. package/templates/default/src/components/product/Gallery.astro +66 -0
  51. package/templates/default/src/components/product/MobileBuyBar.astro +29 -0
  52. package/templates/default/src/components/product/OfferChoice.astro +66 -0
  53. package/templates/default/src/components/product/ProductMain.astro +40 -0
  54. package/templates/default/src/components/product/ProductReviews.astro +72 -0
  55. package/templates/default/src/components/product/RelatedProducts.astro +30 -0
  56. package/templates/default/src/components/product/blocks/BenefitsBlock.astro +13 -0
  57. package/templates/default/src/components/product/blocks/CollapsibleBlock.astro +20 -0
  58. package/templates/default/src/components/product/blocks/DescriptionBlock.astro +19 -0
  59. package/templates/default/src/components/product/blocks/DetailsBlock.astro +33 -0
  60. package/templates/default/src/components/product/blocks/GalleryBlock.astro +12 -0
  61. package/templates/default/src/components/product/blocks/OrderBlock.astro +30 -0
  62. package/templates/default/src/components/product/blocks/PriceBlock.astro +23 -0
  63. package/templates/default/src/components/product/blocks/RatingBlock.astro +16 -0
  64. package/templates/default/src/components/product/blocks/StockBlock.astro +22 -0
  65. package/templates/default/src/components/product/blocks/TextBlock.astro +11 -0
  66. package/templates/default/src/components/product/blocks/TitleBlock.astro +20 -0
  67. package/templates/default/src/components/reviews/ReviewCard.astro +46 -0
  68. package/templates/default/src/components/reviews/ReviewForm.astro +113 -0
  69. package/templates/default/src/components/reviews/VoiceNote.astro +60 -0
  70. package/templates/default/src/components/sections/CollectionCards.astro +65 -0
  71. package/templates/default/src/components/sections/Countdown.astro +57 -0
  72. package/templates/default/src/components/sections/Faq.astro +44 -0
  73. package/templates/default/src/components/sections/FeaturedProduct.astro +71 -0
  74. package/templates/default/src/components/sections/Hero.astro +99 -0
  75. package/templates/default/src/components/sections/ImageBanner.astro +46 -0
  76. package/templates/default/src/components/sections/ProductGrid.astro +47 -0
  77. package/templates/default/src/components/sections/RichText.astro +35 -0
  78. package/templates/default/src/components/sections/Steps.astro +46 -0
  79. package/templates/default/src/components/sections/Testimonials.astro +57 -0
  80. package/templates/default/src/components/shell/Footer.astro +80 -0
  81. package/templates/default/src/components/shell/Header.astro +89 -0
  82. package/templates/default/src/components/shell/LanguageMenu.astro +33 -0
  83. package/templates/default/src/components/shell/MobileMenu.astro +65 -0
  84. package/templates/default/src/components/shell/SearchDialog.astro +19 -0
  85. package/templates/default/src/components/shell/TopBar.astro +54 -0
  86. package/templates/default/src/components/shell/WhatsAppWidget.astro +111 -0
  87. package/templates/default/src/components/store/ContactMain.astro +79 -0
  88. package/templates/default/src/components/store/SearchMain.astro +56 -0
  89. package/templates/default/src/components/store/TrackOrderMain.astro +161 -0
  90. package/templates/default/src/components/surface/Area.astro +20 -0
  91. package/templates/default/src/components/surface/PreviewBridge.astro +24 -0
  92. package/templates/default/src/components/surface/Sections.astro +35 -0
  93. package/templates/default/src/components/ui/Breadcrumbs.astro +36 -0
  94. package/templates/default/src/components/ui/Button.astro +45 -0
  95. package/templates/default/src/components/ui/EditorPlaceholder.astro +24 -0
  96. package/templates/default/src/components/ui/Icon.astro +93 -0
  97. package/templates/default/src/components/ui/Logo.astro +36 -0
  98. package/templates/default/src/components/ui/Photo.astro +46 -0
  99. package/templates/default/src/components/ui/Price.astro +24 -0
  100. package/templates/default/src/components/ui/ProductCard.astro +41 -0
  101. package/templates/default/src/components/ui/Rating.astro +22 -0
  102. package/templates/default/src/components/ui/Section.astro +34 -0
  103. package/templates/default/src/components/ui/SectionHeading.astro +19 -0
  104. package/templates/default/src/env.d.ts +23 -0
  105. package/templates/default/src/layouts/StoreLayout.astro +145 -0
  106. package/templates/default/src/lib/browser-copy.ts +37 -0
  107. package/templates/default/src/lib/context.ts +89 -0
  108. package/templates/default/src/lib/coupon-notice.ts +47 -0
  109. package/templates/default/src/lib/i18n.ts +32 -0
  110. package/templates/default/src/lib/images.ts +38 -0
  111. package/templates/default/src/lib/listing-query.ts +41 -0
  112. package/templates/default/src/lib/money.ts +16 -0
  113. package/templates/default/src/lib/motion.ts +16 -0
  114. package/templates/default/src/lib/nav.ts +26 -0
  115. package/templates/default/src/lib/offer-tiles.ts +105 -0
  116. package/templates/default/src/lib/order-outcome.ts +66 -0
  117. package/templates/default/src/lib/otp-message.ts +21 -0
  118. package/templates/default/src/lib/products.ts +38 -0
  119. package/templates/default/src/lib/review-refusals.ts +31 -0
  120. package/templates/default/src/lib/store.ts +31 -0
  121. package/templates/default/src/lib/whatsapp.ts +29 -0
  122. package/templates/default/src/middleware.ts +23 -0
  123. package/templates/default/src/pages/404.astro +22 -0
  124. package/templates/default/src/pages/api/abandoned/convert.ts +4 -0
  125. package/templates/default/src/pages/api/abandoned/upsert.ts +4 -0
  126. package/templates/default/src/pages/api/cart/validate.ts +4 -0
  127. package/templates/default/src/pages/api/communes/[wilayaId].ts +4 -0
  128. package/templates/default/src/pages/api/otp/send.ts +4 -0
  129. package/templates/default/src/pages/api/otp/verify.ts +4 -0
  130. package/templates/default/src/pages/api/reviews/[productId].ts +3 -0
  131. package/templates/default/src/pages/api/reviews/eligibility.ts +3 -0
  132. package/templates/default/src/pages/api/reviews/submit.ts +3 -0
  133. package/templates/default/src/pages/api/reviews/upload.ts +3 -0
  134. package/templates/default/src/pages/category/[slug].astro +20 -0
  135. package/templates/default/src/pages/checkout.astro +25 -0
  136. package/templates/default/src/pages/collections/[handle].astro +20 -0
  137. package/templates/default/src/pages/contact.astro +17 -0
  138. package/templates/default/src/pages/index.astro +9 -0
  139. package/templates/default/src/pages/lp/[slug].astro +47 -0
  140. package/templates/default/src/pages/pages/[slug].astro +16 -0
  141. package/templates/default/src/pages/products/[handle].astro +37 -0
  142. package/templates/default/src/pages/products/index.astro +15 -0
  143. package/templates/default/src/pages/robots.txt.ts +9 -0
  144. package/templates/default/src/pages/search.astro +19 -0
  145. package/templates/default/src/pages/sitemap.xml.ts +12 -0
  146. package/templates/default/src/pages/thank-you.astro +33 -0
  147. package/templates/default/src/pages/track-order.astro +17 -0
  148. package/templates/default/src/pages/wocart-preview.astro +43 -0
  149. package/templates/default/src/pages/wocart-revalidate.ts +10 -0
  150. package/templates/default/src/pages/wocart-styles.css.ts +5 -0
  151. package/templates/default/src/pages/wocart-theme.json.ts +5 -0
  152. package/templates/default/src/scripts/cart.ts +371 -0
  153. package/templates/default/src/scripts/checkout/coupon.ts +96 -0
  154. package/templates/default/src/scripts/checkout/delivery.ts +86 -0
  155. package/templates/default/src/scripts/checkout/form.ts +54 -0
  156. package/templates/default/src/scripts/checkout/otp.ts +106 -0
  157. package/templates/default/src/scripts/checkout/picker.ts +169 -0
  158. package/templates/default/src/scripts/checkout/quote.ts +169 -0
  159. package/templates/default/src/scripts/checkout/submit.ts +113 -0
  160. package/templates/default/src/scripts/checkout/tracking.ts +74 -0
  161. package/templates/default/src/scripts/countdown.ts +29 -0
  162. package/templates/default/src/scripts/events.ts +4 -0
  163. package/templates/default/src/scripts/hero.ts +49 -0
  164. package/templates/default/src/scripts/listing.ts +13 -0
  165. package/templates/default/src/scripts/order-form.ts +100 -0
  166. package/templates/default/src/scripts/product.ts +306 -0
  167. package/templates/default/src/scripts/public-config.ts +79 -0
  168. package/templates/default/src/scripts/reviews.ts +358 -0
  169. package/templates/default/src/scripts/site.ts +131 -0
  170. package/templates/default/src/scripts/thank-you.ts +11 -0
  171. package/templates/default/src/scripts/voice-note.ts +94 -0
  172. package/templates/default/src/styles/base.css +1030 -0
  173. package/templates/default/src/styles/checkout.css +1111 -0
  174. package/templates/default/src/styles/global.css +12 -0
  175. package/templates/default/src/styles/product.css +871 -0
  176. package/templates/default/src/styles/reviews.css +533 -0
  177. package/templates/default/src/styles/sections.css +931 -0
  178. package/templates/default/src/styles/shell.css +970 -0
  179. package/templates/default/src/styles/tokens.css +583 -0
  180. package/templates/default/src/theme/api-routes.ts +10 -0
  181. package/templates/default/src/theme/content/catalog.ts +117 -0
  182. package/templates/default/src/theme/content/checkout.ts +168 -0
  183. package/templates/default/src/theme/content/editor.ts +21 -0
  184. package/templates/default/src/theme/content/index.ts +45 -0
  185. package/templates/default/src/theme/content/reviews.ts +76 -0
  186. package/templates/default/src/theme/content/shell.ts +59 -0
  187. package/templates/default/src/theme/content/types.ts +12 -0
  188. package/templates/default/src/theme/documents/catalog.json +11 -0
  189. package/templates/default/src/theme/documents/category.json +11 -0
  190. package/templates/default/src/theme/documents/checkout.json +11 -0
  191. package/templates/default/src/theme/documents/collection.json +11 -0
  192. package/templates/default/src/theme/documents/contact.json +11 -0
  193. package/templates/default/src/theme/documents/footer.area.json +11 -0
  194. package/templates/default/src/theme/documents/header.area.json +16 -0
  195. package/templates/default/src/theme/documents/home.json +313 -0
  196. package/templates/default/src/theme/documents/landing.json +8 -0
  197. package/templates/default/src/theme/documents/page.json +11 -0
  198. package/templates/default/src/theme/documents/product.json +125 -0
  199. package/templates/default/src/theme/documents/search.json +11 -0
  200. package/templates/default/src/theme/documents/thank-you.json +11 -0
  201. package/templates/default/src/theme/documents/track-order.json +11 -0
  202. package/templates/default/src/theme/fields.ts +61 -0
  203. package/templates/default/src/theme/key.ts +11 -0
  204. package/templates/default/src/theme/labels.ts +231 -0
  205. package/templates/default/src/theme/locales.ts +11 -0
  206. package/templates/default/src/theme/palette.ts +14 -0
  207. package/templates/default/src/theme/sections/collection-cards.ts +65 -0
  208. package/templates/default/src/theme/sections/faq.ts +74 -0
  209. package/templates/default/src/theme/sections/featured-product.ts +42 -0
  210. package/templates/default/src/theme/sections/hero.ts +47 -0
  211. package/templates/default/src/theme/sections/image-banner.ts +25 -0
  212. package/templates/default/src/theme/sections/index.ts +40 -0
  213. package/templates/default/src/theme/sections/landing.ts +150 -0
  214. package/templates/default/src/theme/sections/listing.ts +84 -0
  215. package/templates/default/src/theme/sections/product-grid.ts +42 -0
  216. package/templates/default/src/theme/sections/product.ts +297 -0
  217. package/templates/default/src/theme/sections/rich-text.ts +39 -0
  218. package/templates/default/src/theme/sections/shared.ts +54 -0
  219. package/templates/default/src/theme/sections/shell.ts +85 -0
  220. package/templates/default/src/theme/sections/store-pages.ts +101 -0
  221. package/templates/default/src/theme/sections/testimonials.ts +61 -0
  222. package/templates/default/src/theme/sections/thank-you.ts +35 -0
  223. package/templates/default/src/theme/settings.ts +124 -0
  224. package/templates/default/src/theme/theme.ts +65 -0
  225. package/templates/default/tests/fixtures/canvas-tote.json +62 -0
  226. package/templates/default/tests/fixtures/linen-shirt.json +128 -0
  227. package/templates/default/tests/unit/checkout.test.ts +241 -0
  228. package/templates/default/tests/unit/contract.test.ts +169 -0
  229. package/templates/default/tests/unit/contrast.test.ts +68 -0
  230. package/templates/default/tests/unit/copy.test.ts +101 -0
  231. package/templates/default/tests/unit/design-values.test.ts +95 -0
  232. package/templates/default/tests/unit/editability.test.ts +180 -0
  233. package/templates/default/tests/unit/fixtures.ts +91 -0
  234. package/templates/default/tests/unit/footer.test.ts +54 -0
  235. package/templates/default/tests/unit/guards.test.ts +340 -0
  236. package/templates/default/tests/unit/images.test.ts +26 -0
  237. package/templates/default/tests/unit/landing.test.ts +151 -0
  238. package/templates/default/tests/unit/languages.test.ts +42 -0
  239. package/templates/default/tests/unit/middleware.test.ts +53 -0
  240. package/templates/default/tests/unit/offer-tiles.test.ts +75 -0
  241. package/templates/default/tests/unit/render.ts +38 -0
  242. package/templates/default/tests/unit/reviews.test.ts +25 -0
  243. package/templates/default/tests/unit/rules.test.ts +59 -0
  244. package/templates/default/tests/unit/source.ts +75 -0
  245. package/templates/default/tests/unit/store-pages.test.ts +147 -0
  246. package/templates/default/tests/unit/studio.test.ts +202 -0
  247. package/templates/default/tests/unit/testimonials.test.ts +52 -0
  248. package/templates/default/tests/unit/thank-you.test.ts +52 -0
  249. package/templates/default/tests/unit/tracking.test.ts +29 -0
  250. package/templates/default/tests/unit/voice-note.test.ts +42 -0
  251. package/templates/default/tsconfig.json +13 -0
  252. package/templates/default/vitest.config.ts +15 -0
  253. package/templates/default/wrangler.jsonc +17 -0
@@ -0,0 +1,54 @@
1
+ ---
2
+ /** The announcement bar: the merchant's messages, the store's social links and its languages. */
3
+ import { localizeHref } from "@abcart/storefront";
4
+ import { schemeClass } from "@abcart/theme";
5
+ import Icon from "@/components/ui/Icon.astro";
6
+ import LanguageMenu from "./LanguageMenu.astro";
7
+ import { createTranslator } from "@/lib/i18n";
8
+
9
+ interface Props {
10
+ announcements?: { id: string; icon?: string; text?: string; link?: string }[];
11
+ showSocial?: boolean;
12
+ showLanguage?: boolean;
13
+ scheme?: string;
14
+ }
15
+
16
+ const { announcements = [], showSocial = true, showLanguage = false, scheme } = Astro.props;
17
+ const { settings, routing, languages: pageLanguages, locale, content } = Astro.locals.store;
18
+ const t = createTranslator(content, locale);
19
+ const social = showSocial ? settings.socialLinks.filter((link) => link.href) : [];
20
+ const messages = announcements.filter((message) => message.text);
21
+ const languages = showLanguage && pageLanguages.length > 0;
22
+ ---
23
+ {(messages.length > 0 || social.length > 0 || languages) && (
24
+ <div class:list={["topbar", schemeClass(scheme)]}>
25
+ <div class="topbar__inner">
26
+ <div class="topbar__social">
27
+ {social.map((link) => (
28
+ <a href={link.href} target="_blank" rel="noopener noreferrer" aria-label={link.label || link.network}><Icon name={link.network} size={15} /></a>
29
+ ))}
30
+ </div>
31
+
32
+ <div class="ticker" data-ticker>
33
+ {messages.length > 1 && (
34
+ <button class="ticker__arrow" type="button" data-ticker-prev aria-label={t("common.previous")}><Icon name="chevron-left" size={16} class="icon-directional" /></button>
35
+ )}
36
+ <div class="ticker__viewport" aria-live="polite">
37
+ {messages.map((message, index) => (
38
+ <span class="ticker__item" data-ticker-item data-active={index === 0 ? "true" : "false"} hidden={index !== 0}>
39
+ <Icon name={message.icon || "sparkles"} size={15} />
40
+ {message.link ? <a href={localizeHref(message.link, locale, routing)}>{message.text}</a> : <span>{message.text}</span>}
41
+ </span>
42
+ ))}
43
+ </div>
44
+ {messages.length > 1 && (
45
+ <button class="ticker__arrow" type="button" data-ticker-next aria-label={t("common.next")}><Icon name="chevron-right" size={16} class="icon-directional" /></button>
46
+ )}
47
+ </div>
48
+
49
+ <div class="topbar__end">
50
+ {showLanguage && <LanguageMenu place="bar" />}
51
+ </div>
52
+ </div>
53
+ </div>
54
+ )}
@@ -0,0 +1,111 @@
1
+ ---
2
+ /**
3
+ * The merchant's WhatsApp widget, as the App describes it: where it sits, its
4
+ * colour, whether it calls for attention, and — when the merchant wrote a
5
+ * greeting or a caption — a small card with the agent before the chat opens.
6
+ * The layout decides whether this page shows it, with the page's message.
7
+ * While an order form runs under the launcher it steps aside, so it never
8
+ * covers the form a shopper is filling.
9
+ */
10
+ import type { WhatsAppContact } from "@abcart/storefront";
11
+ import Icon from "@/components/ui/Icon.astro";
12
+
13
+ interface Props {
14
+ /** The store's WhatsApp on this page, every text resolved (`storeWhatsApp`). */
15
+ contact: WhatsAppContact;
16
+ closeLabel: string;
17
+ }
18
+
19
+ const { contact, closeLabel } = Astro.props;
20
+ const card = contact.welcomeMessage !== null || contact.caption !== null;
21
+ const label = contact.launcherLabel ?? contact.ctaLabel;
22
+ ---
23
+ <div class="wa" data-wa data-position={contact.position} data-accent={contact.accent} data-attention={contact.attention ? "true" : "false"}>
24
+ {card ? (
25
+ <>
26
+ <div class="wa__card" id="wa-card" role="dialog" aria-labelledby="wa-name" hidden data-wa-card>
27
+ <div class="wa__head">
28
+ {contact.avatarUrl ? <img class="wa__avatar" src={contact.avatarUrl} alt="" width="44" height="44" loading="lazy" /> : <span class="wa__avatar" aria-hidden="true"><Icon name="whatsapp" size={22} /></span>}
29
+ <div>
30
+ <p class="wa__name" id="wa-name">{contact.agentName}</p>
31
+ {contact.caption && <p class="wa__caption">{contact.caption}</p>}
32
+ </div>
33
+ <button class="wa__close" type="button" data-wa-close aria-label={closeLabel}><Icon name="close" size={18} /></button>
34
+ </div>
35
+ {contact.welcomeMessage && <p class="wa__bubble">{contact.welcomeMessage}</p>}
36
+ <a class="wa__cta" href={contact.href} target="_blank" rel="noopener noreferrer"><Icon name="whatsapp" size={18} />{contact.ctaLabel}</a>
37
+ </div>
38
+ <button class="whatsapp-float" type="button" aria-expanded="false" aria-controls="wa-card" data-wa-launcher>
39
+ <Icon name="whatsapp" size={22} />
40
+ <span>{label}</span>
41
+ </button>
42
+ </>
43
+ ) : (
44
+ <a class="whatsapp-float" href={contact.href} target="_blank" rel="noopener noreferrer" aria-label={label} data-wa-launcher>
45
+ <Icon name="whatsapp" size={22} />
46
+ <span>{label}</span>
47
+ </a>
48
+ )}
49
+ </div>
50
+
51
+ <script>
52
+ const root = document.querySelector<HTMLElement>("[data-wa]");
53
+ const launcher = root?.querySelector<HTMLElement>("[data-wa-launcher]");
54
+ const card = root?.querySelector<HTMLElement>("[data-wa-card]");
55
+ if (root && launcher) {
56
+ // Attention once per session, never under reduced motion.
57
+ let seen = false;
58
+ try {
59
+ seen = sessionStorage.getItem("wa:attention") === "1";
60
+ sessionStorage.setItem("wa:attention", "1");
61
+ } catch {
62
+ // Private mode: the widget still works.
63
+ }
64
+ if (seen || matchMedia("(prefers-reduced-motion: reduce)").matches) root.dataset.attention = "false";
65
+
66
+ // The launcher steps aside while an order form runs under it: in the screen's bottom band, on its side.
67
+ const forms = document.querySelectorAll<HTMLElement>("[data-order-scope]");
68
+ if (forms.length > 0 && "IntersectionObserver" in window) {
69
+ const underLauncher = new Set<Element>();
70
+ const besideLauncher = (form: Element) => {
71
+ const a = form.getBoundingClientRect();
72
+ const b = launcher.getBoundingClientRect();
73
+ return a.left < b.right && a.right > b.left;
74
+ };
75
+ const watch = new IntersectionObserver(
76
+ (entries) => {
77
+ for (const entry of entries) {
78
+ if (entry.isIntersecting && besideLauncher(entry.target)) underLauncher.add(entry.target);
79
+ else underLauncher.delete(entry.target);
80
+ }
81
+ root.dataset.yield = String(underLauncher.size > 0 && (!card || card.hidden));
82
+ },
83
+ { rootMargin: "-80% 0px 0px 0px" },
84
+ );
85
+ forms.forEach((form) => watch.observe(form));
86
+ }
87
+
88
+ if (card) {
89
+ const setOpen = (open: boolean) => {
90
+ card.hidden = !open;
91
+ launcher.setAttribute("aria-expanded", String(open));
92
+ root.dataset.attention = "false";
93
+ if (open) card.querySelector<HTMLElement>("a")?.focus();
94
+ };
95
+ launcher.addEventListener("click", () => setOpen(Boolean(card.hidden)));
96
+ root.querySelector("[data-wa-close]")?.addEventListener("click", () => {
97
+ setOpen(false);
98
+ launcher.focus();
99
+ });
100
+ document.addEventListener("keydown", (event) => {
101
+ if (event.key === "Escape" && !card.hidden) {
102
+ setOpen(false);
103
+ launcher.focus();
104
+ }
105
+ });
106
+ document.addEventListener("click", (event) => {
107
+ if (!card.hidden && !root.contains(event.target as Node)) setOpen(false);
108
+ });
109
+ }
110
+ }
111
+ </script>
@@ -0,0 +1,79 @@
1
+ ---
2
+ /**
3
+ * How a shopper reaches the store: its WhatsApp, phone, email and address —
4
+ * each a card once the store has it — the merchant's opening hours and note
5
+ * when written, its own pages, and how it is paid.
6
+ */
7
+ import { localizeHref, storefrontPath } from "@abcart/storefront";
8
+ import type { StyleValue } from "@abcart/theme";
9
+ import Section from "@/components/ui/Section.astro";
10
+ import Breadcrumbs from "@/components/ui/Breadcrumbs.astro";
11
+ import Icon from "@/components/ui/Icon.astro";
12
+ import { createTranslator } from "@/lib/i18n";
13
+ import { storeWhatsApp } from "@/lib/whatsapp";
14
+
15
+ interface Props {
16
+ title?: string;
17
+ subtitle?: string;
18
+ hours?: string;
19
+ note?: string;
20
+ showPages?: boolean;
21
+ showBreadcrumbs?: boolean;
22
+ scheme?: string;
23
+ style?: StyleValue;
24
+ }
25
+
26
+ const { title, subtitle, hours, note, showPages = true, showBreadcrumbs = true, scheme, style } = Astro.props;
27
+ const store = Astro.locals.store;
28
+ const { config, locale, routing } = store;
29
+ const t = createTranslator(store.content, locale);
30
+ const href = (path: string) => localizeHref(path, locale, routing);
31
+ const { phone, email, address } = config.contact;
32
+ const whatsapp = storeWhatsApp(store, Astro);
33
+
34
+ type Card = { icon: string; title: string; detail: string; href?: string; whatsapp?: boolean; ltr?: boolean };
35
+ const cards: Card[] = [
36
+ ...(whatsapp ? [{ icon: "whatsapp", title: t("contact.whatsapp"), detail: whatsapp.ctaLabel, href: whatsapp.href, whatsapp: true }] : []),
37
+ ...(phone ? [{ icon: "phone", title: t("contact.phone"), detail: phone, href: `tel:${phone.replace(/\s+/g, "")}`, ltr: true }] : []),
38
+ ...(email ? [{ icon: "mail", title: t("contact.email"), detail: email, href: `mailto:${email}`, ltr: true }] : []),
39
+ ...(address ? [{ icon: "map-pin", title: t("contact.address"), detail: address }] : []),
40
+ ...(hours ? [{ icon: "clock", title: t("contact.hoursTitle"), detail: hours }] : []),
41
+ ];
42
+ const pages = showPages ? config.pages.map((page) => ({ title: page.title, href: href(storefrontPath("page", { slug: page.slug })) })) : [];
43
+ ---
44
+ <Section scheme={scheme} style={style} class="contact-page">
45
+ {showBreadcrumbs && <Breadcrumbs items={[{ label: t("nav.home"), href: href(storefrontPath("home")) }, { label: t("contact.title") }]} />}
46
+ <header class="listing-head">
47
+ {title && <h1>{title}</h1>}
48
+ {subtitle && <p>{subtitle}</p>}
49
+ </header>
50
+ {cards.length > 0 ? (
51
+ <div class="contact-cards">
52
+ {cards.map((card) => card.href ? (
53
+ <a class="contact-card" href={card.href} target={card.whatsapp ? "_blank" : undefined} rel={card.whatsapp ? "noopener noreferrer" : undefined}>
54
+ <span class="contact-card__icon"><Icon name={card.icon} size={26} /></span>
55
+ <strong>{card.title}</strong>
56
+ <span dir={card.ltr ? "ltr" : undefined}>{card.detail}</span>
57
+ </a>
58
+ ) : (
59
+ <div class="contact-card">
60
+ <span class="contact-card__icon"><Icon name={card.icon} size={26} /></span>
61
+ <strong>{card.title}</strong>
62
+ <span class="contact-card__prose">{card.detail}</span>
63
+ </div>
64
+ ))}
65
+ </div>
66
+ ) : (
67
+ <p class="contact-none">{t("contact.none")}</p>
68
+ )}
69
+ {note && <p class="contact-note">{note}</p>}
70
+ {pages.length > 0 && (
71
+ <nav class="contact-help" aria-labelledby="contact-help-title">
72
+ <h2 id="contact-help-title">{t("footer.help")}</h2>
73
+ <ul>
74
+ {pages.map((page) => <li><a href={page.href}>{page.title}<Icon name="chevron-right" size={16} class="icon-directional" /></a></li>)}
75
+ </ul>
76
+ </nav>
77
+ )}
78
+ <p class="contact-page__note"><Icon name="cash" size={18} />{t("product.cod")}</p>
79
+ </Section>
@@ -0,0 +1,56 @@
1
+ ---
2
+ /**
3
+ * The search box and what it finds: the products a shopper's words name,
4
+ * best match first unless an order is chosen, a page at a time.
5
+ */
6
+ import { localizeHref, storefrontPath } from "@abcart/storefront";
7
+ import type { StyleValue } from "@abcart/theme";
8
+ import Section from "@/components/ui/Section.astro";
9
+ import ProductCard from "@/components/ui/ProductCard.astro";
10
+ import Breadcrumbs from "@/components/ui/Breadcrumbs.astro";
11
+ import Icon from "@/components/ui/Icon.astro";
12
+ import Pagination from "@/components/listing/Pagination.astro";
13
+ import SortControl from "@/components/listing/SortControl.astro";
14
+ import { createTranslator } from "@/lib/i18n";
15
+ import { listingHref, pageCount } from "@/lib/listing-query";
16
+ import type { SearchView } from "@/theme/sections/store-pages";
17
+
18
+ interface Props {
19
+ view: SearchView;
20
+ showBreadcrumbs?: boolean;
21
+ showSort?: boolean;
22
+ scheme?: string;
23
+ style?: StyleValue;
24
+ }
25
+
26
+ const { view, showBreadcrumbs = true, showSort = true, scheme, style } = Astro.props;
27
+ const { content, locale, routing } = Astro.locals.store;
28
+ const t = createTranslator(content, locale);
29
+ const href = (path: string) => localizeHref(path, locale, routing);
30
+ const searchHref = href(storefrontPath("search"));
31
+ const { query, page, sort, result } = view;
32
+ const title = query ? t("search.results", { count: result.total, query }) : t("search.title");
33
+ ---
34
+ <Section scheme={scheme} style={style} class="search-page">
35
+ {showBreadcrumbs && <Breadcrumbs items={[{ label: t("nav.home"), href: href(storefrontPath("home")) }, { label: t("search.title") }]} />}
36
+ <header class="listing-head">
37
+ <h1>{title}</h1>
38
+ <form method="get" action={searchHref} role="search" class="search-page__form">
39
+ <Icon name="search" size={19} class="search-dialog__icon" />
40
+ <input class="input" type="search" name="q" value={query} placeholder={t("search.placeholder")} aria-label={t("search.placeholder")} enterkeyhint="search" />
41
+ <button class="btn" type="submit">{t("search.submit")}</button>
42
+ </form>
43
+ </header>
44
+ {showSort && query && (result.items.length > 0 || sort) && <SortControl action={searchHref} sort={sort} keep={{ q: query }} />}
45
+ {query && result.items.length > 0 ? (
46
+ <div class="product-grid">{result.items.map((product, index) => <ProductCard product={product} priority={index < 2} />)}</div>
47
+ ) : (
48
+ <div class="empty-state">
49
+ <Icon name="search" size={44} />
50
+ {query && <h2>{t("search.empty")}</h2>}
51
+ <p>{t("search.hint")}</p>
52
+ <a class="btn" href={href(storefrontPath("catalog"))}>{t("nav.shop")}</a>
53
+ </div>
54
+ )}
55
+ <Pagination page={page} hasNext={result.hasNext} pages={pageCount(result.total)} href={(at) => listingHref(searchHref, at, sort, { q: query })} />
56
+ </Section>
@@ -0,0 +1,161 @@
1
+ ---
2
+ /**
3
+ * Where a shopper's order is. A plain form posts the order number and the
4
+ * phone to an action; the page renders from the same POST, so it needs no
5
+ * script and the answer is never cached. The title and the introduction are
6
+ * the merchant's.
7
+ */
8
+ import { actions } from "astro:actions";
9
+ import { localizeHref, SHOPPER_ORDER_JOURNEY, SHOPPER_ORDER_STAGES, storefrontPath } from "@abcart/storefront";
10
+ import type { OrderLookup } from "@abcart/storefront/astro";
11
+ import type { StyleValue } from "@abcart/theme";
12
+ import Section from "@/components/ui/Section.astro";
13
+ import Breadcrumbs from "@/components/ui/Breadcrumbs.astro";
14
+ import Icon from "@/components/ui/Icon.astro";
15
+ import { ORDER_EXAMPLE } from "@/lib/order-outcome";
16
+ import { createTranslator, formatDate } from "@/lib/i18n";
17
+ import { money } from "@/lib/money";
18
+ import { storeWhatsApp } from "@/lib/whatsapp";
19
+ import type { ContentKey } from "@/theme/content";
20
+
21
+ interface Props {
22
+ title?: string;
23
+ subtitle?: string;
24
+ showBreadcrumbs?: boolean;
25
+ scheme?: string;
26
+ style?: StyleValue;
27
+ }
28
+
29
+ const { title, subtitle, showBreadcrumbs = true, scheme, style } = Astro.props;
30
+ const store = Astro.locals.store;
31
+ const t = createTranslator(store.content, store.locale);
32
+ const href = (path: string) => localizeHref(path, store.locale, store.routing);
33
+ const pagePath = href(storefrontPath("trackOrder"));
34
+
35
+ const result = Astro.getActionResult(actions.orderStatus);
36
+ const lookup: OrderLookup | { status: "missing" } | null = result?.data?.lookup ?? (result?.error ? { status: "missing" } : null);
37
+ const asked = result?.data?.asked ?? { orderNumber: (Astro.url.searchParams.get("order") ?? "").trim().slice(0, 64), phone: "" };
38
+ const order = lookup?.status === "found" ? lookup.order : null;
39
+
40
+ function refusalWords(answer: typeof lookup): string | null {
41
+ switch (answer?.status) {
42
+ case "missing":
43
+ return t("track.missing");
44
+ case "invalid-number":
45
+ return t("track.invalidNumber", { example: ORDER_EXAMPLE });
46
+ case "invalid-phone":
47
+ return t("track.invalidPhone");
48
+ case "not-found":
49
+ return t("track.notFound");
50
+ case "rate-limited":
51
+ return answer.retryAfterSeconds ? t("track.rateLimited", { count: Math.ceil(answer.retryAfterSeconds / 60) }) : t("track.rateLimitedLater");
52
+ case "failed":
53
+ return t("track.failed");
54
+ default:
55
+ return null;
56
+ }
57
+ }
58
+ const refusal = refusalWords(lookup);
59
+
60
+ const STAGE_WORDS: Record<(typeof SHOPPER_ORDER_STAGES)[number], { title: ContentKey; hint: ContentKey }> = {
61
+ placed: { title: "track.stage.placed", hint: "track.stage.placed.hint" },
62
+ confirmed: { title: "track.stage.confirmed", hint: "track.stage.confirmed.hint" },
63
+ preparing: { title: "track.stage.preparing", hint: "track.stage.preparing.hint" },
64
+ shipped: { title: "track.stage.shipped", hint: "track.stage.shipped.hint" },
65
+ out_for_delivery: { title: "track.stage.outForDelivery", hint: "track.stage.outForDelivery.hint" },
66
+ delivered: { title: "track.stage.delivered", hint: "track.stage.delivered.hint" },
67
+ returned: { title: "track.stage.returned", hint: "track.stage.returned.hint" },
68
+ cancelled: { title: "track.stage.cancelled", hint: "track.stage.cancelled.hint" },
69
+ };
70
+ const known = (stage: string): stage is (typeof SHOPPER_ORDER_STAGES)[number] => (SHOPPER_ORDER_STAGES as readonly string[]).includes(stage);
71
+ // A stage a newer server adds has the general words, and no place on the journey.
72
+ const words = order ? (known(order.stage) ? STAGE_WORDS[order.stage] : { title: "track.stage.other", hint: "track.stage.other.hint" } satisfies { title: ContentKey; hint: ContentKey }) : null;
73
+ const reached = order ? (SHOPPER_ORDER_JOURNEY as readonly string[]).indexOf(order.stage) : -1;
74
+ const ended = order?.stage === "returned" || order?.stage === "cancelled";
75
+
76
+ const symbol = store.config.currencySymbol || store.config.currency;
77
+ // A question about the order goes to the store's WhatsApp, else to its contact page.
78
+ const whatsapp = order ? storeWhatsApp(store, Astro, { kind: "order", order: order.orderNumber }) : null;
79
+ const contactHref = order ? (whatsapp ? whatsapp.href : href(storefrontPath("contact"))) : null;
80
+ ---
81
+ <Section scheme={scheme} style={style} class="track">
82
+ {showBreadcrumbs && <Breadcrumbs items={[{ label: t("nav.home"), href: href(storefrontPath("home")) }, { label: t("track.title") }]} />}
83
+ <header class="listing-head">
84
+ {title && <h1>{title}</h1>}
85
+ {!order && subtitle && <p>{subtitle}</p>}
86
+ </header>
87
+
88
+ {order && words ? (
89
+ <article class="track__card" aria-labelledby="track-stage">
90
+ <div class="track__head">
91
+ <div class="thanks__number">
92
+ <small>{t("track.number")}</small>
93
+ <strong dir="ltr">{order.orderNumber}</strong>
94
+ </div>
95
+ <p class="track__placed">{t("track.placedOn", { date: formatDate(order.placedAt, store.locale) })}</p>
96
+ </div>
97
+
98
+ <div class:list={["track__stage", ended && "track__stage--ended", order.stage === "delivered" && "track__stage--done"]}>
99
+ <span class="track__stage-icon"><Icon name={ended ? "alert" : order.stage === "delivered" ? "check-circle" : "truck"} size={26} /></span>
100
+ <div>
101
+ <h2 id="track-stage">{t(words.title)}</h2>
102
+ <p>{t(words.hint)}</p>
103
+ </div>
104
+ </div>
105
+
106
+ {reached >= 0 && (
107
+ <ol class="track__journey" aria-label={t("track.progress")}>
108
+ {SHOPPER_ORDER_JOURNEY.map((stage, index) => (
109
+ <li class:list={["track__step", index < reached && "is-done", index === reached && "is-current"]} aria-current={index === reached ? "step" : undefined}>
110
+ <span class="track__dot" aria-hidden="true">{index < reached ? <Icon name="check" size={14} strokeWidth={2.6} /> : null}</span>
111
+ <span class="track__step-label">{t(STAGE_WORDS[stage].title)}</span>
112
+ </li>
113
+ ))}
114
+ </ol>
115
+ )}
116
+
117
+ <dl class="thanks__details track__facts">
118
+ <div><dt><small>{t("track.delivery")}</small></dt><dd><strong>{t(order.deliveryType === "stop_desk" ? "track.delivery.stopDesk" : "track.delivery.home")}</strong></dd></div>
119
+ <div><dt><small>{t("track.total")}</small></dt><dd><strong>{money(order.total, symbol, store.locale)}</strong></dd></div>
120
+ {order.tracking && (
121
+ <div class="track__fact--wide"><dt><small>{t("track.tracking")}</small></dt><dd><strong dir="ltr">{order.tracking.carrier ? `${order.tracking.carrier} · ${order.tracking.number}` : order.tracking.number}</strong></dd></div>
122
+ )}
123
+ </dl>
124
+
125
+ <section class="track__lines" aria-labelledby="track-items">
126
+ <h3 id="track-items">{t("track.items")}</h3>
127
+ <ul>
128
+ {order.lines.map((line) => (
129
+ <li>
130
+ <span class="track__line-name">{line.name}{line.variantLabel && <small> · {line.variantLabel}</small>}</span>
131
+ <span class="track__qty" dir="ltr">×{line.quantity}</span>
132
+ </li>
133
+ ))}
134
+ </ul>
135
+ </section>
136
+
137
+ <div class="thanks__actions">
138
+ {contactHref && (
139
+ <a class="btn" href={contactHref} target={whatsapp ? "_blank" : undefined} rel={whatsapp ? "noopener noreferrer" : undefined}>
140
+ <Icon name={whatsapp ? "whatsapp" : "mail"} size={18} /> {t("track.contact")}
141
+ </a>
142
+ )}
143
+ <a class="btn btn--ghost" href={pagePath}>{t("track.another")}</a>
144
+ </div>
145
+ </article>
146
+ ) : (
147
+ <form class="track__form" method="POST" action={`${pagePath}${actions.orderStatus}`}>
148
+ <div class="field">
149
+ <label class="field-label" for="track-number">{t("track.number")}</label>
150
+ <input class="input" id="track-number" name="orderNumber" value={asked.orderNumber} autocomplete="off" autocapitalize="characters" spellcheck="false" dir="ltr" placeholder={ORDER_EXAMPLE} maxlength="64" required aria-describedby="track-number-hint" />
151
+ <small class="field-hint" id="track-number-hint">{t("track.numberHint", { example: ORDER_EXAMPLE })}</small>
152
+ </div>
153
+ <div class="field">
154
+ <label class="field-label" for="track-phone">{t("track.phone")}</label>
155
+ <input class="input" id="track-phone" name="phone" type="tel" inputmode="tel" autocomplete="tel" dir="ltr" value={asked.phone} maxlength="32" required />
156
+ </div>
157
+ {refusal && <p class="track__refusal" role="alert"><Icon name="info" size={18} />{refusal}</p>}
158
+ <button class="btn btn--block" type="submit"><Icon name="search" size={18} />{t("track.submit")}</button>
159
+ </form>
160
+ )}
161
+ </Section>
@@ -0,0 +1,20 @@
1
+ ---
2
+ /**
3
+ * A part every page shares — the header, the footer — composed of sections like
4
+ * a page: the store's saved document for it, or the theme's default. When an
5
+ * editor is working on this area its draft renders, and only then are the
6
+ * area's sections marked for selection.
7
+ */
8
+ import { areaSurface } from "@abcart/theme";
9
+ import Sections from "./Sections.astro";
10
+
11
+ interface Props {
12
+ area: "header" | "footer";
13
+ }
14
+
15
+ const surface = areaSurface(Astro.props.area);
16
+ const draft = Astro.locals.preview?.draft;
17
+ const editing = draft?.surface === surface;
18
+ const document = editing && draft?.document !== undefined ? draft.document : await Astro.locals.store.client.pageData.get(surface);
19
+ ---
20
+ <Sections surface={surface} document={document} preview={editing} />
@@ -0,0 +1,24 @@
1
+ ---
2
+ /**
3
+ * The preview page's link to the editor that frames it: it reports where each
4
+ * marked section is, turns clicks into selections and re-renders the drafts
5
+ * the editor sends. Rendered on `/wocart-preview` only, from a verified token.
6
+ */
7
+ interface Props {
8
+ /** The verified token's editor origin: the only window it talks to. */
9
+ editor: string;
10
+ token: string;
11
+ }
12
+
13
+ const { editor, token } = Astro.props;
14
+ ---
15
+ <wocart-preview-bridge data-editor={editor} data-token={token} hidden></wocart-preview-bridge>
16
+
17
+ <script>
18
+ import { startPreviewBridge } from "@abcart/theme/preview";
19
+
20
+ const host = document.querySelector<HTMLElement>("wocart-preview-bridge");
21
+ if (host?.dataset.editor && host.dataset.token) {
22
+ startPreviewBridge({ editorOrigin: host.dataset.editor, token: host.dataset.token });
23
+ }
24
+ </script>
@@ -0,0 +1,35 @@
1
+ ---
2
+ /**
3
+ * A composed surface's sections: the document that wins — the store's saved one
4
+ * or an editor's draft, else the theme's default — completed with every
5
+ * required section and rendered through the SDK with one read cache per page.
6
+ * In a preview each section is marked so the editor can select it; a shopper's
7
+ * page carries no markers.
8
+ */
9
+ import InstanceView from "@abcart/theme/astro/InstanceView.astro";
10
+ import { createReadCache, type RendererIssue } from "@abcart/theme/astro";
11
+ import { resolveSurfaceDocument, type ReadCache } from "@abcart/theme";
12
+ import { theme } from "@/theme/theme";
13
+ import { THEME_KEY } from "@/theme/key";
14
+ import { buildThemeRenderContext } from "@/lib/context";
15
+
16
+ interface Props {
17
+ surface: string;
18
+ /** What the store saved for the surface (`null` when nothing), or an editor's draft. */
19
+ document: unknown;
20
+ preview?: boolean;
21
+ params?: Record<string, string | undefined>;
22
+ reads?: ReadCache;
23
+ }
24
+
25
+ const { surface, document, preview = false, params } = Astro.props;
26
+ const store = Astro.locals.store;
27
+ const context = buildThemeRenderContext(store, params);
28
+ const resolved = resolveSurfaceDocument(theme, surface, document, { content: store.content, locales: [store.locale, ...(context.fallbackLocales ?? [])] });
29
+ if (resolved.source === "default" && document) console.warn(`[${THEME_KEY}] ${surface}: saved document replaced by the default (${resolved.issues.length} issue(s))`);
30
+ const reads = Astro.props.reads ?? createReadCache();
31
+ const onIssue = (issue: RendererIssue) => console.warn(`[${THEME_KEY}] ${surface}: ${issue.code} ${issue.message}`);
32
+ ---
33
+ {resolved.page.sections.map((section) => (
34
+ <InstanceView instance={section} theme={theme} context={context} storefront={store.client} reads={reads} onIssue={onIssue} preview={preview} />
35
+ ))}
@@ -0,0 +1,36 @@
1
+ ---
2
+ import Icon from "./Icon.astro";
3
+ import { createTranslator } from "@/lib/i18n";
4
+
5
+ interface Crumb {
6
+ label: string;
7
+ href?: string;
8
+ }
9
+
10
+ interface Props {
11
+ /** From home to the page itself; the last one is the page. */
12
+ items: Crumb[];
13
+ }
14
+
15
+ const { items } = Astro.props;
16
+ const t = createTranslator(Astro.locals.store.content, Astro.locals.store.locale);
17
+ ---
18
+ <nav class="breadcrumbs" aria-label={t("a11y.breadcrumb")}>
19
+ <ol>
20
+ {items.map((item, index) => {
21
+ const last = index === items.length - 1;
22
+ return (
23
+ <li>
24
+ {index > 0 && <Icon name="chevron-right" size={13} class="icon-directional" />}
25
+ {last || !item.href ? (
26
+ <span aria-current={last ? "page" : undefined}>{item.label}</span>
27
+ ) : index === 0 ? (
28
+ <a href={item.href}><Icon name="home" size={15} /><span class="sr-only">{item.label}</span></a>
29
+ ) : (
30
+ <a href={item.href}>{item.label}</a>
31
+ )}
32
+ </li>
33
+ );
34
+ })}
35
+ </ol>
36
+ </nav>
@@ -0,0 +1,45 @@
1
+ ---
2
+ interface Props {
3
+ href?: string;
4
+ variant?: "primary" | "ghost" | "white" | "dark" | "link";
5
+ size?: "sm" | "md" | "lg";
6
+ block?: boolean;
7
+ type?: "button" | "submit";
8
+ class?: string;
9
+ ariaLabel?: string;
10
+ disabled?: boolean;
11
+ attrs?: Record<string, string | number | boolean | undefined>;
12
+ }
13
+
14
+ const {
15
+ href,
16
+ variant = "primary",
17
+ size = "md",
18
+ block = false,
19
+ type = "button",
20
+ class: className = "",
21
+ ariaLabel,
22
+ disabled = false,
23
+ attrs = {},
24
+ } = Astro.props;
25
+
26
+ const classes = [
27
+ "btn",
28
+ variant !== "primary" ? `btn--${variant}` : "",
29
+ size !== "md" ? `btn--${size}` : "",
30
+ block ? "btn--block" : "",
31
+ className,
32
+ ]
33
+ .filter(Boolean)
34
+ .join(" ");
35
+
36
+ ---
37
+ {href ? (
38
+ <a href={href} class={classes} aria-label={ariaLabel} {...Object.fromEntries(Object.entries(attrs).filter(([, v]) => v !== undefined && v !== false))}>
39
+ <slot />
40
+ </a>
41
+ ) : (
42
+ <button type={type} class={classes} aria-label={ariaLabel} disabled={disabled} {...Object.fromEntries(Object.entries(attrs).filter(([, v]) => v !== undefined && v !== false))}>
43
+ <slot />
44
+ </button>
45
+ )}
@@ -0,0 +1,24 @@
1
+ ---
2
+ /**
3
+ * What a section with nothing to show yet draws in the editor's preview — no
4
+ * products picked, no photos, no text — so the merchant can see, select and
5
+ * fill it. A shopper's page never renders it: a section with nothing to show
6
+ * renders nothing there.
7
+ */
8
+ import Icon from "./Icon.astro";
9
+ import { createTranslator } from "@/lib/i18n";
10
+ import type { ContentKey } from "@/theme/content";
11
+
12
+ interface Props {
13
+ /** What the merchant should do to fill the section. */
14
+ hint: ContentKey;
15
+ icon?: string;
16
+ }
17
+
18
+ const { hint, icon = "sparkles" } = Astro.props;
19
+ const t = createTranslator(Astro.locals.store.content, Astro.locals.store.locale);
20
+ ---
21
+ <div class="editor-placeholder">
22
+ <Icon name={icon} size={26} />
23
+ <p>{t(hint)}</p>
24
+ </div>