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.
- package/CHANGELOG.md +127 -0
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +64 -2
- package/bin/create-abcart-theme.mjs +4 -0
- package/package.json +47 -4
- package/src/args.mjs +113 -0
- package/src/banner.mjs +21 -0
- package/src/cli.mjs +119 -0
- package/src/create.mjs +82 -0
- package/src/package-manager.mjs +32 -0
- package/src/style.mjs +17 -0
- package/templates/default/.agents/skills/shopify-theme-asset-collector/SKILL.md +125 -0
- package/templates/default/.agents/skills/shopify-theme-asset-collector/scripts/collect_public_assets.py +370 -0
- package/templates/default/.agents/skills/wocart-docs/SKILL.md +146 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/SKILL.md +58 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/references/inputs-and-rights.md +47 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/references/layout-rtl-and-phone.md +36 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/references/measure-the-design.md +60 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/references/tokens-sections-content.md +103 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/references/verify-and-report.md +102 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/scripts/compare-design.cjs +230 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/scripts/qa-pages.cjs +219 -0
- package/templates/default/.dev.vars.example +12 -0
- package/templates/default/AGENTS.md +240 -0
- package/templates/default/README.md +184 -0
- package/templates/default/_gitignore +11 -0
- package/templates/default/astro.config.mjs +85 -0
- package/templates/default/package.json +36 -0
- package/templates/default/public/fonts/OFL.txt +96 -0
- package/templates/default/public/fonts/alexandria-arabic.woff2 +0 -0
- package/templates/default/public/fonts/fraunces-latin.woff2 +0 -0
- package/templates/default/src/actions/index.ts +22 -0
- package/templates/default/src/components/cart/AddToCartButton.astro +45 -0
- package/templates/default/src/components/cart/CartDrawer.astro +47 -0
- package/templates/default/src/components/cart/CartSummary.astro +11 -0
- package/templates/default/src/components/cart/FreeShipping.astro +7 -0
- package/templates/default/src/components/checkout/CheckoutMain.astro +29 -0
- package/templates/default/src/components/checkout/OrderForm.astro +280 -0
- package/templates/default/src/components/checkout/ThankYouMain.astro +68 -0
- package/templates/default/src/components/landing/LandingImages.astro +51 -0
- package/templates/default/src/components/landing/LandingOrder.astro +46 -0
- package/templates/default/src/components/landing/LandingProduct.astro +41 -0
- package/templates/default/src/components/listing/ListingMain.astro +93 -0
- package/templates/default/src/components/listing/PageMain.astro +52 -0
- package/templates/default/src/components/listing/Pagination.astro +31 -0
- package/templates/default/src/components/listing/SortControl.astro +35 -0
- package/templates/default/src/components/product/BuyBox.astro +96 -0
- package/templates/default/src/components/product/Description.astro +24 -0
- package/templates/default/src/components/product/Gallery.astro +66 -0
- package/templates/default/src/components/product/MobileBuyBar.astro +29 -0
- package/templates/default/src/components/product/OfferChoice.astro +66 -0
- package/templates/default/src/components/product/ProductMain.astro +40 -0
- package/templates/default/src/components/product/ProductReviews.astro +72 -0
- package/templates/default/src/components/product/RelatedProducts.astro +30 -0
- package/templates/default/src/components/product/blocks/BenefitsBlock.astro +13 -0
- package/templates/default/src/components/product/blocks/CollapsibleBlock.astro +20 -0
- package/templates/default/src/components/product/blocks/DescriptionBlock.astro +19 -0
- package/templates/default/src/components/product/blocks/DetailsBlock.astro +33 -0
- package/templates/default/src/components/product/blocks/GalleryBlock.astro +12 -0
- package/templates/default/src/components/product/blocks/OrderBlock.astro +30 -0
- package/templates/default/src/components/product/blocks/PriceBlock.astro +23 -0
- package/templates/default/src/components/product/blocks/RatingBlock.astro +16 -0
- package/templates/default/src/components/product/blocks/StockBlock.astro +22 -0
- package/templates/default/src/components/product/blocks/TextBlock.astro +11 -0
- package/templates/default/src/components/product/blocks/TitleBlock.astro +20 -0
- package/templates/default/src/components/reviews/ReviewCard.astro +46 -0
- package/templates/default/src/components/reviews/ReviewForm.astro +113 -0
- package/templates/default/src/components/reviews/VoiceNote.astro +60 -0
- package/templates/default/src/components/sections/CollectionCards.astro +65 -0
- package/templates/default/src/components/sections/Countdown.astro +57 -0
- package/templates/default/src/components/sections/Faq.astro +44 -0
- package/templates/default/src/components/sections/FeaturedProduct.astro +71 -0
- package/templates/default/src/components/sections/Hero.astro +99 -0
- package/templates/default/src/components/sections/ImageBanner.astro +46 -0
- package/templates/default/src/components/sections/ProductGrid.astro +47 -0
- package/templates/default/src/components/sections/RichText.astro +35 -0
- package/templates/default/src/components/sections/Steps.astro +46 -0
- package/templates/default/src/components/sections/Testimonials.astro +57 -0
- package/templates/default/src/components/shell/Footer.astro +80 -0
- package/templates/default/src/components/shell/Header.astro +89 -0
- package/templates/default/src/components/shell/LanguageMenu.astro +33 -0
- package/templates/default/src/components/shell/MobileMenu.astro +65 -0
- package/templates/default/src/components/shell/SearchDialog.astro +19 -0
- package/templates/default/src/components/shell/TopBar.astro +54 -0
- package/templates/default/src/components/shell/WhatsAppWidget.astro +111 -0
- package/templates/default/src/components/store/ContactMain.astro +79 -0
- package/templates/default/src/components/store/SearchMain.astro +56 -0
- package/templates/default/src/components/store/TrackOrderMain.astro +161 -0
- package/templates/default/src/components/surface/Area.astro +20 -0
- package/templates/default/src/components/surface/PreviewBridge.astro +24 -0
- package/templates/default/src/components/surface/Sections.astro +35 -0
- package/templates/default/src/components/ui/Breadcrumbs.astro +36 -0
- package/templates/default/src/components/ui/Button.astro +45 -0
- package/templates/default/src/components/ui/EditorPlaceholder.astro +24 -0
- package/templates/default/src/components/ui/Icon.astro +93 -0
- package/templates/default/src/components/ui/Logo.astro +36 -0
- package/templates/default/src/components/ui/Photo.astro +46 -0
- package/templates/default/src/components/ui/Price.astro +24 -0
- package/templates/default/src/components/ui/ProductCard.astro +41 -0
- package/templates/default/src/components/ui/Rating.astro +22 -0
- package/templates/default/src/components/ui/Section.astro +34 -0
- package/templates/default/src/components/ui/SectionHeading.astro +19 -0
- package/templates/default/src/env.d.ts +23 -0
- package/templates/default/src/layouts/StoreLayout.astro +145 -0
- package/templates/default/src/lib/browser-copy.ts +37 -0
- package/templates/default/src/lib/context.ts +89 -0
- package/templates/default/src/lib/coupon-notice.ts +47 -0
- package/templates/default/src/lib/i18n.ts +32 -0
- package/templates/default/src/lib/images.ts +38 -0
- package/templates/default/src/lib/listing-query.ts +41 -0
- package/templates/default/src/lib/money.ts +16 -0
- package/templates/default/src/lib/motion.ts +16 -0
- package/templates/default/src/lib/nav.ts +26 -0
- package/templates/default/src/lib/offer-tiles.ts +105 -0
- package/templates/default/src/lib/order-outcome.ts +66 -0
- package/templates/default/src/lib/otp-message.ts +21 -0
- package/templates/default/src/lib/products.ts +38 -0
- package/templates/default/src/lib/review-refusals.ts +31 -0
- package/templates/default/src/lib/store.ts +31 -0
- package/templates/default/src/lib/whatsapp.ts +29 -0
- package/templates/default/src/middleware.ts +23 -0
- package/templates/default/src/pages/404.astro +22 -0
- package/templates/default/src/pages/api/abandoned/convert.ts +4 -0
- package/templates/default/src/pages/api/abandoned/upsert.ts +4 -0
- package/templates/default/src/pages/api/cart/validate.ts +4 -0
- package/templates/default/src/pages/api/communes/[wilayaId].ts +4 -0
- package/templates/default/src/pages/api/otp/send.ts +4 -0
- package/templates/default/src/pages/api/otp/verify.ts +4 -0
- package/templates/default/src/pages/api/reviews/[productId].ts +3 -0
- package/templates/default/src/pages/api/reviews/eligibility.ts +3 -0
- package/templates/default/src/pages/api/reviews/submit.ts +3 -0
- package/templates/default/src/pages/api/reviews/upload.ts +3 -0
- package/templates/default/src/pages/category/[slug].astro +20 -0
- package/templates/default/src/pages/checkout.astro +25 -0
- package/templates/default/src/pages/collections/[handle].astro +20 -0
- package/templates/default/src/pages/contact.astro +17 -0
- package/templates/default/src/pages/index.astro +9 -0
- package/templates/default/src/pages/lp/[slug].astro +47 -0
- package/templates/default/src/pages/pages/[slug].astro +16 -0
- package/templates/default/src/pages/products/[handle].astro +37 -0
- package/templates/default/src/pages/products/index.astro +15 -0
- package/templates/default/src/pages/robots.txt.ts +9 -0
- package/templates/default/src/pages/search.astro +19 -0
- package/templates/default/src/pages/sitemap.xml.ts +12 -0
- package/templates/default/src/pages/thank-you.astro +33 -0
- package/templates/default/src/pages/track-order.astro +17 -0
- package/templates/default/src/pages/wocart-preview.astro +43 -0
- package/templates/default/src/pages/wocart-revalidate.ts +10 -0
- package/templates/default/src/pages/wocart-styles.css.ts +5 -0
- package/templates/default/src/pages/wocart-theme.json.ts +5 -0
- package/templates/default/src/scripts/cart.ts +371 -0
- package/templates/default/src/scripts/checkout/coupon.ts +96 -0
- package/templates/default/src/scripts/checkout/delivery.ts +86 -0
- package/templates/default/src/scripts/checkout/form.ts +54 -0
- package/templates/default/src/scripts/checkout/otp.ts +106 -0
- package/templates/default/src/scripts/checkout/picker.ts +169 -0
- package/templates/default/src/scripts/checkout/quote.ts +169 -0
- package/templates/default/src/scripts/checkout/submit.ts +113 -0
- package/templates/default/src/scripts/checkout/tracking.ts +74 -0
- package/templates/default/src/scripts/countdown.ts +29 -0
- package/templates/default/src/scripts/events.ts +4 -0
- package/templates/default/src/scripts/hero.ts +49 -0
- package/templates/default/src/scripts/listing.ts +13 -0
- package/templates/default/src/scripts/order-form.ts +100 -0
- package/templates/default/src/scripts/product.ts +306 -0
- package/templates/default/src/scripts/public-config.ts +79 -0
- package/templates/default/src/scripts/reviews.ts +358 -0
- package/templates/default/src/scripts/site.ts +131 -0
- package/templates/default/src/scripts/thank-you.ts +11 -0
- package/templates/default/src/scripts/voice-note.ts +94 -0
- package/templates/default/src/styles/base.css +1030 -0
- package/templates/default/src/styles/checkout.css +1111 -0
- package/templates/default/src/styles/global.css +12 -0
- package/templates/default/src/styles/product.css +871 -0
- package/templates/default/src/styles/reviews.css +533 -0
- package/templates/default/src/styles/sections.css +931 -0
- package/templates/default/src/styles/shell.css +970 -0
- package/templates/default/src/styles/tokens.css +583 -0
- package/templates/default/src/theme/api-routes.ts +10 -0
- package/templates/default/src/theme/content/catalog.ts +117 -0
- package/templates/default/src/theme/content/checkout.ts +168 -0
- package/templates/default/src/theme/content/editor.ts +21 -0
- package/templates/default/src/theme/content/index.ts +45 -0
- package/templates/default/src/theme/content/reviews.ts +76 -0
- package/templates/default/src/theme/content/shell.ts +59 -0
- package/templates/default/src/theme/content/types.ts +12 -0
- package/templates/default/src/theme/documents/catalog.json +11 -0
- package/templates/default/src/theme/documents/category.json +11 -0
- package/templates/default/src/theme/documents/checkout.json +11 -0
- package/templates/default/src/theme/documents/collection.json +11 -0
- package/templates/default/src/theme/documents/contact.json +11 -0
- package/templates/default/src/theme/documents/footer.area.json +11 -0
- package/templates/default/src/theme/documents/header.area.json +16 -0
- package/templates/default/src/theme/documents/home.json +313 -0
- package/templates/default/src/theme/documents/landing.json +8 -0
- package/templates/default/src/theme/documents/page.json +11 -0
- package/templates/default/src/theme/documents/product.json +125 -0
- package/templates/default/src/theme/documents/search.json +11 -0
- package/templates/default/src/theme/documents/thank-you.json +11 -0
- package/templates/default/src/theme/documents/track-order.json +11 -0
- package/templates/default/src/theme/fields.ts +61 -0
- package/templates/default/src/theme/key.ts +11 -0
- package/templates/default/src/theme/labels.ts +231 -0
- package/templates/default/src/theme/locales.ts +11 -0
- package/templates/default/src/theme/palette.ts +14 -0
- package/templates/default/src/theme/sections/collection-cards.ts +65 -0
- package/templates/default/src/theme/sections/faq.ts +74 -0
- package/templates/default/src/theme/sections/featured-product.ts +42 -0
- package/templates/default/src/theme/sections/hero.ts +47 -0
- package/templates/default/src/theme/sections/image-banner.ts +25 -0
- package/templates/default/src/theme/sections/index.ts +40 -0
- package/templates/default/src/theme/sections/landing.ts +150 -0
- package/templates/default/src/theme/sections/listing.ts +84 -0
- package/templates/default/src/theme/sections/product-grid.ts +42 -0
- package/templates/default/src/theme/sections/product.ts +297 -0
- package/templates/default/src/theme/sections/rich-text.ts +39 -0
- package/templates/default/src/theme/sections/shared.ts +54 -0
- package/templates/default/src/theme/sections/shell.ts +85 -0
- package/templates/default/src/theme/sections/store-pages.ts +101 -0
- package/templates/default/src/theme/sections/testimonials.ts +61 -0
- package/templates/default/src/theme/sections/thank-you.ts +35 -0
- package/templates/default/src/theme/settings.ts +124 -0
- package/templates/default/src/theme/theme.ts +65 -0
- package/templates/default/tests/fixtures/canvas-tote.json +62 -0
- package/templates/default/tests/fixtures/linen-shirt.json +128 -0
- package/templates/default/tests/unit/checkout.test.ts +241 -0
- package/templates/default/tests/unit/contract.test.ts +169 -0
- package/templates/default/tests/unit/contrast.test.ts +68 -0
- package/templates/default/tests/unit/copy.test.ts +101 -0
- package/templates/default/tests/unit/design-values.test.ts +95 -0
- package/templates/default/tests/unit/editability.test.ts +180 -0
- package/templates/default/tests/unit/fixtures.ts +91 -0
- package/templates/default/tests/unit/footer.test.ts +54 -0
- package/templates/default/tests/unit/guards.test.ts +340 -0
- package/templates/default/tests/unit/images.test.ts +26 -0
- package/templates/default/tests/unit/landing.test.ts +151 -0
- package/templates/default/tests/unit/languages.test.ts +42 -0
- package/templates/default/tests/unit/middleware.test.ts +53 -0
- package/templates/default/tests/unit/offer-tiles.test.ts +75 -0
- package/templates/default/tests/unit/render.ts +38 -0
- package/templates/default/tests/unit/reviews.test.ts +25 -0
- package/templates/default/tests/unit/rules.test.ts +59 -0
- package/templates/default/tests/unit/source.ts +75 -0
- package/templates/default/tests/unit/store-pages.test.ts +147 -0
- package/templates/default/tests/unit/studio.test.ts +202 -0
- package/templates/default/tests/unit/testimonials.test.ts +52 -0
- package/templates/default/tests/unit/thank-you.test.ts +52 -0
- package/templates/default/tests/unit/tracking.test.ts +29 -0
- package/templates/default/tests/unit/voice-note.test.ts +42 -0
- package/templates/default/tsconfig.json +13 -0
- package/templates/default/vitest.config.ts +15 -0
- package/templates/default/wrangler.jsonc +17 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
name: string;
|
|
4
|
+
size?: number;
|
|
5
|
+
class?: string;
|
|
6
|
+
strokeWidth?: number;
|
|
7
|
+
filled?: boolean;
|
|
8
|
+
label?: string;
|
|
9
|
+
style?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { name, size = 24, class: className, strokeWidth = 1.8, filled = false, label, style } = Astro.props;
|
|
13
|
+
|
|
14
|
+
const paths: Record<string, string> = {
|
|
15
|
+
menu: "M4 7h16M4 12h16M4 17h16",
|
|
16
|
+
close: "M6 6l12 12M18 6L6 18",
|
|
17
|
+
search: "M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm10 2-4.35-4.35",
|
|
18
|
+
bag: "M6 8h12l1 12H5L6 8Zm3 0V6a3 3 0 0 1 6 0v2",
|
|
19
|
+
edit: "M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z",
|
|
20
|
+
"chevron-down": "m6 9 6 6 6-6",
|
|
21
|
+
"chevron-up": "m18 15-6-6-6 6",
|
|
22
|
+
"chevron-left": "m15 18-6-6 6-6",
|
|
23
|
+
"chevron-right": "m9 18 6-6-6-6",
|
|
24
|
+
"arrow-right": "M4 12h16m-6-6 6 6-6 6",
|
|
25
|
+
"arrow-left": "M20 12H4m6 6-6-6 6-6",
|
|
26
|
+
"arrow-up": "M12 20V4m-6 6 6-6 6 6",
|
|
27
|
+
check: "m20 6-11 11-5-5",
|
|
28
|
+
"check-circle": "M22 11.1V12a10 10 0 1 1-5.9-9.1M22 4 12 14l-3-3",
|
|
29
|
+
plus: "M12 5v14M5 12h14",
|
|
30
|
+
minus: "M5 12h14",
|
|
31
|
+
trash: "M3 6h18M8 6V4h8v2m-9 0 1 14h8l1-14M10 10v7M14 10v7",
|
|
32
|
+
tag: "M20.6 13.4 12 22l-9-9V4h9l8.6 8.6a1.4 1.4 0 0 1 0 2ZM7.5 7.5h.01",
|
|
33
|
+
mail: "M4 4h16v16H4zM4 6l8 6 8-6",
|
|
34
|
+
phone: "M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2 4.2 2 2 0 0 1 4 2h3a2 2 0 0 1 2 1.7c.1.9.3 1.8.6 2.6a2 2 0 0 1-.4 2.1L8 9.6a16 16 0 0 0 6 6l1.2-1.2a2 2 0 0 1 2.1-.4c.8.3 1.7.5 2.6.6a2 2 0 0 1 1.7 2Z",
|
|
35
|
+
"map-pin": "M20 10c0 6-8 12-8 12S4 16 4 10a8 8 0 1 1 16 0Z M12 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z",
|
|
36
|
+
truck: "M3 6h11v11H3zM14 9h4l3 3v5h-7zM7.5 20.5a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6ZM18 20.5a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6Z",
|
|
37
|
+
cash: "M3 6h18v12H3zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM6 9h.01M18 15h.01",
|
|
38
|
+
refresh: "M3 12a9 9 0 0 1 15.5-6.2L21 8M21 3v5h-5M21 12a9 9 0 0 1-15.5 6.2L3 16M3 21v-5h5",
|
|
39
|
+
shield: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z",
|
|
40
|
+
lock: "M5 11h14v10H5zM8 11V7a4 4 0 0 1 8 0v4",
|
|
41
|
+
star: "m12 2.6 2.9 5.9 6.5.9-4.7 4.6 1.1 6.5-5.8-3-5.8 3 1.1-6.5L2.6 9.4l6.5-.9L12 2.6Z",
|
|
42
|
+
heart: "M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1.1-1.1a5.5 5.5 0 0 0-7.8 7.8l1.1 1.1L12 21l7.8-7.5 1.1-1.1a5.5 5.5 0 0 0-.1-7.8Z",
|
|
43
|
+
instagram:
|
|
44
|
+
"M7 2h10a5 5 0 0 1 5 5v10a5 5 0 0 1-5 5H7a5 5 0 0 1-5-5V7a5 5 0 0 1 5-5Zm5 5.4a4.6 4.6 0 1 0 0 9.2 4.6 4.6 0 0 0 0-9.2ZM17.5 6.5h.01",
|
|
45
|
+
facebook: "M14 22v-9h3l.5-3.5H14V7.3c0-1 .3-1.8 1.8-1.8h1.9V2.4c-.3 0-1.5-.1-2.8-.1-2.8 0-4.7 1.7-4.7 4.8v2.4H7V13h3.2v9H14Z",
|
|
46
|
+
tiktok:
|
|
47
|
+
"M14 3v9.6a4.4 4.4 0 1 1-3.5-4.3V11a1.8 1.8 0 1 0 1.4 1.7V3h2.1a5 5 0 0 0 5 4.5V10A7 7 0 0 1 14 8.2",
|
|
48
|
+
youtube: "M21.6 7.2a2.7 2.7 0 0 0-1.9-1.9C18 4.8 12 4.8 12 4.8s-6 0-7.7.5A2.7 2.7 0 0 0 2.4 7.2 28 28 0 0 0 2 12a28 28 0 0 0 .4 4.8 2.7 2.7 0 0 0 1.9 1.9c1.7.5 7.7.5 7.7.5s6 0 7.7-.5a2.7 2.7 0 0 0 1.9-1.9A28 28 0 0 0 22 12a28 28 0 0 0-.4-4.8ZM10 15.2V8.8l5.2 3.2-5.2 3.2Z",
|
|
49
|
+
whatsapp:
|
|
50
|
+
"M12 2a10 10 0 0 0-8.5 15.2L2 22l4.9-1.4A10 10 0 1 0 12 2Zm0 2a8 8 0 0 1 0 16 8 8 0 0 1-4.2-1.2l-.5-.3-2.6.7.7-2.5-.3-.5A8 8 0 0 1 12 4Zm-3.2 4.1c-.2 0-.5.1-.7.4-.2.3-.8.8-.8 2s.8 2.3.9 2.5c.1.2 1.6 2.6 4 3.6 2 .8 2.4.6 2.8.6.4 0 1.4-.6 1.6-1.1.2-.6.2-1 .1-1.1-.1-.1-.2-.2-.5-.4l-1.6-.8c-.2-.1-.4-.1-.6.1l-.7.9c-.1.2-.3.2-.5.1a6.6 6.6 0 0 1-3.2-2.8c-.1-.2 0-.4.1-.5l.5-.6c.1-.2.1-.3 0-.5l-.7-1.7c-.2-.5-.4-.4-.6-.4h-.1Z",
|
|
51
|
+
sparkles: "m12 3 1.6 4.4L18 9l-4.4 1.6L12 15l-1.6-4.4L6 9l4.4-1.6L12 3ZM19 14l.9 2.1L22 17l-2.1.9L19 20l-.9-2.1L16 17l2.1-.9L19 14ZM5 14l.7 1.6L7.3 16l-1.6.7L5 18.3l-.7-1.6L2.7 16l1.6-.7L5 14Z",
|
|
52
|
+
alert: "M12 9v4m0 4h.01M10.3 3.9 2.4 17.5A2 2 0 0 0 4.1 20.5h15.8a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",
|
|
53
|
+
info: "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20Zm0-14h.01M11 12h1v4h1",
|
|
54
|
+
clock: "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20Zm0-16v6l4 2",
|
|
55
|
+
package: "m12 2 9 5v10l-9 5-9-5V7l9-5Zm0 0v20M3 7l9 5 9-5",
|
|
56
|
+
home: "m3 10 9-8 9 8v10a1 1 0 0 1-1 1h-5v-7H9v7H4a1 1 0 0 1-1-1V10Z",
|
|
57
|
+
filter: "M3 5h18l-7 8v6l-4 2v-8L3 5Z",
|
|
58
|
+
grid: "M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z",
|
|
59
|
+
globe:
|
|
60
|
+
"M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20ZM2 12h20M12 2a15 15 0 0 1 4 10 15 15 0 0 1-4 10 15 15 0 0 1-4-10 15 15 0 0 1 4-10Z",
|
|
61
|
+
quote: "M3 21c3 0 7-1 7-8V5c0-1.2-1-2-2-2H4c-1 0-2 .8-2 2v6c0 1.2 1 2 2 2h3c0 3-1 4-4 5v3ZM14 21c3 0 7-1 7-8V5c0-1.2-1-2-2-2h-4c-1 0-2 .8-2 2v6c0 1.2 1 2 2 2h3c0 3-1 4-4 5v3Z",
|
|
62
|
+
user: "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2M12 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8Z",
|
|
63
|
+
image: "M3 3h18v18H3zM8.5 8.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3ZM21 15l-5-5L5 21",
|
|
64
|
+
eye: "M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12Zm10 3a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",
|
|
65
|
+
gift: "M20 12v9H4v-9M2 7h20v5H2zM12 22V7m0 0H7.5a2.5 2.5 0 1 1 0-5C11 2 12 7 12 7Zm0 0h4.5a2.5 2.5 0 1 0 0-5C13 2 12 7 12 7Z",
|
|
66
|
+
play: "M7 4.5v15a1 1 0 0 0 1.5.86l12.5-7.5a1 1 0 0 0 0-1.72L8.5 3.64A1 1 0 0 0 7 4.5Z",
|
|
67
|
+
pause: "M7 4h3.5v16H7zM13.5 4H17v16h-3.5z",
|
|
68
|
+
mic: "M12 15a3.5 3.5 0 0 0 3.5-3.5V5.5a3.5 3.5 0 1 0-7 0v6A3.5 3.5 0 0 0 12 15Zm-7-4a7 7 0 0 0 14 0M12 18v3",
|
|
69
|
+
paperclip: "m21 11-8.6 8.6a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.7 3.7 0 0 1 5.2 5.2l-8.6 8.6a1.8 1.8 0 0 1-2.6-2.6l7.9-7.9",
|
|
70
|
+
camera: "M4 7h3l2-3h6l2 3h3a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1Zm8 10a4 4 0 1 0 0-8 4 4 0 0 0 0 8Z",
|
|
71
|
+
percent: "M19 5 5 19M6.5 9a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM17.5 20a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const d = paths[name] ?? paths.info;
|
|
75
|
+
---
|
|
76
|
+
<svg
|
|
77
|
+
class={className}
|
|
78
|
+
width={size}
|
|
79
|
+
height={size}
|
|
80
|
+
viewBox="0 0 24 24"
|
|
81
|
+
fill={filled || name === "star" || name === "play" || name === "pause" ? "currentColor" : "none"}
|
|
82
|
+
stroke={filled || name === "star" || name === "play" || name === "pause" ? "none" : "currentColor"}
|
|
83
|
+
stroke-width={strokeWidth}
|
|
84
|
+
stroke-linecap="round"
|
|
85
|
+
stroke-linejoin="round"
|
|
86
|
+
aria-hidden={label ? undefined : "true"}
|
|
87
|
+
role={label ? "img" : undefined}
|
|
88
|
+
aria-label={label}
|
|
89
|
+
focusable="false"
|
|
90
|
+
style={style}
|
|
91
|
+
>
|
|
92
|
+
<path d={d} />
|
|
93
|
+
</svg>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* The store's logo, as uploaded in its settings, at the size the place it
|
|
4
|
+
* sits in asks for and in its own proportions; the store's name in its place
|
|
5
|
+
* when it has none.
|
|
6
|
+
*/
|
|
7
|
+
import { imageUrl } from "@/lib/images";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
/** The class the picture or the name wears. */
|
|
11
|
+
imageClass: string;
|
|
12
|
+
textClass: string;
|
|
13
|
+
/** The height it is shown at, in CSS pixels; the file is fetched sharp for it. */
|
|
14
|
+
height: number;
|
|
15
|
+
loading?: "eager" | "lazy";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { imageClass, textClass, height, loading = "eager" } = Astro.props;
|
|
19
|
+
const { config } = Astro.locals.store;
|
|
20
|
+
const logo = config.logo;
|
|
21
|
+
const ratio = logo?.width && logo.height ? logo.width / logo.height : null;
|
|
22
|
+
const width = ratio ? Math.round(height * ratio) : undefined;
|
|
23
|
+
---
|
|
24
|
+
{logo ? (
|
|
25
|
+
<img
|
|
26
|
+
class={imageClass}
|
|
27
|
+
src={imageUrl(logo.url, config.media, Math.min(width ?? height * 4, 640) * 2) ?? logo.url}
|
|
28
|
+
alt={config.name}
|
|
29
|
+
width={width}
|
|
30
|
+
height={ratio ? height : undefined}
|
|
31
|
+
loading={loading}
|
|
32
|
+
decoding="async"
|
|
33
|
+
/>
|
|
34
|
+
) : (
|
|
35
|
+
<span class={textClass}>{config.name}</span>
|
|
36
|
+
)}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* One photo, sized for where it sits: `sizes` says how wide it shows, and the
|
|
4
|
+
* browser picks the smallest file that fills it. The first photo on a page is
|
|
5
|
+
* `priority`; every other one waits until it is near the screen.
|
|
6
|
+
*/
|
|
7
|
+
import { imageSrcset, imageUrl, type Picture } from "@/lib/images";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
src: string | null | undefined;
|
|
11
|
+
alt?: string | undefined;
|
|
12
|
+
/** The widest file needed, in CSS pixels at 2× density. */
|
|
13
|
+
width: number;
|
|
14
|
+
/** Height ÷ width to crop to; absent, the photo keeps its shape. */
|
|
15
|
+
ratio?: number;
|
|
16
|
+
sizes: string;
|
|
17
|
+
widths?: readonly number[];
|
|
18
|
+
priority?: boolean;
|
|
19
|
+
class?: string;
|
|
20
|
+
/** A merchant-picked image's focal point. */
|
|
21
|
+
position?: Picture["position"];
|
|
22
|
+
attrs?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const { src, alt = "", width, ratio, sizes, widths = [360, 540, 720, 960, 1280, 1600, 1920], priority = false, class: className, position, attrs = {} } = Astro.props;
|
|
26
|
+
const steps = widths.filter((step) => step <= width);
|
|
27
|
+
const { media } = Astro.locals.store.config;
|
|
28
|
+
const url = imageUrl(src, media, width, ratio);
|
|
29
|
+
const srcset = imageSrcset(src, media, steps.length > 0 ? steps : [width], ratio);
|
|
30
|
+
---
|
|
31
|
+
{url && (
|
|
32
|
+
<img
|
|
33
|
+
class={className}
|
|
34
|
+
src={url}
|
|
35
|
+
srcset={srcset}
|
|
36
|
+
sizes={srcset ? sizes : undefined}
|
|
37
|
+
alt={alt}
|
|
38
|
+
width={width}
|
|
39
|
+
height={ratio ? Math.round(width * ratio) : undefined}
|
|
40
|
+
loading={priority ? "eager" : "lazy"}
|
|
41
|
+
fetchpriority={priority ? "high" : undefined}
|
|
42
|
+
decoding={priority ? "sync" : "async"}
|
|
43
|
+
style={position ? `object-position:${position}` : undefined}
|
|
44
|
+
{...attrs}
|
|
45
|
+
/>
|
|
46
|
+
)}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { money } from "@/lib/money";
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
price: number;
|
|
6
|
+
compareAt?: number | null;
|
|
7
|
+
fromLabel?: string;
|
|
8
|
+
size?: "md" | "lg";
|
|
9
|
+
/** Marks the figures for the product script, which keeps them on the chosen variant. */
|
|
10
|
+
live?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { price, compareAt = null, fromLabel = "", size = "md", live = false } = Astro.props;
|
|
14
|
+
const { config, locale } = Astro.locals.store;
|
|
15
|
+
const symbol = config.currencySymbol || config.currency;
|
|
16
|
+
const hasCompare = typeof compareAt === "number" && compareAt > price;
|
|
17
|
+
---
|
|
18
|
+
<span class:list={["price", size === "lg" && "price--lg"]}>
|
|
19
|
+
{fromLabel && <span class="price__from">{fromLabel}</span>}
|
|
20
|
+
<span class="price__current" data-product-price={live ? "" : undefined}>{money(price, symbol, locale)}</span>
|
|
21
|
+
{(hasCompare || live) && (
|
|
22
|
+
<s class="price__compare" data-product-compare={live ? "" : undefined} hidden={!hasCompare}>{hasCompare ? money(compareAt, symbol, locale) : ""}</s>
|
|
23
|
+
)}
|
|
24
|
+
</span>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { ProductList } from "@abcart/storefront";
|
|
3
|
+
import { getProductListView, localizeHref, productImageSource, storefrontPath } from "@abcart/storefront";
|
|
4
|
+
import Photo from "./Photo.astro";
|
|
5
|
+
import Price from "./Price.astro";
|
|
6
|
+
import Icon from "./Icon.astro";
|
|
7
|
+
import AddToCartButton from "@/components/cart/AddToCartButton.astro";
|
|
8
|
+
import { createTranslator } from "@/lib/i18n";
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
product: ProductList;
|
|
12
|
+
/** The card's photo is the page's first: it loads at once. */
|
|
13
|
+
priority?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { product, priority = false } = Astro.props;
|
|
17
|
+
const { locale, routing, content, settings } = Astro.locals.store;
|
|
18
|
+
const portrait = settings.cardRatio === "portrait";
|
|
19
|
+
const t = createTranslator(content, locale);
|
|
20
|
+
const view = getProductListView(product);
|
|
21
|
+
const href = localizeHref(storefrontPath("product", { handle: product.handle }), locale, routing);
|
|
22
|
+
const image = productImageSource(product);
|
|
23
|
+
const discount = view.hasDiscount ? view.discountPct : null;
|
|
24
|
+
---
|
|
25
|
+
<article class:list={["product-card", portrait && "product-card--portrait"]}>
|
|
26
|
+
<a class="product-card__media" href={href} tabindex="-1" aria-hidden="true">
|
|
27
|
+
{image ? (
|
|
28
|
+
<Photo src={image} alt="" width={640} ratio={portrait ? 1.25 : 1} sizes="(min-width: 1100px) 25vw, (min-width: 700px) 33vw, 50vw" priority={priority} />
|
|
29
|
+
) : (
|
|
30
|
+
<span class="product-card__placeholder"><Icon name="image" size={30} /></span>
|
|
31
|
+
)}
|
|
32
|
+
<span class="product-card__badges">
|
|
33
|
+
{view.isOutOfStock ? <span class="badge badge--out">{t("product.soldOut")}</span> : discount ? <span class="badge badge--sale">{t("product.save", { percent: discount })}</span> : null}
|
|
34
|
+
</span>
|
|
35
|
+
</a>
|
|
36
|
+
<div class="product-card__body">
|
|
37
|
+
<h3 class="product-card__title"><a href={href}>{product.name}</a></h3>
|
|
38
|
+
<Price price={view.basePrice} compareAt={view.comparePrice} fromLabel={product.hasVariants ? t("product.from") : ""} />
|
|
39
|
+
{settings.cardButton && <AddToCartButton product={product} href={href} />}
|
|
40
|
+
</div>
|
|
41
|
+
</article>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Icon from "./Icon.astro";
|
|
3
|
+
import { createTranslator } from "@/lib/i18n";
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
rating: number;
|
|
7
|
+
count?: number;
|
|
8
|
+
size?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { rating, count = 0, size = 16 } = Astro.props;
|
|
12
|
+
const t = createTranslator(Astro.locals.store.content, Astro.locals.store.locale);
|
|
13
|
+
const rounded = Math.round(rating);
|
|
14
|
+
const spoken = count > 0 ? `${t("a11y.rating", { rating: rating.toFixed(1) })} · ${t("reviews.count", { count })}` : t("a11y.rating", { rating: rating.toFixed(1) });
|
|
15
|
+
---
|
|
16
|
+
<span class="rating-line" role="img" aria-label={spoken}>
|
|
17
|
+
<span class="stars" aria-hidden="true">
|
|
18
|
+
{[1, 2, 3, 4, 5].map((n) => <Icon name="star" size={size} filled={n <= rounded} class={n <= rounded ? undefined : "star-empty"} />)}
|
|
19
|
+
</span>
|
|
20
|
+
<strong aria-hidden="true">{rating.toFixed(1)}</strong>
|
|
21
|
+
{count > 0 && <span aria-hidden="true">({count})</span>}
|
|
22
|
+
</span>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* A section's frame: the colour scheme it wears — its band runs the page's
|
|
4
|
+
* full width — and its style: the room above and below on the band, how wide
|
|
5
|
+
* the content runs inside it. Every section renders through this frame, so a
|
|
6
|
+
* merchant's colours and spacing mean the same in each one.
|
|
7
|
+
*/
|
|
8
|
+
import { schemeClass, styleClasses, type StyleValue } from "@abcart/theme";
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
scheme?: string | undefined;
|
|
12
|
+
style?: StyleValue | undefined;
|
|
13
|
+
class?: string;
|
|
14
|
+
/** The inner column's class; `frame` is the page's gutter and width. */
|
|
15
|
+
inner?: string;
|
|
16
|
+
as?: "section" | "div" | "aside";
|
|
17
|
+
id?: string;
|
|
18
|
+
label?: string;
|
|
19
|
+
labelledby?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { scheme, style, class: className, inner = "frame", as: Tag = "section", id, label, labelledby } = Astro.props;
|
|
23
|
+
const band = style?.spacing ? styleClasses({ spacing: style.spacing }) : "";
|
|
24
|
+
const width = style?.size ? styleClasses({ size: style.size }) : "";
|
|
25
|
+
const colors = schemeClass(scheme);
|
|
26
|
+
---
|
|
27
|
+
<Tag
|
|
28
|
+
id={id}
|
|
29
|
+
class:list={["band", colors, band, className]}
|
|
30
|
+
aria-label={label}
|
|
31
|
+
aria-labelledby={labelledby}
|
|
32
|
+
>
|
|
33
|
+
<div class:list={[inner, width]}><slot /></div>
|
|
34
|
+
</Tag>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
title?: string | undefined;
|
|
4
|
+
accent?: string | undefined;
|
|
5
|
+
subtitle?: string | undefined;
|
|
6
|
+
align?: "center" | "start" | undefined;
|
|
7
|
+
as?: "h1" | "h2" | "h3";
|
|
8
|
+
id?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { title = "", accent = "", subtitle = "", align = "center", as = "h2", id } = Astro.props;
|
|
12
|
+
const Heading = as;
|
|
13
|
+
---
|
|
14
|
+
{(title || accent || subtitle) && (
|
|
15
|
+
<div class:list={["section-head", align === "start" && "section-head--start"]}>
|
|
16
|
+
{(title || accent) && <Heading id={id}>{title}{accent ? <> <span class="accent">{accent}</span></> : null}</Heading>}
|
|
17
|
+
{subtitle && <p>{subtitle}</p>}
|
|
18
|
+
</div>
|
|
19
|
+
)}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="astro/client" />
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
namespace App {
|
|
5
|
+
interface Locals {
|
|
6
|
+
/** Everything a page knows about its store, built once per request by the middleware. */
|
|
7
|
+
store: import("./lib/context").StoreContext;
|
|
8
|
+
/**
|
|
9
|
+
* The placeOrder result for the page's order form. The product template
|
|
10
|
+
* renders through InstanceView, so the page passes it on the request.
|
|
11
|
+
*/
|
|
12
|
+
placeOrderOutcome?: import("./lib/order-outcome").PlaceOrderOutcome;
|
|
13
|
+
/** Set on the editor's preview route only, from a verified token. */
|
|
14
|
+
preview?: {
|
|
15
|
+
claims: import("@abcart/storefront/server").PreviewClaims;
|
|
16
|
+
draft: import("@abcart/storefront/server").PreviewDraft;
|
|
17
|
+
token: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Every page's frame: the head (title, language versions, sharing, the
|
|
4
|
+
* store's colour schemes, its pixel), the header and footer areas, the
|
|
5
|
+
* basket drawer, the merchant's WhatsApp widget, and the copy the browser
|
|
6
|
+
* scripts read.
|
|
7
|
+
*/
|
|
8
|
+
import "@/styles/global.css";
|
|
9
|
+
import { alternateLinks, canonicalUrl, localizeHref, showsWidgetOn, storefrontPath } from "@abcart/storefront";
|
|
10
|
+
import { trackingHead } from "@abcart/storefront/astro";
|
|
11
|
+
import { schemeClass } from "@abcart/theme";
|
|
12
|
+
import ThemeStyles from "@abcart/theme/astro/ThemeStyles.astro";
|
|
13
|
+
import { createTranslator, localeTag } from "@/lib/i18n";
|
|
14
|
+
import { browserCopy } from "@/lib/browser-copy";
|
|
15
|
+
import { storeWhatsApp } from "@/lib/whatsapp";
|
|
16
|
+
import { PAGE_SCHEME } from "@/theme/fields";
|
|
17
|
+
import Area from "@/components/surface/Area.astro";
|
|
18
|
+
import WhatsAppWidget from "@/components/shell/WhatsAppWidget.astro";
|
|
19
|
+
import CartDrawer from "@/components/cart/CartDrawer.astro";
|
|
20
|
+
import Icon from "@/components/ui/Icon.astro";
|
|
21
|
+
|
|
22
|
+
interface Props {
|
|
23
|
+
title?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
/** The page's own picture for sharing; the store's otherwise. */
|
|
26
|
+
ogImage?: string | null;
|
|
27
|
+
/** The platform page type, which the page's scripts and styles read. */
|
|
28
|
+
pageType?: string;
|
|
29
|
+
noindex?: boolean;
|
|
30
|
+
/** The product this page is about, for the WhatsApp message it starts. */
|
|
31
|
+
whatsappProduct?: string | null;
|
|
32
|
+
/** The order this page confirms, for the WhatsApp message it starts. */
|
|
33
|
+
whatsappOrder?: string | null;
|
|
34
|
+
/** Overrides the store pixel (a landing page may name its own). */
|
|
35
|
+
pixelId?: string | null;
|
|
36
|
+
/** Whether the page shows the store's header and footer areas: a landing page may leave them out. */
|
|
37
|
+
header?: boolean;
|
|
38
|
+
footer?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A store without a logo still has a tab icon, so the browser never asks for a missing /favicon.ico. */
|
|
42
|
+
import { BLACK, WHITE } from "@/theme/palette";
|
|
43
|
+
const FALLBACK_ICON = `data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="8" fill="${BLACK}"/><circle cx="16" cy="16" r="6" fill="${WHITE}"/></svg>`)}`;
|
|
44
|
+
|
|
45
|
+
const { title = "", description = "", ogImage = null, pageType = "", noindex = false, whatsappProduct = null, whatsappOrder = null, pixelId: pagePixelId, header = true, footer = true } = Astro.props;
|
|
46
|
+
const store = Astro.locals.store;
|
|
47
|
+
const { config, settings, routing, locale, content, isRTL, pathname } = store;
|
|
48
|
+
const t = createTranslator(content, locale);
|
|
49
|
+
|
|
50
|
+
const origin = (Astro.site ?? Astro.url).origin;
|
|
51
|
+
const alternates = !noindex && store.languages.length > 0 ? alternateLinks(pathname, routing, origin) : [];
|
|
52
|
+
const canonical = canonicalUrl(origin, store, Astro.url.search);
|
|
53
|
+
const pageTitle = !title ? config.metaTitle || config.name : title.includes(config.name) ? title : `${title} | ${config.name}`;
|
|
54
|
+
const pageDescription = description || config.metaDescription || t("brand.tagline");
|
|
55
|
+
const shareImage = ogImage || config.ogImage?.url;
|
|
56
|
+
const schemes = settings.colorSchemes;
|
|
57
|
+
const pageScheme = schemes.find((scheme) => scheme.id === settings.pageScheme) ?? schemes.find((scheme) => scheme.id === PAGE_SCHEME) ?? schemes[0];
|
|
58
|
+
const cartEnabled = config.cartEnabled === true;
|
|
59
|
+
const activePixelId = pagePixelId === undefined ? config.pixelId : pagePixelId;
|
|
60
|
+
|
|
61
|
+
// The widget is the merchant's, configured in the dashboard: which pages show
|
|
62
|
+
// it, where it sits, what it says. The theme only draws it, with the page's
|
|
63
|
+
// message: a product page's names its product, a confirmation its order.
|
|
64
|
+
const whatsapp = storeWhatsApp(store, Astro, whatsappProduct ? { kind: "product", product: whatsappProduct } : whatsappOrder ? { kind: "order", order: whatsappOrder } : { kind: "general" });
|
|
65
|
+
const whatsappShown = whatsapp !== null && showsWidgetOn(whatsapp.surfaces, pathname);
|
|
66
|
+
|
|
67
|
+
const publicConfig = {
|
|
68
|
+
locale,
|
|
69
|
+
localeTag: localeTag(locale),
|
|
70
|
+
isRTL,
|
|
71
|
+
storeName: config.name,
|
|
72
|
+
currency: config.currency,
|
|
73
|
+
symbol: config.currencySymbol || config.currency,
|
|
74
|
+
cartEnabled,
|
|
75
|
+
freeShippingThreshold: config.freeShippingThreshold,
|
|
76
|
+
otpEnabled: config.otpEnabled,
|
|
77
|
+
turnstileEnabled: config.turnstileEnabled,
|
|
78
|
+
turnstileSiteKey: config.turnstileSiteKey,
|
|
79
|
+
checkoutForm: config.checkoutForm,
|
|
80
|
+
reviewsEnabled: config.reviewsEnabled,
|
|
81
|
+
routes: {
|
|
82
|
+
checkout: localizeHref(storefrontPath("checkout"), locale, routing),
|
|
83
|
+
catalog: localizeHref(storefrontPath("catalog"), locale, routing),
|
|
84
|
+
search: localizeHref(storefrontPath("search"), locale, routing),
|
|
85
|
+
thankYou: localizeHref(storefrontPath("thankYou"), locale, routing),
|
|
86
|
+
},
|
|
87
|
+
content: browserCopy(content),
|
|
88
|
+
};
|
|
89
|
+
const publicJson = JSON.stringify(publicConfig).replace(/</g, "\\u003c");
|
|
90
|
+
---
|
|
91
|
+
<!doctype html>
|
|
92
|
+
<html lang={locale} dir={isRTL ? "rtl" : "ltr"} data-corners={settings.corners}>
|
|
93
|
+
<head>
|
|
94
|
+
<meta charset="utf-8" />
|
|
95
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
|
96
|
+
<title>{pageTitle}</title>
|
|
97
|
+
<meta name="description" content={pageDescription} />
|
|
98
|
+
<link rel="canonical" href={canonical} />
|
|
99
|
+
{noindex && <meta name="robots" content="noindex, nofollow" />}
|
|
100
|
+
{alternates.map((link) => <link rel="alternate" hreflang={link.hreflang} href={link.href} />)}
|
|
101
|
+
<meta property="og:type" content={pageType === "product" ? "product" : "website"} />
|
|
102
|
+
<meta property="og:site_name" content={config.name} />
|
|
103
|
+
<meta property="og:title" content={pageTitle} />
|
|
104
|
+
<meta property="og:description" content={pageDescription} />
|
|
105
|
+
<meta property="og:url" content={canonical} />
|
|
106
|
+
<meta property="og:locale" content={localeTag(locale).replace("-", "_")} />
|
|
107
|
+
{shareImage && <meta property="og:image" content={shareImage} />}
|
|
108
|
+
<meta name="twitter:card" content={shareImage ? "summary_large_image" : "summary"} />
|
|
109
|
+
<meta name="theme-color" content={pageScheme?.colors.background ?? WHITE} />
|
|
110
|
+
<meta name="format-detection" content="telephone=no" />
|
|
111
|
+
<link rel="icon" href={config.logo?.url || FALLBACK_ICON} />
|
|
112
|
+
{isRTL ? (
|
|
113
|
+
<link rel="preload" href="/fonts/alexandria-arabic.woff2" as="font" type="font/woff2" crossorigin />
|
|
114
|
+
) : (
|
|
115
|
+
<link rel="preload" href="/fonts/fraunces-latin.woff2" as="font" type="font/woff2" crossorigin />
|
|
116
|
+
)}
|
|
117
|
+
<ThemeStyles schemes={schemes} />
|
|
118
|
+
<slot name="head" />
|
|
119
|
+
<Fragment set:html={trackingHead(activePixelId)} />
|
|
120
|
+
</head>
|
|
121
|
+
<body class:list={[schemeClass(pageScheme?.id)]} data-cart-enabled={cartEnabled ? "true" : "false"} data-page-type={pageType} data-wa-side={whatsappShown ? whatsapp.position : undefined}>
|
|
122
|
+
<a class="skip-link" href="#main">{t("nav.skip")}</a>
|
|
123
|
+
{header && (
|
|
124
|
+
<div class="site-top" data-site-top>
|
|
125
|
+
<Area area="header" />
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
128
|
+
|
|
129
|
+
<main id="main"><slot /></main>
|
|
130
|
+
|
|
131
|
+
{footer && <Area area="footer" />}
|
|
132
|
+
{cartEnabled && <CartDrawer />}
|
|
133
|
+
{whatsappShown && <WhatsAppWidget contact={whatsapp} closeLabel={t("common.close")} />}
|
|
134
|
+
|
|
135
|
+
<button class="back-to-top" type="button" data-back-to-top aria-label={t("common.backToTop")} data-visible="false"><Icon name="arrow-up" size={20} /></button>
|
|
136
|
+
|
|
137
|
+
<script type="application/json" id="wocart-public" set:html={publicJson}></script>
|
|
138
|
+
<script>
|
|
139
|
+
import "@/scripts/site";
|
|
140
|
+
import { storefrontTracking } from "@abcart/storefront";
|
|
141
|
+
storefrontTracking().start();
|
|
142
|
+
</script>
|
|
143
|
+
<slot name="end" />
|
|
144
|
+
</body>
|
|
145
|
+
</html>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { messageForms } from "@abcart/theme/messages";
|
|
2
|
+
import type { ContentKey } from "@/theme/content";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The copy the browser scripts read, and the only copy a page embeds for them:
|
|
6
|
+
* everything else renders on the server. A guard test fails when a script
|
|
7
|
+
* reads a key missing here.
|
|
8
|
+
*/
|
|
9
|
+
export const BROWSER_COPY_KEYS = [
|
|
10
|
+
"a11y.rating",
|
|
11
|
+
"cart.added", "cart.blockedMissing", "cart.blockedOut", "cart.blockedUnlisted", "cart.count", "cart.decrease", "cart.deliveryAtCheckout",
|
|
12
|
+
"cart.freeProgress", "cart.freeQualified", "cart.full", "cart.gift", "cart.increase", "cart.quantity", "cart.remove", "cart.validateFailed",
|
|
13
|
+
"checkout.errorBody", "checkout.free", "checkout.gift", "checkout.invalidEmail", "checkout.invalidPhone", "checkout.loadingFee",
|
|
14
|
+
"checkout.otpAttempts", "checkout.otpError", "checkout.otpExpired", "checkout.otpHint", "checkout.otpResend", "checkout.otpUnavailable",
|
|
15
|
+
"checkout.otpVerified", "checkout.placing", "checkout.required", "checkout.unavailable",
|
|
16
|
+
"common.inStock", "common.loading",
|
|
17
|
+
"coupon.alreadyUsed", "coupon.applied", "coupon.appliedFreeShipping", "coupon.belowQuantity", "coupon.belowSubtotal",
|
|
18
|
+
"coupon.deliveryAlreadyFree", "coupon.expired", "coupon.identifyFirst", "coupon.noEligibleProducts", "coupon.notEligible",
|
|
19
|
+
"coupon.notFound", "coupon.notStarted", "coupon.offerApplied", "coupon.refused", "coupon.usedUp",
|
|
20
|
+
"offer.piece", "offer.saving",
|
|
21
|
+
"product.lowStock", "product.save", "product.soldOut",
|
|
22
|
+
"reviews.openPhoto",
|
|
23
|
+
] as const satisfies readonly ContentKey[];
|
|
24
|
+
|
|
25
|
+
/** The review form's words, embedded on the form itself: only a page with reviews carries them. */
|
|
26
|
+
export const REVIEW_FORM_COPY = [
|
|
27
|
+
"reviews.errorOrder", "reviews.errorOrderFormat", "reviews.errorNotDelivered", "reviews.errorRateLimited", "reviews.errorDuplicate", "reviews.errorFileType",
|
|
28
|
+
"reviews.errorFileSize", "reviews.errorGeneric", "reviews.nothingLeft", "reviews.orderFound", "reviews.photosLimit", "reviews.voiceLimit",
|
|
29
|
+
"reviews.sending", "reviews.notSent", "reviews.tooManyPhotos", "reviews.micDenied", "reviews.ratingRequired", "reviews.tooShort",
|
|
30
|
+
"reviews.waitUploads", "reviews.thanksPublished", "reviews.thanksPending",
|
|
31
|
+
"reviews.errorDisabled", "reviews.errorProduct", "reviews.errorGrant", "reviews.errorUploadMissing", "reviews.errorMediaLimit",
|
|
32
|
+
] as const satisfies readonly ContentKey[];
|
|
33
|
+
|
|
34
|
+
/** Each key with every plural form it has, so a count reads right in the browser too. */
|
|
35
|
+
export function browserCopy(content: Record<string, string>, keys: readonly string[] = BROWSER_COPY_KEYS): Record<string, string> {
|
|
36
|
+
return Object.assign({}, ...keys.map((key) => messageForms(content, key)));
|
|
37
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a page knows about its store, built once per request by the
|
|
3
|
+
* middleware: the store's config, the language the page renders in, the
|
|
4
|
+
* theme's words with the merchant's edits, and the theme settings. Pages,
|
|
5
|
+
* layouts and components read it from `Astro.locals.store`.
|
|
6
|
+
*/
|
|
7
|
+
import type { StoreConfig } from "@abcart/storefront";
|
|
8
|
+
import type { StoreClient } from "@abcart/storefront/server";
|
|
9
|
+
import { isSingleLanguagePage, localeRouting, localizeHref, servedLanguage, type LocaleRouting } from "@abcart/storefront";
|
|
10
|
+
import { resolveThemeContent, resolveThemeSettings, type InferSettings, type ThemeRenderContext } from "@abcart/theme";
|
|
11
|
+
import { content as packs } from "@/theme/content";
|
|
12
|
+
import { DEFAULT_LOCALE, LOCALES } from "@/theme/locales";
|
|
13
|
+
import { settingsDefinition } from "@/theme/settings";
|
|
14
|
+
|
|
15
|
+
/** The store's theme settings, typed from the theme's own declaration. */
|
|
16
|
+
export type ThemeSettings = InferSettings<typeof settingsDefinition>;
|
|
17
|
+
|
|
18
|
+
export interface StoreContext {
|
|
19
|
+
/** The SDK client for this request's language; every read of the page goes through it. */
|
|
20
|
+
client: StoreClient;
|
|
21
|
+
config: StoreConfig;
|
|
22
|
+
/** The language this request renders in. */
|
|
23
|
+
locale: string;
|
|
24
|
+
isRTL: boolean;
|
|
25
|
+
/** The store's languages, as links need them. */
|
|
26
|
+
routing: LocaleRouting;
|
|
27
|
+
/** The languages this page can be read in, for a language menu: empty on a single-language page or store. */
|
|
28
|
+
languages: PageLanguage[];
|
|
29
|
+
/** This page's path without its language prefix: the route it renders. */
|
|
30
|
+
pathname: string;
|
|
31
|
+
/** The theme's words in this language, with the merchant's edits. */
|
|
32
|
+
content: Record<string, string>;
|
|
33
|
+
settings: ThemeSettings;
|
|
34
|
+
/** An internal link in this request's language: `href("/products")` is `/fr/products` on a French page. */
|
|
35
|
+
href: (path: string) => string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface PageLanguage {
|
|
39
|
+
code: string;
|
|
40
|
+
/** The language's own name: "Français", "العربية". */
|
|
41
|
+
label: string;
|
|
42
|
+
/** This page in that language. */
|
|
43
|
+
href: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The languages this page can be read in, for a language menu: none when there is only one, or on a page that exists in the primary language only (a landing page). */
|
|
47
|
+
export function pageLanguages(config: StoreConfig, routing: LocaleRouting, pathname: string): PageLanguage[] {
|
|
48
|
+
if (routing.published.length < 2 || isSingleLanguagePage(pathname)) return [];
|
|
49
|
+
return routing.published.map((code) => ({
|
|
50
|
+
code,
|
|
51
|
+
label: config.locales.find((entry) => entry.code === code)?.nativeName ?? code,
|
|
52
|
+
href: localizeHref(pathname, code, routing),
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function buildStoreContext(config: StoreConfig, locale: string, pathname: string, client: StoreClient): StoreContext {
|
|
57
|
+
const language = servedLanguage(config, locale) ?? servedLanguage(config) ?? { code: locale, nativeName: locale, direction: "ltr" as const };
|
|
58
|
+
const routing = localeRouting(config);
|
|
59
|
+
// The SDK's one policy: this language's pack, then the merchant's text edits of its own keys.
|
|
60
|
+
const content = resolveThemeContent({ content: packs, locales: LOCALES }, language.code, config.contentOverrides?.[language.code], { defaultLocale: DEFAULT_LOCALE });
|
|
61
|
+
const { values } = resolveThemeSettings(settingsDefinition, config.themeSettings ?? {}, { locales: [language.code], content });
|
|
62
|
+
return {
|
|
63
|
+
client,
|
|
64
|
+
config,
|
|
65
|
+
locale: language.code,
|
|
66
|
+
isRTL: language.direction === "rtl",
|
|
67
|
+
routing,
|
|
68
|
+
languages: pageLanguages(config, routing, pathname),
|
|
69
|
+
pathname,
|
|
70
|
+
content,
|
|
71
|
+
settings: values,
|
|
72
|
+
href: (path) => localizeHref(path, language.code, routing),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** What the SDK's renderer gives every section: the store, the words and the language chain. */
|
|
77
|
+
export function buildThemeRenderContext(store: StoreContext, params?: Record<string, string | undefined>): ThemeRenderContext {
|
|
78
|
+
// A translated value falls back to the primary language's, never another language's.
|
|
79
|
+
const fallbackLocales = store.locale === store.config.lang ? [] : [store.config.lang];
|
|
80
|
+
return {
|
|
81
|
+
store: store.config,
|
|
82
|
+
content: store.content,
|
|
83
|
+
locale: store.locale,
|
|
84
|
+
fallbackLocales,
|
|
85
|
+
isRTL: store.isRTL,
|
|
86
|
+
url: store.pathname,
|
|
87
|
+
...(params ? { params } : {}),
|
|
88
|
+
};
|
|
89
|
+
}
|