@eldrajs/theme-cli 0.0.0 → 0.2.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 +77 -0
- package/LICENSE +21 -0
- package/README.md +26 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +203 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.js +3 -0
- package/dist/validate-DprFpjV7.js +535 -0
- package/package.json +50 -2
- package/template/.eldra/block-types.d.ts +429 -0
- package/template/.eldra/manifest.json +9378 -0
- package/template/.eldra/previews.json +36 -0
- package/template/.github/workflows/eldra-deploy.yml +24 -0
- package/template/.gitlab-ci.yml +16 -0
- package/template/.storybook/eldra.ts +123 -0
- package/template/.storybook/i18n.ts +23 -0
- package/template/.storybook/main.ts +59 -0
- package/template/.storybook/nuxt-link-stub.ts +23 -0
- package/template/.storybook/preview.ts +53 -0
- package/template/.storybook/shims-vue.d.ts +10 -0
- package/template/.storybook/virtual-eldra.d.ts +32 -0
- package/template/README.md +293 -0
- package/template/app/app.vue +126 -0
- package/template/app/assets/main.css +404 -0
- package/template/app/components/EldraIcon.vue +66 -0
- package/template/app/components/EldraRouterLink.vue +62 -0
- package/template/app/components/ui/UiImage.stories.ts +30 -0
- package/template/app/components/ui/UiImage.vue +224 -0
- package/template/app/components/ui/__tests__/UiImage.spec.ts +292 -0
- package/template/app/composables/iconComponent.ts +84 -0
- package/template/app/composables/iconFetcher.ts +14 -0
- package/template/app/composables/useBlockData.ts +30 -0
- package/template/app/composables/useEditing.ts +31 -0
- package/template/app/composables/useEldraIcon.ts +46 -0
- package/template/app/composables/useRevalidating.ts +69 -0
- package/template/app/composables/useRichTextScrollRegions.ts +80 -0
- package/template/app/composables/useStorefront.ts +18 -0
- package/template/app/composables/useStorefrontFeedback.ts +49 -0
- package/template/app/composables/useUiId.ts +18 -0
- package/template/app/composables/useWishlist.ts +42 -0
- package/template/app/i18n.d.ts +28 -0
- package/template/app/icons.ts +185 -0
- package/template/app/pages/[...slug].vue +134 -0
- package/template/app/plugins/eldra-i18n.ts +98 -0
- package/template/app/plugins/eldra-storefront.ts +288 -0
- package/template/app/plugins/eldra-ui-messages.ts +112 -0
- package/template/app/storefront/cart.ts +245 -0
- package/template/app/storefront/categories.ts +283 -0
- package/template/app/storefront/collectionSelector.ts +60 -0
- package/template/app/storefront/commerce.ts +58 -0
- package/template/app/storefront/demo.ts +1313 -0
- package/template/app/storefront/facets.ts +476 -0
- package/template/app/storefront/feedback.ts +122 -0
- package/template/app/storefront/gateway.ts +2256 -0
- package/template/app/storefront/history.ts +233 -0
- package/template/app/storefront/money.ts +248 -0
- package/template/app/storefront/options.ts +71 -0
- package/template/app/storefront/prerender.ts +77 -0
- package/template/app/storefront/refresh.ts +222 -0
- package/template/app/storefront/toProductCard.ts +154 -0
- package/template/app/storefront/types.ts +815 -0
- package/template/app/storefront/volatile.ts +211 -0
- package/template/app/templates.ts +544 -0
- package/template/app/utils/classes.ts +40 -0
- package/template/app/utils/links.ts +70 -0
- package/template/app/utils/pageStructure.ts +77 -0
- package/template/app/utils/pageTitle.ts +37 -0
- package/template/app/virtual-eldra.d.ts +12 -0
- package/template/bitbucket-pipelines.yml +19 -0
- package/template/blocks/announcement-bar/Block.vue +203 -0
- package/template/blocks/announcement-bar/__tests__/Block.spec.ts +227 -0
- package/template/blocks/announcement-bar/block.json +45 -0
- package/template/blocks/announcement-bar/mock.json +7 -0
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/Block.vue +317 -0
- package/template/blocks/article/__tests__/Block.spec.ts +229 -0
- package/template/blocks/article/block.json +148 -0
- package/template/blocks/article/mock.json +512 -0
- package/template/blocks/article/preview.json +16 -0
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/Block.vue +343 -0
- package/template/blocks/article-list/__tests__/Block.spec.ts +279 -0
- package/template/blocks/article-list/block.json +181 -0
- package/template/blocks/article-list/mock.json +68 -0
- package/template/blocks/article-list/preview.json +84 -0
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/Block.vue +278 -0
- package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +461 -0
- package/template/blocks/breadcrumbs/block.json +89 -0
- package/template/blocks/breadcrumbs/mock.json +11 -0
- package/template/blocks/breadcrumbs/preview.json +3 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/Block.vue +372 -0
- package/template/blocks/cart/__tests__/Block.spec.ts +561 -0
- package/template/blocks/cart/__tests__/ShippingBar.spec.ts +78 -0
- package/template/blocks/cart/__tests__/Summary.spec.ts +245 -0
- package/template/blocks/cart/block.json +74 -0
- package/template/blocks/cart/mock.json +11 -0
- package/template/blocks/cart/parts/CartLines.vue +257 -0
- package/template/blocks/cart/parts/ShippingBar.vue +105 -0
- package/template/blocks/cart/parts/Summary.vue +291 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +1832 -0
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +3037 -0
- package/template/blocks/collection-grid/__tests__/groups.spec.ts +731 -0
- package/template/blocks/collection-grid/block.json +187 -0
- package/template/blocks/collection-grid/mock.json +23 -0
- package/template/blocks/collection-grid/parts/groups.ts +861 -0
- package/template/blocks/collection-grid/preview.json +7 -0
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +533 -0
- package/template/blocks/collection-header/__tests__/Block.spec.ts +381 -0
- package/template/blocks/collection-header/block.json +140 -0
- package/template/blocks/collection-header/mock.json +28 -0
- package/template/blocks/collection-header/preview.json +14 -0
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/Block.vue +621 -0
- package/template/blocks/contact/__tests__/Block.spec.ts +347 -0
- package/template/blocks/contact/block.json +174 -0
- package/template/blocks/contact/mock.json +28 -0
- package/template/blocks/contact/preview.json +9 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/Block.vue +383 -0
- package/template/blocks/cta/__tests__/Block.spec.ts +309 -0
- package/template/blocks/cta/block.json +86 -0
- package/template/blocks/cta/mock.json +10 -0
- package/template/blocks/cta/preview.json +9 -0
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/Block.vue +254 -0
- package/template/blocks/faq/__tests__/Block.spec.ts +312 -0
- package/template/blocks/faq/block.json +113 -0
- package/template/blocks/faq/mock.json +115 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/Block.vue +241 -0
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +311 -0
- package/template/blocks/feature-grid/block.json +106 -0
- package/template/blocks/feature-grid/mock.json +29 -0
- package/template/blocks/feature-grid/preview.json +45 -0
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +652 -0
- package/template/blocks/footer/__tests__/Block.spec.ts +700 -0
- package/template/blocks/footer/block.json +240 -0
- package/template/blocks/footer/mock.json +161 -0
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/gallery/Block.vue +416 -0
- package/template/blocks/gallery/__tests__/Block.spec.ts +289 -0
- package/template/blocks/gallery/block.json +87 -0
- package/template/blocks/gallery/mock.json +16 -0
- package/template/blocks/gallery/preview.json +64 -0
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +378 -0
- package/template/blocks/hero/__tests__/Block.spec.ts +324 -0
- package/template/blocks/hero/block.json +146 -0
- package/template/blocks/hero/mock.json +11 -0
- package/template/blocks/hero/preview.json +55 -0
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/Block.vue +232 -0
- package/template/blocks/image/__tests__/Block.spec.ts +224 -0
- package/template/blocks/image/block.json +67 -0
- package/template/blocks/image/mock.json +7 -0
- package/template/blocks/image/preview.json +9 -0
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/Block.vue +206 -0
- package/template/blocks/logo-cloud/__tests__/Block.spec.ts +210 -0
- package/template/blocks/logo-cloud/block.json +79 -0
- package/template/blocks/logo-cloud/mock.json +15 -0
- package/template/blocks/logo-cloud/preview.json +92 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +1348 -0
- package/template/blocks/navigation/__tests__/Block.spec.ts +2030 -0
- package/template/blocks/navigation/block.json +167 -0
- package/template/blocks/navigation/mock.json +191 -0
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/navigation/useMegaMenuKeys.ts +276 -0
- package/template/blocks/newsletter/Block.vue +399 -0
- package/template/blocks/newsletter/__tests__/Block.spec.ts +365 -0
- package/template/blocks/newsletter/block.json +105 -0
- package/template/blocks/newsletter/mock.json +31 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/Block.vue +754 -0
- package/template/blocks/order-status/__tests__/Block.spec.ts +515 -0
- package/template/blocks/order-status/block.json +138 -0
- package/template/blocks/order-status/mock.json +19 -0
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/Block.vue +297 -0
- package/template/blocks/pricing-table/__tests__/Block.spec.ts +357 -0
- package/template/blocks/pricing-table/block.json +155 -0
- package/template/blocks/pricing-table/mock.json +47 -0
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +459 -0
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +957 -0
- package/template/blocks/product-carousel/block.json +71 -0
- package/template/blocks/product-carousel/mock.json +9 -0
- package/template/blocks/product-carousel/preview.json +7 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +886 -0
- package/template/blocks/product-detail/__tests__/Block.spec.ts +1492 -0
- package/template/blocks/product-detail/__tests__/stock.spec.ts +119 -0
- package/template/blocks/product-detail/block.json +155 -0
- package/template/blocks/product-detail/mock.json +113 -0
- package/template/blocks/product-detail/parts/Gallery.vue +181 -0
- package/template/blocks/product-detail/parts/StickyBuyBar.vue +99 -0
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/product-detail/stock.ts +150 -0
- package/template/blocks/quote/Block.vue +206 -0
- package/template/blocks/quote/__tests__/Block.spec.ts +265 -0
- package/template/blocks/quote/block.json +76 -0
- package/template/blocks/quote/mock.json +9 -0
- package/template/blocks/quote/preview.json +16 -0
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/Block.vue +143 -0
- package/template/blocks/rich-text/__tests__/Block.spec.ts +191 -0
- package/template/blocks/rich-text/block.json +57 -0
- package/template/blocks/rich-text/mock.json +87 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +589 -0
- package/template/blocks/search/PopularChips.vue +40 -0
- package/template/blocks/search/TypeSection.vue +148 -0
- package/template/blocks/search/__tests__/Block.spec.ts +718 -0
- package/template/blocks/search/__tests__/results.spec.ts +166 -0
- package/template/blocks/search/block.json +102 -0
- package/template/blocks/search/mock.json +18 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/search/results.ts +85 -0
- package/template/blocks/split-content/Block.vue +195 -0
- package/template/blocks/split-content/__tests__/Block.spec.ts +225 -0
- package/template/blocks/split-content/block.json +70 -0
- package/template/blocks/split-content/mock.json +45 -0
- package/template/blocks/split-content/preview.json +58 -0
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/Block.vue +159 -0
- package/template/blocks/stats/__tests__/Block.spec.ts +194 -0
- package/template/blocks/stats/block.json +73 -0
- package/template/blocks/stats/mock.json +12 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/Block.vue +278 -0
- package/template/blocks/tabs/__tests__/Block.spec.ts +303 -0
- package/template/blocks/tabs/block.json +97 -0
- package/template/blocks/tabs/mock.json +129 -0
- package/template/blocks/tabs/preview.json +153 -0
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/Block.vue +288 -0
- package/template/blocks/team/__tests__/Block.spec.ts +221 -0
- package/template/blocks/team/block.json +125 -0
- package/template/blocks/team/mock.json +39 -0
- package/template/blocks/team/preview.json +62 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/Block.vue +408 -0
- package/template/blocks/testimonials/__tests__/Block.spec.ts +319 -0
- package/template/blocks/testimonials/block.json +121 -0
- package/template/blocks/testimonials/mock.json +46 -0
- package/template/blocks/testimonials/preview.json +68 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/Block.vue +274 -0
- package/template/blocks/timeline/__tests__/Block.spec.ts +310 -0
- package/template/blocks/timeline/block.json +98 -0
- package/template/blocks/timeline/mock.json +27 -0
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +330 -0
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +290 -0
- package/template/blocks/trust-strip/block.json +117 -0
- package/template/blocks/trust-strip/mock.json +37 -0
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/Block.vue +354 -0
- package/template/blocks/video-embed/__tests__/Block.spec.ts +219 -0
- package/template/blocks/video-embed/__tests__/embed.spec.ts +76 -0
- package/template/blocks/video-embed/block.json +94 -0
- package/template/blocks/video-embed/embed.ts +84 -0
- package/template/blocks/video-embed/mock.json +13 -0
- package/template/blocks/video-embed/preview.json +9 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/Block.vue +367 -0
- package/template/blocks/wishlist/__tests__/Block.spec.ts +508 -0
- package/template/blocks/wishlist/block.json +42 -0
- package/template/blocks/wishlist/mock.json +9 -0
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +602 -0
- package/template/i18n/is-IS.json +602 -0
- package/template/nuxt.config.ts +156 -0
- package/template/package.json +56 -0
- package/template/pages/article.page.json +731 -0
- package/template/pages/cart.page.json +85 -0
- package/template/pages/category.page.json +133 -0
- package/template/pages/collection.page.json +194 -0
- package/template/pages/home.page.json +353 -0
- package/template/pages/product.page.json +323 -0
- package/template/pages/products.page.json +144 -0
- package/template/pages/search.page.json +83 -0
- package/template/pages/wishlist.page.json +88 -0
- package/template/public/apple-touch-icon.png +0 -0
- package/template/public/demo/article-cover.svg +1 -0
- package/template/public/demo/article-figure.svg +1 -0
- package/template/public/demo/avatar-1.svg +3 -0
- package/template/public/demo/avatar-2.svg +3 -0
- package/template/public/demo/avatar-3.svg +3 -0
- package/template/public/demo/avatar-4.svg +3 -0
- package/template/public/demo/avatar-5.svg +3 -0
- package/template/public/demo/avatar-6.svg +3 -0
- package/template/public/demo/avatar-7.svg +3 -0
- package/template/public/demo/avatar-8.svg +3 -0
- package/template/public/demo/collection-1.svg +1 -0
- package/template/public/demo/collection-2.svg +1 -0
- package/template/public/demo/cta-split.svg +1 -0
- package/template/public/demo/feature-1.svg +1 -0
- package/template/public/demo/feature-2.svg +1 -0
- package/template/public/demo/feature-3.svg +1 -0
- package/template/public/demo/feature-4.svg +1 -0
- package/template/public/demo/gallery-1.svg +1 -0
- package/template/public/demo/gallery-2.svg +1 -0
- package/template/public/demo/gallery-3.svg +1 -0
- package/template/public/demo/gallery-4.svg +1 -0
- package/template/public/demo/gallery-5.svg +1 -0
- package/template/public/demo/gallery-6.svg +1 -0
- package/template/public/demo/gallery-7.svg +1 -0
- package/template/public/demo/gallery-8.svg +1 -0
- package/template/public/demo/hero-slide-1.svg +1 -0
- package/template/public/demo/hero-slide-2.svg +1 -0
- package/template/public/demo/hero-slide-3.svg +1 -0
- package/template/public/demo/hero-slide-4.svg +1 -0
- package/template/public/demo/hero-wide.svg +1 -0
- package/template/public/demo/hero.svg +1 -0
- package/template/public/demo/logo-1.svg +4 -0
- package/template/public/demo/logo-2.svg +4 -0
- package/template/public/demo/logo-3.svg +4 -0
- package/template/public/demo/logo-4.svg +4 -0
- package/template/public/demo/logo-5.svg +4 -0
- package/template/public/demo/logo-6.svg +4 -0
- package/template/public/demo/logo-7.svg +4 -0
- package/template/public/demo/logo-8.svg +4 -0
- package/template/public/demo/logo.svg +3 -0
- package/template/public/demo/map.svg +1 -0
- package/template/public/demo/poster.svg +1 -0
- package/template/public/demo/product-1.svg +4 -0
- package/template/public/demo/product-10.svg +4 -0
- package/template/public/demo/product-11.svg +4 -0
- package/template/public/demo/product-12.svg +4 -0
- package/template/public/demo/product-2.svg +4 -0
- package/template/public/demo/product-3.svg +4 -0
- package/template/public/demo/product-4.svg +4 -0
- package/template/public/demo/product-5.svg +4 -0
- package/template/public/demo/product-6.svg +4 -0
- package/template/public/demo/product-7.svg +4 -0
- package/template/public/demo/product-8.svg +4 -0
- package/template/public/demo/product-9.svg +4 -0
- package/template/public/demo/product-square-1.svg +4 -0
- package/template/public/demo/product-square-2.svg +4 -0
- package/template/public/demo/product-square-3.svg +4 -0
- package/template/public/demo/product-square-4.svg +4 -0
- package/template/public/demo/product-square-5.svg +4 -0
- package/template/public/demo/product-square-6.svg +4 -0
- package/template/public/demo/quote-portrait.svg +4 -0
- package/template/public/demo/split-1.svg +1 -0
- package/template/public/demo/split-2.svg +1 -0
- package/template/public/demo/split-3.svg +1 -0
- package/template/public/demo/split-4.svg +1 -0
- package/template/public/demo/team-1.svg +4 -0
- package/template/public/demo/team-2.svg +4 -0
- package/template/public/demo/team-3.svg +4 -0
- package/template/public/demo/team-4.svg +4 -0
- package/template/public/favicon.ico +0 -0
- package/template/scripts/demo-images.mjs +393 -0
- package/template/scripts/generate-stories.mjs +156 -0
- package/template/scripts/previewHash.mjs +125 -0
- package/template/scripts/previews.mjs +149 -0
- package/template/stories/generated/announcement-bar.stories.ts +44 -0
- package/template/stories/generated/article-list.stories.ts +87 -0
- package/template/stories/generated/article.stories.ts +27 -0
- package/template/stories/generated/breadcrumbs.stories.ts +39 -0
- package/template/stories/generated/cart.stories.ts +38 -0
- package/template/stories/generated/collection-grid.stories.ts +117 -0
- package/template/stories/generated/collection-header.stories.ts +51 -0
- package/template/stories/generated/contact.stories.ts +45 -0
- package/template/stories/generated/cta.stories.ts +51 -0
- package/template/stories/generated/faq.stories.ts +56 -0
- package/template/stories/generated/feature-grid.stories.ts +69 -0
- package/template/stories/generated/footer.stories.ts +50 -0
- package/template/stories/generated/gallery.stories.ts +81 -0
- package/template/stories/generated/hero.stories.ts +75 -0
- package/template/stories/generated/image.stories.ts +99 -0
- package/template/stories/generated/logo-cloud.stories.ts +57 -0
- package/template/stories/generated/navigation.stories.ts +62 -0
- package/template/stories/generated/newsletter.stories.ts +68 -0
- package/template/stories/generated/order-status.stories.ts +32 -0
- package/template/stories/generated/pricing-table.stories.ts +44 -0
- package/template/stories/generated/product-carousel.stories.ts +75 -0
- package/template/stories/generated/product-detail.stories.ts +62 -0
- package/template/stories/generated/quote.stories.ts +69 -0
- package/template/stories/generated/rich-text.stories.ts +50 -0
- package/template/stories/generated/search.stories.ts +56 -0
- package/template/stories/generated/split-content.stories.ts +39 -0
- package/template/stories/generated/stats.stories.ts +68 -0
- package/template/stories/generated/tabs.stories.ts +45 -0
- package/template/stories/generated/team.stories.ts +45 -0
- package/template/stories/generated/testimonials.stories.ts +69 -0
- package/template/stories/generated/timeline.stories.ts +80 -0
- package/template/stories/generated/trust-strip.stories.ts +62 -0
- package/template/stories/generated/video-embed.stories.ts +63 -0
- package/template/stories/generated/wishlist.stories.ts +26 -0
- package/template/stories/pages/article.stories.ts +51 -0
- package/template/stories/pages/cart.stories.ts +56 -0
- package/template/stories/pages/category.stories.ts +56 -0
- package/template/stories/pages/collection.stories.ts +51 -0
- package/template/stories/pages/home.stories.ts +51 -0
- package/template/stories/pages/product.stories.ts +47 -0
- package/template/stories/pages/products.stories.ts +58 -0
- package/template/stories/pages/search.stories.ts +54 -0
- package/template/stories/pages/wishlist.stories.ts +53 -0
- package/template/stories/support/pageBlocks.ts +115 -0
- package/template/test/blocksEmptyData.spec.ts +52 -0
- package/template/test/carouselKeyboard.spec.ts +272 -0
- package/template/test/carouselRing.browser.spec.ts +193 -0
- package/template/test/carouselSlideWidth.browser.spec.ts +102 -0
- package/template/test/cartDrawer.spec.ts +295 -0
- package/template/test/cartToast.spec.ts +86 -0
- package/template/test/countPill.browser.spec.ts +196 -0
- package/template/test/demoImages.spec.ts +140 -0
- package/template/test/deps.spec.ts +102 -0
- package/template/test/eldraIcon.spec.ts +58 -0
- package/template/test/framing.spec.ts +76 -0
- package/template/test/i18n.spec.ts +200 -0
- package/template/test/iconComponent.spec.ts +91 -0
- package/template/test/inlineEditable.spec.ts +335 -0
- package/template/test/localePrefix.spec.ts +342 -0
- package/template/test/mainCss.spec.ts +107 -0
- package/template/test/mockGatewayContract.spec.ts +122 -0
- package/template/test/mocks/blocks.ts +20 -0
- package/template/test/mocks/breakpoints.ts +7 -0
- package/template/test/mocks/manifest.ts +11 -0
- package/template/test/moneyFormatting.spec.ts +85 -0
- package/template/test/pageTitle.spec.ts +49 -0
- package/template/test/pages/article.spec.ts +231 -0
- package/template/test/pages/category.spec.ts +185 -0
- package/template/test/pages/collection.spec.ts +396 -0
- package/template/test/pages/home.spec.ts +295 -0
- package/template/test/pages/hydration.spec.ts +557 -0
- package/template/test/pages/product.spec.ts +396 -0
- package/template/test/pages/seededPages.spec.ts +190 -0
- package/template/test/pages/ssr.spec.ts +387 -0
- package/template/test/prerenderCommerce.spec.ts +134 -0
- package/template/test/prerenderFailure.spec.ts +130 -0
- package/template/test/prerenderRefresh.browser.spec.ts +1431 -0
- package/template/test/previewsFresh.spec.ts +56 -0
- package/template/test/richText.spec.ts +164 -0
- package/template/test/richTextTypography.spec.ts +182 -0
- package/template/test/setup.ts +21 -0
- package/template/test/slugPage.spec.ts +244 -0
- package/template/test/slugPageTemplate.spec.ts +194 -0
- package/template/test/starter.spec.ts +1416 -0
- package/template/test/storefront/cart.spec.ts +404 -0
- package/template/test/storefront/categories.spec.ts +235 -0
- package/template/test/storefront/collectionSelector.spec.ts +74 -0
- package/template/test/storefront/demo.spec.ts +555 -0
- package/template/test/storefront/facets.spec.ts +425 -0
- package/template/test/storefront/feedback.spec.ts +97 -0
- package/template/test/storefront/gateway.spec.ts +2673 -0
- package/template/test/storefront/gatewayCart.spec.ts +289 -0
- package/template/test/storefront/gatewayPrerender.spec.ts +1037 -0
- package/template/test/storefront/history.spec.ts +341 -0
- package/template/test/storefront/money.spec.ts +170 -0
- package/template/test/storefront/toProductCard.spec.ts +138 -0
- package/template/test/storefront/volatile.spec.ts +284 -0
- package/template/test/support/axe.ts +14 -0
- package/template/test/support/dialog.ts +51 -0
- package/template/test/support/hydrate.ts +118 -0
- package/template/test/support/i18nText.ts +11 -0
- package/template/test/support/mockGateway.ts +1017 -0
- package/template/test/support/mountBlock.ts +194 -0
- package/template/test/support/mountPage.spec.ts +72 -0
- package/template/test/support/mountPage.ts +254 -0
- package/template/test/support/mountProbe.client.ts +69 -0
- package/template/test/support/renderSsr.ts +97 -0
- package/template/test/support/staticServer.ts +96 -0
- package/template/test/themeIcons.spec.ts +140 -0
- package/template/test/toastAnnouncement.spec.ts +133 -0
- package/template/test/tokens.spec.ts +102 -0
- package/template/test/uiMessagesPlugin.spec.ts +104 -0
- package/template/test/useBlockData.spec.ts +49 -0
- package/template/test/useEditing.spec.ts +54 -0
- package/template/test/useEldraIcon.spec.ts +126 -0
- package/template/test/useUiId.spec.ts +40 -0
- package/template/tokens.json +149 -0
- package/template/tsconfig.json +3 -0
- package/template/tsconfig.storybook.json +17 -0
- package/template/vitest-axe.d.ts +13 -0
- package/template/vitest.config.ts +44 -0
|
@@ -0,0 +1,886 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Product detail · the product page's buy box (spec `02-blocks.md` "Product detail", 3172–3300):
|
|
4
|
+
* gallery, title, price, rating, variant pickers, honest stock status, quantity, add to cart,
|
|
5
|
+
* delivery notes and description tabs, plus a quick-add bar on narrow widths. The title, price,
|
|
6
|
+
* images, options, inventory and rating all come from `useStorefront()`; the CMS fields decide what
|
|
7
|
+
* the block shows and add the editorial copy around it.
|
|
8
|
+
*
|
|
9
|
+
* **Which product.** `productHandle` is empty on a product template, where the route supplies it
|
|
10
|
+
* (`storefront.route.productHandle`); an author fills it in by hand for a featured-product landing
|
|
11
|
+
* section. With neither, the editor sees the "Choose a product" placeholder and the live site
|
|
12
|
+
* renders nothing (Global Constraints, "Editor vs live").
|
|
13
|
+
*
|
|
14
|
+
* **`gallery-right` mirrors visually only.** The gallery is first in the DOM in both variants and
|
|
15
|
+
* only the `@tablet:order-*` utilities swap the columns, so reading and focus order never change
|
|
16
|
+
* (spec Variants, `gallery-right` row).
|
|
17
|
+
*
|
|
18
|
+
* **The buy area is a real `<form>`**, the way a storefront's add-to-cart form always is: the
|
|
19
|
+
* pickers are its radio groups, the stepper its quantity field and Add to cart its submit button,
|
|
20
|
+
* so `Enter` inside the form buys.
|
|
21
|
+
*
|
|
22
|
+
* **Each radio group gets a unique native `name`.** `VariantPicker`'s `legend` prop (separate from
|
|
23
|
+
* `name`, see `packages/ui/src/components/variant-picker/VariantPicker.vue`) is what makes this
|
|
24
|
+
* possible without also changing the visible/accessible legend text: `instanceId` (`useUiId()`)
|
|
25
|
+
* combines with `option.name` into the radios' `name` attribute, so two product-detail blocks on
|
|
26
|
+
* one page — or a repeated option name within one — never share a group, while `legend`
|
|
27
|
+
* (`option.label`) keeps reading "Colour", never "Colour v-3".
|
|
28
|
+
*
|
|
29
|
+
* **Stock is derived, never stored** — `stock.ts` owns the four-state rule so the template branches
|
|
30
|
+
* once and the whole matrix is provable without mounting anything. `role="status"`/`aria-live`
|
|
31
|
+
* around it is what announces a variant change politely, and nothing here moves focus when the
|
|
32
|
+
* selection changes (spec Acceptance criteria, 4.1.3/3.2.2).
|
|
33
|
+
*
|
|
34
|
+
* **No countdowns, viewer counts or invented urgency** — the block has no fields for them on
|
|
35
|
+
* purpose (spec Do/Don't).
|
|
36
|
+
*/
|
|
37
|
+
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
|
38
|
+
import {
|
|
39
|
+
Badge,
|
|
40
|
+
Button,
|
|
41
|
+
Container,
|
|
42
|
+
Dialog,
|
|
43
|
+
EditorPlaceholder,
|
|
44
|
+
FieldWrapper,
|
|
45
|
+
FormLayout,
|
|
46
|
+
Input,
|
|
47
|
+
Link,
|
|
48
|
+
Price,
|
|
49
|
+
QuantityStepper,
|
|
50
|
+
Rating,
|
|
51
|
+
Section,
|
|
52
|
+
StockBadge,
|
|
53
|
+
Tab,
|
|
54
|
+
TabPanel,
|
|
55
|
+
Tabs,
|
|
56
|
+
VariantPicker,
|
|
57
|
+
useToast,
|
|
58
|
+
type FormLayoutSubmitPayload,
|
|
59
|
+
} from '@eldrajs/ui';
|
|
60
|
+
import { EldraRichText, useEldraLocale } from '@eldrajs/theme-vue';
|
|
61
|
+
import { useBlockData } from '../../app/composables/useBlockData';
|
|
62
|
+
import { useEditing } from '../../app/composables/useEditing';
|
|
63
|
+
import { useRichTextScrollRegions } from '../../app/composables/useRichTextScrollRegions';
|
|
64
|
+
import { useRevalidating } from '../../app/composables/useRevalidating';
|
|
65
|
+
import { useStorefront } from '../../app/composables/useStorefront';
|
|
66
|
+
import { useWishlist } from '../../app/composables/useWishlist';
|
|
67
|
+
import { useStorefrontFeedback } from '../../app/composables/useStorefrontFeedback';
|
|
68
|
+
import { CART_ADD_TOAST_ID, isOutOfStock, WISHLIST_TOAST_ID } from '../../app/storefront/feedback';
|
|
69
|
+
import { roundMoney, useMoney } from '../../app/storefront/money';
|
|
70
|
+
import { useI18n } from 'vue-i18n';
|
|
71
|
+
import { useUiId } from '../../app/composables/useUiId';
|
|
72
|
+
import EldraIcon from '../../app/components/EldraIcon.vue';
|
|
73
|
+
import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
|
|
74
|
+
import { isInternalHref, safeHref } from '../../app/utils/links';
|
|
75
|
+
import Gallery from './parts/Gallery.vue';
|
|
76
|
+
import StickyBuyBar from './parts/StickyBuyBar.vue';
|
|
77
|
+
import { deriveStockLine, type LowStockThreshold } from './stock';
|
|
78
|
+
|
|
79
|
+
interface PerkItem {
|
|
80
|
+
icon?: string;
|
|
81
|
+
title?: string;
|
|
82
|
+
text?: string;
|
|
83
|
+
}
|
|
84
|
+
interface TabItem {
|
|
85
|
+
label?: string;
|
|
86
|
+
body?: { content?: unknown[] } | null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const props = defineProps<{ entry: EldraBlockEntry<'product-detail'> }>();
|
|
90
|
+
const { data, entryId } = useBlockData(props, 'product-detail');
|
|
91
|
+
const { t } = useI18n();
|
|
92
|
+
const editing = useEditing();
|
|
93
|
+
const storefront = useStorefront();
|
|
94
|
+
/** The saved-for-later list, hydrated after mount — see `useWishlist()` for why the heart is
|
|
95
|
+
* never pressed in prerendered HTML. */
|
|
96
|
+
const wishlist = useWishlist();
|
|
97
|
+
const feedback = useStorefrontFeedback();
|
|
98
|
+
const toast = useToast();
|
|
99
|
+
|
|
100
|
+
const titleId = `product-detail-title-${useUiId()}`;
|
|
101
|
+
/** Every `VariantPicker` radio group on the page needs a unique native `name`, or two
|
|
102
|
+
* product-detail blocks (or a repeated `option.name` within one) would join the same group — see
|
|
103
|
+
* the module doc comment for why `legend` is what keeps the human-readable text ("Colour") out of
|
|
104
|
+
* that name. */
|
|
105
|
+
const instanceId = useUiId();
|
|
106
|
+
|
|
107
|
+
/* ------------------------------------------------------------------------- */
|
|
108
|
+
/* The product */
|
|
109
|
+
/* ------------------------------------------------------------------------- */
|
|
110
|
+
|
|
111
|
+
const handle = computed<string | null>(() => {
|
|
112
|
+
const chosen = (data.value.productHandle ?? '').trim();
|
|
113
|
+
if (chosen !== '') return chosen;
|
|
114
|
+
return storefront.route.productHandle;
|
|
115
|
+
});
|
|
116
|
+
const productResult = storefront.catalog.product(handle);
|
|
117
|
+
const product = computed(() => productResult.data.value);
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* **The prerender contract** (`app/storefront/types.ts`): this page's HTML was built with the
|
|
121
|
+
* product's real title, images, price and stock line, so the three states below are about what the
|
|
122
|
+
* page does *not* have, never about what it already shows.
|
|
123
|
+
*
|
|
124
|
+
* - `showStatus` — the skeleton/loading line, and the "we couldn't load this" line. Only ever with
|
|
125
|
+
* no product at all: an error over a product the visitor can see keeps the product (the `v-if`
|
|
126
|
+
* chain in the template puts `product` first, and this reads `product === null` as well so the
|
|
127
|
+
* rule is stated rather than implied by template order).
|
|
128
|
+
* - `notFound` — the read finished, answered nothing, and did not fail: the handle names a product
|
|
129
|
+
* this catalogue does not have. A prerendered page outlives its catalogue, so this is a real
|
|
130
|
+
* visitor state (a bookmarked link to a discontinued product), not only an author mistake.
|
|
131
|
+
* - `revalidating` — the two states in which a fresher value is on its way, both drawn the same
|
|
132
|
+
* way: the volatile refresh (`StorefrontResult.revalidating`, money and the stock line), and a
|
|
133
|
+
* *different* product loading over the one on screen (`loading && data !== null`, the handle
|
|
134
|
+
* changed). The values stay, dimmed with a spinner; the page never regresses to a skeleton for
|
|
135
|
+
* something it can already show. Both go through `useRevalidating`, which holds them at `false`
|
|
136
|
+
* until after mount — a hydrating page's result is already `loading` with its payload data in
|
|
137
|
+
* place, so reading either signal straight through would paint a busy state the server never
|
|
138
|
+
* wrote (see that composable's own comment).
|
|
139
|
+
*/
|
|
140
|
+
const showStatus = computed(
|
|
141
|
+
() =>
|
|
142
|
+
handle.value !== null &&
|
|
143
|
+
product.value === null &&
|
|
144
|
+
(productResult.pending.value || productResult.error.value !== null)
|
|
145
|
+
);
|
|
146
|
+
const notFound = computed(
|
|
147
|
+
() =>
|
|
148
|
+
handle.value !== null &&
|
|
149
|
+
product.value === null &&
|
|
150
|
+
!productResult.pending.value &&
|
|
151
|
+
!productResult.loading.value &&
|
|
152
|
+
productResult.error.value === null
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* `Price` and `StockBadge` keep their prerendered value, dim it, draw a spinner beside it and
|
|
157
|
+
* announce the refresh themselves — `announce` is left at its default here, unlike the card lists,
|
|
158
|
+
* because a product page has exactly one price and one stock line to speak about.
|
|
159
|
+
*/
|
|
160
|
+
const {
|
|
161
|
+
price: priceRevalidating,
|
|
162
|
+
stock: stockRevalidating,
|
|
163
|
+
refreshing,
|
|
164
|
+
} = useRevalidating({
|
|
165
|
+
keys: () => productResult.revalidating.value,
|
|
166
|
+
refreshing: () => productResult.loading.value && product.value !== null,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* `true` from the first client render onwards, and never on the server — the gate every piece of
|
|
171
|
+
* **shopper** state on this page is read behind (`cartBusy` below; the wishlist's own store keeps
|
|
172
|
+
* the same gate internally, see `useWishlist()`).
|
|
173
|
+
*
|
|
174
|
+
* The rule it enforces: nothing a visitor's own browser knows may reach the prerendered file, and
|
|
175
|
+
* nothing may reach the *first* client render either, because that render is what Nuxt hydrates
|
|
176
|
+
* the file with. A value that differs between the two is a hydration mismatch, and Vue answers one
|
|
177
|
+
* by throwing that subtree away and rendering it again. Gated like this, the same value arrives a
|
|
178
|
+
* tick later as an ordinary reactive update.
|
|
179
|
+
*/
|
|
180
|
+
const mounted = ref(false);
|
|
181
|
+
|
|
182
|
+
/** Spec Field → layout mapping: "Mounting records the product in `history.recordView`" — the
|
|
183
|
+
* `product-carousel` block's `recently-viewed` source is the other half of this. */
|
|
184
|
+
onMounted(() => {
|
|
185
|
+
mounted.value = true;
|
|
186
|
+
if (handle.value !== null) storefront.history.recordView(handle.value);
|
|
187
|
+
});
|
|
188
|
+
watch(handle, (next) => {
|
|
189
|
+
if (next !== null) storefront.history.recordView(next);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
/* ------------------------------------------------------------------------- */
|
|
193
|
+
/* Fields */
|
|
194
|
+
/* ------------------------------------------------------------------------- */
|
|
195
|
+
|
|
196
|
+
const galleryRight = computed(() => data.value.variant === 'gallery-right');
|
|
197
|
+
const showCategory = computed(() => data.value.showCategory !== false);
|
|
198
|
+
const showRatingField = computed(() => data.value.showRating !== false);
|
|
199
|
+
const showQuantity = computed(() => data.value.showQuantity !== false);
|
|
200
|
+
const showWishlist = computed(() => data.value.showWishlist !== false);
|
|
201
|
+
const stickyBarEnabled = computed(() => data.value.stickyBar !== false);
|
|
202
|
+
const threshold = computed<LowStockThreshold>(() => data.value.lowStockThreshold ?? '3');
|
|
203
|
+
const perks = computed<PerkItem[]>(() =>
|
|
204
|
+
(data.value.perks ?? []).filter((perk: PerkItem) => Boolean(perk.title))
|
|
205
|
+
);
|
|
206
|
+
const tabs = computed<TabItem[]>(() =>
|
|
207
|
+
(data.value.tabs ?? []).filter((tab: TabItem) => Boolean(tab.label))
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
const sizeGuideHref = computed(() => safeHref(data.value.sizeGuideHref));
|
|
211
|
+
const sizeGuideLabel = computed(() => data.value.sizeGuideLabel?.trim() || t('product.sizeGuide'));
|
|
212
|
+
const sizeGuideAs = computed(() =>
|
|
213
|
+
sizeGuideHref.value !== null && isInternalHref(sizeGuideHref.value) ? EldraRouterLink : undefined
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* **The product's own category, as one label — never a trail.**
|
|
218
|
+
*
|
|
219
|
+
* The *trail* belongs to `breadcrumbs`, which is the block whose job a trail is and the one that
|
|
220
|
+
* can put the page-tree levels above the catalogue in front of it. Drawing the whole trail here as
|
|
221
|
+
* well meant a page carrying both blocks — the default, since `showCategory` is on unless an author
|
|
222
|
+
* turns it off and so is `breadcrumbs`' `fromProduct` — had the same levels twice, in two `<nav>`s
|
|
223
|
+
* both named "Breadcrumb". One leaf label beside the title is the thing this block actually wants:
|
|
224
|
+
* which shelf this product sits on. See `docs/starter-kit.md`, "The category tree", for how the two
|
|
225
|
+
* fields relate.
|
|
226
|
+
*
|
|
227
|
+
* The leaf comes from the store, not from a field, but it still ends up in an `href`, so it goes
|
|
228
|
+
* through the same `safeHref` gate every author-supplied destination in this theme passes; a
|
|
229
|
+
* destination that does not survive it drops the label rather than rendering a broken link.
|
|
230
|
+
*/
|
|
231
|
+
const categoryLeaf = computed<{ label: string; href: string } | null>(() => {
|
|
232
|
+
const leaf = (product.value?.categoryTrail ?? []).at(-1);
|
|
233
|
+
if (leaf === undefined || !leaf.label) return null;
|
|
234
|
+
const href = safeHref(leaf.href);
|
|
235
|
+
return href === null ? null : { label: leaf.label, href };
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
/** Spec States, Minimal row: "With no reviews, the rating is hidden" — and the `showRating` field's
|
|
239
|
+
* own note, "Hidden anyway when the product has fewer than 3 reviews": an average over one or two
|
|
240
|
+
* opinions is noise, not information. */
|
|
241
|
+
const rating = computed(() => product.value?.rating ?? null);
|
|
242
|
+
const showRating = computed(
|
|
243
|
+
() => showRatingField.value && rating.value !== null && rating.value.count >= 3
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
/* ------------------------------------------------------------------------- */
|
|
247
|
+
/* Money */
|
|
248
|
+
/* ------------------------------------------------------------------------- */
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* `money.format` is for the two places a price has to appear *inside* another string — the Add to
|
|
252
|
+
* cart label and the quick-add bar's meta line — where a `<Price>` element cannot go; `money.minor`
|
|
253
|
+
* converts a storefront amount (major units) into the minor units `<Price>` itself reads. Both are
|
|
254
|
+
* bound to the same currency and locale the `<Price>` above the button resolves, so the two can
|
|
255
|
+
* never disagree about the formatting.
|
|
256
|
+
*/
|
|
257
|
+
const money = useMoney();
|
|
258
|
+
|
|
259
|
+
const formattedPrice = computed(() =>
|
|
260
|
+
product.value === null ? '' : money.format(product.value.price.amount)
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
/** Spec States, Sale row: 'The saving badge ("Save $32") is calculated from the two prices, never
|
|
264
|
+
* typed in.' Only a real sale counts — a `compareAt` at or below the current price is ignored, the
|
|
265
|
+
* same rule `Price`'s own sale state applies. */
|
|
266
|
+
const saving = computed<string | null>(() => {
|
|
267
|
+
const price = product.value?.price;
|
|
268
|
+
if (price === undefined) return null;
|
|
269
|
+
const compareAt = price.compareAt ?? null;
|
|
270
|
+
if (compareAt === null || compareAt <= price.amount) return null;
|
|
271
|
+
return money.format(roundMoney(compareAt - price.amount));
|
|
272
|
+
});
|
|
273
|
+
const onSale = computed(() => saving.value !== null);
|
|
274
|
+
|
|
275
|
+
/* ------------------------------------------------------------------------- */
|
|
276
|
+
/* Options and the selected variant */
|
|
277
|
+
/* ------------------------------------------------------------------------- */
|
|
278
|
+
|
|
279
|
+
const options = computed(() => product.value?.options ?? []);
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* **Which option's legend row the "Size guide" link sits beside — one row, ever.**
|
|
283
|
+
*
|
|
284
|
+
* Spec Layout, Pickers places the link "at the far end" of *the* legend row, singular. The gate used
|
|
285
|
+
* to be `option.type === 'pills'`, which is a property of the **control** rather than of the option,
|
|
286
|
+
* so every pills option got a link of its own: a product with Size and a `custom` "Fabric" option
|
|
287
|
+
* rendered two identical "Size guide" links. Naming the option is not available — a size option is
|
|
288
|
+
* whatever the merchant called it, in whatever language, which is the guess this whole feature
|
|
289
|
+
* removes — so the link goes to the **first** option drawn as pills, which is the size option on
|
|
290
|
+
* every ordinary product and a harmless single link on any other. A product whose options are all
|
|
291
|
+
* swatches gets none, exactly as before.
|
|
292
|
+
*
|
|
293
|
+
* A **position**, not a name: two options can share one (the module comment above says why that is a
|
|
294
|
+
* shape this block already tolerates), and matching on the name would put the link back on both.
|
|
295
|
+
* `-1` when nothing is drawn as pills, which no index equals.
|
|
296
|
+
*/
|
|
297
|
+
const sizeGuideOptionIndex = computed(() =>
|
|
298
|
+
options.value.findIndex((option) => option.type === 'pills')
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
/** One selected value per option, keyed by the option's own `name`. */
|
|
302
|
+
const selection = ref<Record<string, string>>({});
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Spec Do/Don't: "Don't pre-select a sold-out variant" — the default is the first *available* value,
|
|
306
|
+
* falling back to the first value only for an option with nothing available at all (which still
|
|
307
|
+
* needs a checked radio, so a shopper can ask to be notified). Re-seeded whenever the product
|
|
308
|
+
* changes, never on every render, so a shopper's own choice survives an unrelated re-render.
|
|
309
|
+
*/
|
|
310
|
+
watch(
|
|
311
|
+
options,
|
|
312
|
+
(next) => {
|
|
313
|
+
const seeded: Record<string, string> = {};
|
|
314
|
+
for (const option of next) {
|
|
315
|
+
const first = option.values.find((value) => value.available) ?? option.values[0];
|
|
316
|
+
if (first !== undefined) seeded[option.name] = first.value;
|
|
317
|
+
}
|
|
318
|
+
selection.value = seeded;
|
|
319
|
+
},
|
|
320
|
+
{ immediate: true }
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
const selectedValues = computed(() =>
|
|
324
|
+
options.value.map((option) =>
|
|
325
|
+
option.values.find((value) => value.value === selection.value[option.name])
|
|
326
|
+
)
|
|
327
|
+
);
|
|
328
|
+
/** "Oat / M" — what every stock message, the wishlist name and the quick-add bar read. */
|
|
329
|
+
const variantLabel = computed(() =>
|
|
330
|
+
selectedValues.value
|
|
331
|
+
.filter((value) => value !== undefined)
|
|
332
|
+
.map((value) => value!.label)
|
|
333
|
+
.join(' / ')
|
|
334
|
+
);
|
|
335
|
+
const variantAvailable = computed(() =>
|
|
336
|
+
selectedValues.value.every((value) => value === undefined || value.available)
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
/* ------------------------------------------------------------------------- */
|
|
340
|
+
/* Stock */
|
|
341
|
+
/* ------------------------------------------------------------------------- */
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* The cart refused an add for stock. The product read is the page's source of truth for stock
|
|
345
|
+
* (`gateway.ts` reads real inventory for it), but the cart service is the one that actually
|
|
346
|
+
* commits it: when the two disagree, the cart has just proved it knows something the read did not,
|
|
347
|
+
* and continuing to offer a button that cannot work is the worse of the two errors. So the page
|
|
348
|
+
* holds that one fact locally and shows the sold-out state the spec already defines — Notify me, the
|
|
349
|
+
* sold-out line, no stepper — rather than inventing a fifth state for it.
|
|
350
|
+
*
|
|
351
|
+
* Dropped as soon as anything fresher could contradict it: a product read that came back *different*
|
|
352
|
+
* — which is exactly what "the refresh said otherwise" means, since a refresh that changes nothing
|
|
353
|
+
* keeps every object at its own identity (`app/storefront/volatile.ts`) and has not contradicted
|
|
354
|
+
* anything — or another variant chosen, which is not the variant the backend refused.
|
|
355
|
+
*/
|
|
356
|
+
const refusedForStock = ref(false);
|
|
357
|
+
watch([() => productResult.data.value, variantLabel], () => {
|
|
358
|
+
refusedForStock.value = false;
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* `StorefrontProduct.inventory` is the theme's one inventory number (see `app/storefront/types.ts`):
|
|
363
|
+
* the count of the variant this page would sell, or `null` from a store that tracks no units — and
|
|
364
|
+
* also `null` whenever the source cannot say which variant a count belongs to, since "only 2 left in
|
|
365
|
+
* L" about M's two units is worse than no line at all. Either way `null` is what keeps "only N left"
|
|
366
|
+
* off a made-to-order product, and off a product whose count would be guesswork.
|
|
367
|
+
*/
|
|
368
|
+
const stockLine = computed(() =>
|
|
369
|
+
deriveStockLine({
|
|
370
|
+
stock: refusedForStock.value ? 'out' : (product.value?.stock ?? 'in'),
|
|
371
|
+
inventory: product.value?.inventory ?? null,
|
|
372
|
+
variantAvailable: variantAvailable.value,
|
|
373
|
+
variantLabel: variantLabel.value,
|
|
374
|
+
threshold: threshold.value,
|
|
375
|
+
shipsBy: product.value?.shipsBy ?? null,
|
|
376
|
+
})
|
|
377
|
+
);
|
|
378
|
+
const soldOut = computed(() => stockLine.value.state === 'out');
|
|
379
|
+
const isBackorder = computed(() => stockLine.value.state === 'backorder');
|
|
380
|
+
|
|
381
|
+
/** Spec States, Back-order row: `warning` with the clock icon. `StockBadge`'s own `preorder` level
|
|
382
|
+
* draws the clock in `muted` (it serves a quieter product-card context too), so the block asks for
|
|
383
|
+
* the spec's colour through the component's sanctioned per-part `classes`, never by patching it. */
|
|
384
|
+
const stockClasses = computed(() =>
|
|
385
|
+
isBackorder.value ? { root: 'text-warning font-semibold' } : { root: 'font-semibold' }
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
/* ------------------------------------------------------------------------- */
|
|
389
|
+
/* Quantity, cart, wishlist */
|
|
390
|
+
/* ------------------------------------------------------------------------- */
|
|
391
|
+
|
|
392
|
+
const quantity = ref(1);
|
|
393
|
+
/** Spec States, Low stock row: "The stepper maximum matches the inventory." A shopper who already
|
|
394
|
+
* typed 6 must not keep a quantity the store cannot fill after switching to a thinner variant. */
|
|
395
|
+
watch(
|
|
396
|
+
() => stockLine.value.max,
|
|
397
|
+
(max) => {
|
|
398
|
+
if (quantity.value > max) quantity.value = max;
|
|
399
|
+
}
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* The cart's own in-flight state, which is a *shopper's* — and therefore gated on mount (see
|
|
404
|
+
* `mounted` above). The cart store asks for whatever cart the browser already remembers as soon as
|
|
405
|
+
* it is created (`app/storefront/cart.ts`'s `init()`, from the storefront plugin's `setup`), so on
|
|
406
|
+
* a reload with a cart in `localStorage` `pending` is already `true` before the app hydrates —
|
|
407
|
+
* while the prerendered file, built with no browser and no cart, says it is not. Read straight
|
|
408
|
+
* through, that put `Button`'s `loading` treatment on the first client render of a page whose HTML
|
|
409
|
+
* has none of it: one "Hydration completed but contains mismatches" on every reload with a cart,
|
|
410
|
+
* and the buy bar re-rendered from scratch. The home page never showed it because the header's
|
|
411
|
+
* count is gated already and nothing else there reads the cart.
|
|
412
|
+
*
|
|
413
|
+
* It costs nothing: before mount there is no cart request a visitor could have started, so the
|
|
414
|
+
* gated value and the real one only ever differ on the render that must not use the real one.
|
|
415
|
+
*/
|
|
416
|
+
const cartBusy = computed(() => mounted.value && storefront.cart.pending.value);
|
|
417
|
+
|
|
418
|
+
const addToCartLabel = computed(() => {
|
|
419
|
+
if (soldOut.value) return t('product.notifyMe');
|
|
420
|
+
if (isBackorder.value) return t('product.backorder');
|
|
421
|
+
return t('product.addToCart', { price: formattedPrice.value });
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
/** The site's own wishlist page (`/wishlist`, seeded from `pages/wishlist.page.json`) — the same destination the header's
|
|
425
|
+
* heart has, and the only place a saved list can be looked at. */
|
|
426
|
+
const WISHLIST_PATH = '/wishlist';
|
|
427
|
+
/** The site's own cart page, for the toast that offers it when no drawer is hosted. */
|
|
428
|
+
const CART_PATH = '/cart';
|
|
429
|
+
/**
|
|
430
|
+
* Both toasts below hand `@eldrajs/ui`'s `Toast` a `{ label, href }` action, which it renders as a
|
|
431
|
+
* plain `<a href>` — no router, so no `EldraRouterLink` to put the active locale's prefix on it.
|
|
432
|
+
* These two are therefore prefixed here: a shopper saving a product on `/is-IS/products/x` must be
|
|
433
|
+
* offered `/is-IS/wishlist`, not the English list. `path()` is the identity on a single-locale
|
|
434
|
+
* site and in Storybook.
|
|
435
|
+
*/
|
|
436
|
+
const activeLocale = useEldraLocale();
|
|
437
|
+
|
|
438
|
+
const wishlisted = computed(() => (handle.value === null ? false : wishlist.has(handle.value)));
|
|
439
|
+
const wishlistLabel = computed(() => {
|
|
440
|
+
const title = product.value?.title ?? '';
|
|
441
|
+
return wishlisted.value
|
|
442
|
+
? t('product.removeFromWishlist', { title })
|
|
443
|
+
: t('product.saveToWishlist', { title });
|
|
444
|
+
});
|
|
445
|
+
/**
|
|
446
|
+
* Press the heart, and — either way — a sentence. The button's own `aria-pressed` flipping is the
|
|
447
|
+
* whole of the feedback a sighted mouse user gets otherwise, and it is a 20px outline icon in the
|
|
448
|
+
* corner of the buy box: the same "the button looks like it did nothing" problem the add-to-cart
|
|
449
|
+
* toast above exists for.
|
|
450
|
+
*
|
|
451
|
+
* A save offers the one thing a shopper might want next — the list itself — the way `cart.added`
|
|
452
|
+
* offers the cart. `/wishlist` is an ordinary link, not a drawer: there is no hosted wishlist
|
|
453
|
+
* drawer, and the page is prerendered, so it is the same destination the header's heart has. A
|
|
454
|
+
* removal offers nothing: the product just left the list, so there is nothing there to go and see,
|
|
455
|
+
* and pressing the heart again is already the undo.
|
|
456
|
+
*
|
|
457
|
+
* One `id` for both, like every other toast in this block: a shopper who presses the heart twice
|
|
458
|
+
* replaces the sentence in place instead of stacking two that contradict each other.
|
|
459
|
+
*/
|
|
460
|
+
function toggleWishlist(): void {
|
|
461
|
+
if (handle.value === null) return;
|
|
462
|
+
const saved = wishlist.toggle(handle.value);
|
|
463
|
+
toast.show({
|
|
464
|
+
id: WISHLIST_TOAST_ID,
|
|
465
|
+
title: saved ? t('wishlist.saved') : t('wishlist.removed'),
|
|
466
|
+
action: saved
|
|
467
|
+
? { label: t('wishlist.view'), href: activeLocale.path(WISHLIST_PATH) }
|
|
468
|
+
: undefined,
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
const addToCartEl = ref<HTMLElement | null>(null);
|
|
473
|
+
const addToCartTarget = ref<HTMLElement | null>(null);
|
|
474
|
+
/** `Button` is a component, so the sticky bar's observer needs the real element behind it — read
|
|
475
|
+
* from the wrapper this block owns rather than by reaching into the component's internals. */
|
|
476
|
+
watch(
|
|
477
|
+
[addToCartEl, addToCartLabel],
|
|
478
|
+
async () => {
|
|
479
|
+
await nextTick();
|
|
480
|
+
addToCartTarget.value = addToCartEl.value?.querySelector('button') ?? null;
|
|
481
|
+
},
|
|
482
|
+
{ immediate: true }
|
|
483
|
+
);
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Add to cart, and — either way — something the shopper can see. The button's own spinner stopping
|
|
487
|
+
* is not feedback: it looks identical whether the line was added or the gateway refused it, which is
|
|
488
|
+
* exactly how a 409 `CART_INSUFFICIENT_STOCK` became "Add to cart does nothing".
|
|
489
|
+
*
|
|
490
|
+
* **On success**, a toast — never the drawer. The design spec is explicit about this
|
|
491
|
+
* (`01-core-components.md` → "Drawer": "a Toast (not the drawer) to confirm 'Added to cart' unless
|
|
492
|
+
* the shopper asked to see the cart"), and the reason is the shopper's place on the page: they were
|
|
493
|
+
* reading a product, they pressed one button, and a modal `<dialog>` over everything takes their
|
|
494
|
+
* focus and their scroll position for a decision they did not ask to make. So the toast confirms it
|
|
495
|
+
* and *offers* the cart: its action opens the hosted drawer when one is live (`drawerAvailable` — the
|
|
496
|
+
* shopper asking to see the cart is exactly what the spec's exception is about), and is an ordinary
|
|
497
|
+
* link to `/cart` when none is, which is the same destination the header's bag has in that state.
|
|
498
|
+
*
|
|
499
|
+
* **On failure**, one shared toast through `useStorefrontFeedback()` (the sentence comes from the
|
|
500
|
+
* gateway's `errorId`, not from this block), plus the one reaction a page can usefully have: a
|
|
501
|
+
* refusal for stock flips its own stock line to sold out.
|
|
502
|
+
*/
|
|
503
|
+
async function primaryAction(): Promise<void> {
|
|
504
|
+
if (soldOut.value) {
|
|
505
|
+
notifyOpen.value = true;
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
const buyable = product.value;
|
|
509
|
+
// Both ids, because the backend resolves the pair (`app/storefront/cart.ts`'s `CartAddInput`). A
|
|
510
|
+
// product read that answered no buyable variant has nothing to add — `mapProductDetails` leaves
|
|
511
|
+
// `variantId` empty rather than inventing one from the product's own id.
|
|
512
|
+
if (buyable === null || buyable.variantId === '') return;
|
|
513
|
+
const cart = storefront.cart;
|
|
514
|
+
const failure = await cart.add({
|
|
515
|
+
productId: buyable.productId,
|
|
516
|
+
variantId: buyable.variantId,
|
|
517
|
+
quantity: quantity.value,
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
if (failure !== null) {
|
|
521
|
+
if (isOutOfStock(failure)) refusedForStock.value = true;
|
|
522
|
+
feedback.report(failure, { id: CART_ADD_TOAST_ID });
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
toast.show({
|
|
526
|
+
id: CART_ADD_TOAST_ID,
|
|
527
|
+
title: t('cart.added'),
|
|
528
|
+
action: cart.drawerAvailable.value
|
|
529
|
+
? {
|
|
530
|
+
label: t('cart.viewCart'),
|
|
531
|
+
onActivate: () => {
|
|
532
|
+
cart.drawerOpen.value = true;
|
|
533
|
+
},
|
|
534
|
+
}
|
|
535
|
+
: { label: t('cart.viewCart'), href: activeLocale.path(CART_PATH) },
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/* ------------------------------------------------------------------------- */
|
|
540
|
+
/* Back-in-stock dialog */
|
|
541
|
+
/* ------------------------------------------------------------------------- */
|
|
542
|
+
|
|
543
|
+
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
544
|
+
|
|
545
|
+
const notifyOpen = ref(false);
|
|
546
|
+
const notifyEmail = ref('');
|
|
547
|
+
const notifyError = ref<string | null>(null);
|
|
548
|
+
const notifySubmitting = ref(false);
|
|
549
|
+
const notifySucceeded = ref(false);
|
|
550
|
+
|
|
551
|
+
/** `FormLayout` refuses to emit `submit` while any field still carries `aria-invalid` (see its own
|
|
552
|
+
* doc comment), so the error clears as soon as the value changes rather than only on the next
|
|
553
|
+
* successful submit — the same shape the `newsletter` block documents. */
|
|
554
|
+
watch(notifyEmail, () => {
|
|
555
|
+
notifyError.value = null;
|
|
556
|
+
});
|
|
557
|
+
watch(notifyOpen, (open) => {
|
|
558
|
+
if (open) return;
|
|
559
|
+
notifyError.value = null;
|
|
560
|
+
notifySucceeded.value = false;
|
|
561
|
+
notifyEmail.value = '';
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
async function submitNotify(payload: FormLayoutSubmitPayload): Promise<void> {
|
|
565
|
+
payload.event.preventDefault();
|
|
566
|
+
if (notifySubmitting.value) return;
|
|
567
|
+
const email = String(payload.data.get('email') ?? '').trim();
|
|
568
|
+
if (!EMAIL_PATTERN.test(email)) {
|
|
569
|
+
notifyError.value = t('product.notifyInvalid');
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
const variantId = product.value?.variantId;
|
|
573
|
+
if (variantId === undefined || variantId === '') return;
|
|
574
|
+
notifySubmitting.value = true;
|
|
575
|
+
const ack = await storefront.catalog.notifyBackInStock({ email, variantId });
|
|
576
|
+
notifySubmitting.value = false;
|
|
577
|
+
if (ack.ok) {
|
|
578
|
+
notifySucceeded.value = true;
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
notifyError.value =
|
|
582
|
+
ack.reason === 'unsupported' ? t('product.notifyUnsupported') : t('product.notifyInvalid');
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/* ------------------------------------------------------------------------- */
|
|
586
|
+
/* Presentation */
|
|
587
|
+
/* ------------------------------------------------------------------------- */
|
|
588
|
+
|
|
589
|
+
/** Spec Container/Section line: 1rem top below 48rem block width, 2rem from 48rem, `section-md`
|
|
590
|
+
* bottom — `Section`'s own `spacing` steps are symmetrical, so the block sets its own halves
|
|
591
|
+
* through the sanctioned `classes` prop. */
|
|
592
|
+
const SECTION_SPACING = 'pt-4 @tablet:pt-8 pb-[var(--eldra-section-md)]';
|
|
593
|
+
|
|
594
|
+
/** Spec Layout: the `h1` is "styled at the h2 scale" — 1.625rem, stepping up to the `text-h2`
|
|
595
|
+
* token's own 2rem from 64rem. */
|
|
596
|
+
const TITLE_CLASS =
|
|
597
|
+
'font-heading text-[1.625rem] leading-[1.15] font-bold tracking-[-0.015em] text-balance ' +
|
|
598
|
+
'@content:text-h2';
|
|
599
|
+
|
|
600
|
+
const quantityStepperClasses = { decrease: 'size-12', increase: 'size-12', input: 'h-12' };
|
|
601
|
+
|
|
602
|
+
const tabsRoot = ref<HTMLElement | null>(null);
|
|
603
|
+
useRichTextScrollRegions(tabsRoot, (caption) => caption ?? t('product.tabsLabel'));
|
|
604
|
+
|
|
605
|
+
function tabValue(index: number): string {
|
|
606
|
+
return String(index);
|
|
607
|
+
}
|
|
608
|
+
</script>
|
|
609
|
+
|
|
610
|
+
<template>
|
|
611
|
+
<Section
|
|
612
|
+
v-if="product"
|
|
613
|
+
spacing="none"
|
|
614
|
+
:labelled-by="titleId"
|
|
615
|
+
:aria-busy="refreshing ? 'true' : undefined"
|
|
616
|
+
:classes="{ root: SECTION_SPACING }"
|
|
617
|
+
>
|
|
618
|
+
<Container width="content">
|
|
619
|
+
<div
|
|
620
|
+
class="@tablet:grid-cols-[7fr_5fr] @tablet:items-start @tablet:gap-8 @content:gap-12 grid gap-6"
|
|
621
|
+
>
|
|
622
|
+
<!-- Gallery first in the DOM in both variants; only the order utilities mirror. -->
|
|
623
|
+
<Gallery
|
|
624
|
+
class="@tablet:sticky @tablet:top-6"
|
|
625
|
+
:class="galleryRight ? '@tablet:order-2' : '@tablet:order-1'"
|
|
626
|
+
:images="product.images"
|
|
627
|
+
:title="product.title"
|
|
628
|
+
:on-sale="onSale"
|
|
629
|
+
/>
|
|
630
|
+
|
|
631
|
+
<div
|
|
632
|
+
role="group"
|
|
633
|
+
:aria-label="t('product.information')"
|
|
634
|
+
class="flex flex-col gap-6"
|
|
635
|
+
:class="galleryRight ? '@tablet:order-1' : '@tablet:order-2'"
|
|
636
|
+
>
|
|
637
|
+
<div class="flex flex-col gap-2">
|
|
638
|
+
<!--
|
|
639
|
+
One label, not a trail, and deliberately not a `<nav>`: a second landmark named
|
|
640
|
+
"Breadcrumb" beside the `breadcrumbs` block's own is the duplication this used to
|
|
641
|
+
ship (see `categoryLeaf`). It stays a link because the destination is useful — the
|
|
642
|
+
catalogue filtered by that category — and `p` rather than a bare `Link` so the line
|
|
643
|
+
keeps its own type size whatever the link's tone does.
|
|
644
|
+
-->
|
|
645
|
+
<p v-if="showCategory && categoryLeaf !== null" class="text-[0.875rem]">
|
|
646
|
+
<Link :href="categoryLeaf.href" :as="EldraRouterLink" tone="muted">
|
|
647
|
+
{{ categoryLeaf.label }}
|
|
648
|
+
</Link>
|
|
649
|
+
</p>
|
|
650
|
+
|
|
651
|
+
<h1 :id="titleId" :class="TITLE_CLASS">{{ product.title }}</h1>
|
|
652
|
+
|
|
653
|
+
<div class="mt-2 flex flex-wrap items-center gap-x-4 gap-y-2">
|
|
654
|
+
<Price
|
|
655
|
+
:amount="money.minor(product.price.amount)"
|
|
656
|
+
:compare-at="
|
|
657
|
+
product.price.compareAt == null ? null : money.minor(product.price.compareAt)
|
|
658
|
+
"
|
|
659
|
+
:revalidating="priceRevalidating"
|
|
660
|
+
/>
|
|
661
|
+
<Badge
|
|
662
|
+
v-if="saving"
|
|
663
|
+
variant="sale"
|
|
664
|
+
:label="t('product.saving', { amount: saving })"
|
|
665
|
+
/>
|
|
666
|
+
<Rating
|
|
667
|
+
v-if="showRating && rating"
|
|
668
|
+
:value="rating.value"
|
|
669
|
+
:count="rating.count"
|
|
670
|
+
href="#reviews"
|
|
671
|
+
:as="EldraRouterLink"
|
|
672
|
+
/>
|
|
673
|
+
</div>
|
|
674
|
+
|
|
675
|
+
<p class="text-muted text-[0.875rem]">{{ t('product.taxNote') }}</p>
|
|
676
|
+
</div>
|
|
677
|
+
|
|
678
|
+
<hr class="border-border" />
|
|
679
|
+
|
|
680
|
+
<form class="flex flex-col gap-5" @submit.prevent="primaryAction">
|
|
681
|
+
<!--
|
|
682
|
+
Spec Layout, Pickers: the size-guide link sits "at the far end" of the legend row.
|
|
683
|
+
`VariantPicker` draws its own legend and has no slot beside it, so the link is a
|
|
684
|
+
sibling in a two-column row aligned to the fieldset's top edge — `items-start`, not
|
|
685
|
+
`items-baseline`: a `<legend>`'s line box is rendered specially and does not give the
|
|
686
|
+
fieldset a first baseline, so baseline alignment drops the link down to the options
|
|
687
|
+
row instead of the legend's.
|
|
688
|
+
-->
|
|
689
|
+
<!--
|
|
690
|
+
`data-option-kind` (and `data-option-metadata` for a `custom` option) is how a theme
|
|
691
|
+
branches on the merchant's display choice without forking this block: the kind decides
|
|
692
|
+
the control through `option.type` already (`color` → swatches, everything else →
|
|
693
|
+
pills), and a customer who wants their one named option rendered its own way has a
|
|
694
|
+
stable hook for it that is not the option's label — see `docs/starter-kit.md`. The
|
|
695
|
+
attributes are on the row rather than the picker so a replacement control inside it is
|
|
696
|
+
covered too.
|
|
697
|
+
-->
|
|
698
|
+
<div
|
|
699
|
+
v-for="(option, optionIndex) in options"
|
|
700
|
+
:key="option.name"
|
|
701
|
+
class="grid grid-cols-[1fr_auto] items-start gap-x-4"
|
|
702
|
+
:data-option-kind="option.kind"
|
|
703
|
+
:data-option-metadata="option.metadata"
|
|
704
|
+
>
|
|
705
|
+
<VariantPicker
|
|
706
|
+
v-model="selection[option.name]"
|
|
707
|
+
:name="`${option.name}-${instanceId}`"
|
|
708
|
+
:legend="option.label"
|
|
709
|
+
:type="option.type"
|
|
710
|
+
:options="option.values"
|
|
711
|
+
/>
|
|
712
|
+
<Link
|
|
713
|
+
v-if="optionIndex === sizeGuideOptionIndex && sizeGuideHref"
|
|
714
|
+
:href="sizeGuideHref"
|
|
715
|
+
:as="sizeGuideAs"
|
|
716
|
+
tone="muted"
|
|
717
|
+
class="justify-self-end text-[0.875rem]"
|
|
718
|
+
>
|
|
719
|
+
{{ sizeGuideLabel }}
|
|
720
|
+
</Link>
|
|
721
|
+
</div>
|
|
722
|
+
|
|
723
|
+
<!-- Always mounted, so a variant change is announced rather than appearing silently. -->
|
|
724
|
+
<p role="status" aria-live="polite">
|
|
725
|
+
<StockBadge
|
|
726
|
+
:level="stockLine.level"
|
|
727
|
+
:message="t(stockLine.key, stockLine.params)"
|
|
728
|
+
:revalidating="stockRevalidating"
|
|
729
|
+
:classes="stockClasses"
|
|
730
|
+
/>
|
|
731
|
+
<span v-if="stockLine.noteKey" class="text-muted mt-1 block pl-6 text-[0.875rem]">{{
|
|
732
|
+
t(stockLine.noteKey)
|
|
733
|
+
}}</span>
|
|
734
|
+
</p>
|
|
735
|
+
|
|
736
|
+
<FieldWrapper
|
|
737
|
+
v-if="showQuantity && !soldOut"
|
|
738
|
+
:label="t('product.quantity')"
|
|
739
|
+
:classes="{ root: 'gap-2' }"
|
|
740
|
+
>
|
|
741
|
+
<QuantityStepper
|
|
742
|
+
v-model="quantity"
|
|
743
|
+
name="quantity"
|
|
744
|
+
:max="stockLine.max"
|
|
745
|
+
:classes="quantityStepperClasses"
|
|
746
|
+
/>
|
|
747
|
+
</FieldWrapper>
|
|
748
|
+
|
|
749
|
+
<div class="grid grid-cols-[1fr_auto] items-center gap-3">
|
|
750
|
+
<div ref="addToCartEl" class="contents">
|
|
751
|
+
<Button
|
|
752
|
+
type="submit"
|
|
753
|
+
variant="primary"
|
|
754
|
+
size="lg"
|
|
755
|
+
block
|
|
756
|
+
:loading="cartBusy"
|
|
757
|
+
:label="addToCartLabel"
|
|
758
|
+
>
|
|
759
|
+
<template v-if="soldOut" #leadingIcon>
|
|
760
|
+
<EldraIcon name="mail" size="md" />
|
|
761
|
+
</template>
|
|
762
|
+
{{ addToCartLabel }}
|
|
763
|
+
</Button>
|
|
764
|
+
</div>
|
|
765
|
+
<Button
|
|
766
|
+
v-if="showWishlist"
|
|
767
|
+
type="button"
|
|
768
|
+
icon-only
|
|
769
|
+
variant="outline"
|
|
770
|
+
size="lg"
|
|
771
|
+
:pressed="wishlisted"
|
|
772
|
+
:label="wishlistLabel"
|
|
773
|
+
@click="toggleWishlist"
|
|
774
|
+
>
|
|
775
|
+
<template #leadingIcon>
|
|
776
|
+
<EldraIcon name="heart" size="md" />
|
|
777
|
+
</template>
|
|
778
|
+
</Button>
|
|
779
|
+
</div>
|
|
780
|
+
</form>
|
|
781
|
+
|
|
782
|
+
<ul
|
|
783
|
+
v-if="perks.length > 0"
|
|
784
|
+
role="list"
|
|
785
|
+
class="bg-surface flex flex-col gap-3 rounded-lg p-4"
|
|
786
|
+
>
|
|
787
|
+
<li v-for="(perk, index) in perks" :key="index" class="flex gap-3 text-[0.875rem]">
|
|
788
|
+
<EldraIcon v-if="perk.icon" :name="perk.icon" size="md" class="text-text shrink-0" />
|
|
789
|
+
<div class="min-w-0">
|
|
790
|
+
<p class="font-semibold">{{ perk.title }}</p>
|
|
791
|
+
<p v-if="perk.text" class="text-muted">{{ perk.text }}</p>
|
|
792
|
+
</div>
|
|
793
|
+
</li>
|
|
794
|
+
</ul>
|
|
795
|
+
|
|
796
|
+
<div v-if="tabs.length > 0" ref="tabsRoot">
|
|
797
|
+
<Tabs variant="underline" :ariaLabel="t('product.tabsLabel')">
|
|
798
|
+
<template #tabs>
|
|
799
|
+
<Tab
|
|
800
|
+
v-for="(tab, index) in tabs"
|
|
801
|
+
:key="index"
|
|
802
|
+
:value="tabValue(index)"
|
|
803
|
+
:title="tab.label"
|
|
804
|
+
/>
|
|
805
|
+
</template>
|
|
806
|
+
<TabPanel v-for="(tab, index) in tabs" :key="index" :value="tabValue(index)">
|
|
807
|
+
<!-- A `Tab` label is a button, not a heading, so the nearest heading above a
|
|
808
|
+
panel is this block's own `h1` (the product title) — the panel body's headings
|
|
809
|
+
therefore start at `h2`. Floored at 2 rather than 3 on purpose: with no `h2`
|
|
810
|
+
in between, an `h3` straight after the `h1` would be a level skip. -->
|
|
811
|
+
<EldraRichText
|
|
812
|
+
class="prose-eldra [&>*+*]:mt-3"
|
|
813
|
+
:entry-id="entryId"
|
|
814
|
+
:field="`tabs.${index}.body`"
|
|
815
|
+
:doc="tab.body"
|
|
816
|
+
:min-heading-level="2"
|
|
817
|
+
/>
|
|
818
|
+
</TabPanel>
|
|
819
|
+
</Tabs>
|
|
820
|
+
</div>
|
|
821
|
+
</div>
|
|
822
|
+
</div>
|
|
823
|
+
|
|
824
|
+
<StickyBuyBar
|
|
825
|
+
v-if="stickyBarEnabled"
|
|
826
|
+
:target="addToCartTarget"
|
|
827
|
+
:title="product.title"
|
|
828
|
+
:meta="
|
|
829
|
+
variantLabel
|
|
830
|
+
? t('product.quickAddMeta', { variant: variantLabel, price: formattedPrice })
|
|
831
|
+
: formattedPrice
|
|
832
|
+
"
|
|
833
|
+
:action-label="addToCartLabel"
|
|
834
|
+
:image="product.images[0] ?? null"
|
|
835
|
+
:pending="cartBusy"
|
|
836
|
+
@add="primaryAction"
|
|
837
|
+
/>
|
|
838
|
+
|
|
839
|
+
<Dialog v-model="notifyOpen" :title="t('product.notifyTitle')" size="sm">
|
|
840
|
+
<!-- Mounted before the sign-up is sent, and empty until there is something to say, so the
|
|
841
|
+
confirmation is announced when it lands rather than appearing silently (4.1.3). -->
|
|
842
|
+
<div role="status">
|
|
843
|
+
<p v-if="notifySucceeded" class="text-text">{{ t('product.notifySuccess') }}</p>
|
|
844
|
+
</div>
|
|
845
|
+
<FormLayout
|
|
846
|
+
v-if="!notifySucceeded"
|
|
847
|
+
novalidate
|
|
848
|
+
:submitting="notifySubmitting"
|
|
849
|
+
@submit="submitNotify"
|
|
850
|
+
>
|
|
851
|
+
<FieldWrapper :label="t('product.notifyEmail')" :error="notifyError ?? undefined">
|
|
852
|
+
<Input v-model="notifyEmail" type="email" name="email" autocomplete="email" required />
|
|
853
|
+
</FieldWrapper>
|
|
854
|
+
<template #actions>
|
|
855
|
+
<Button type="submit" variant="primary" :label="t('product.notifySubmit')">
|
|
856
|
+
{{ t('product.notifySubmit') }}
|
|
857
|
+
</Button>
|
|
858
|
+
</template>
|
|
859
|
+
</FormLayout>
|
|
860
|
+
</Dialog>
|
|
861
|
+
</Container>
|
|
862
|
+
</Section>
|
|
863
|
+
|
|
864
|
+
<Section v-else-if="showStatus" spacing="none" :classes="{ root: SECTION_SPACING }">
|
|
865
|
+
<Container width="content">
|
|
866
|
+
<p role="status" class="text-muted">
|
|
867
|
+
{{ productResult.error.value ? t('storefront.error') : t('storefront.loading') }}
|
|
868
|
+
</p>
|
|
869
|
+
</Container>
|
|
870
|
+
</Section>
|
|
871
|
+
|
|
872
|
+
<!-- The read answered, and the answer was "there is no such product". Said plainly, before the
|
|
873
|
+
editor hint below, because on a live page this is what a visitor who followed an old link
|
|
874
|
+
sees and the hint is not for them. -->
|
|
875
|
+
<Section v-else-if="notFound" spacing="none" :classes="{ root: SECTION_SPACING }">
|
|
876
|
+
<Container width="content">
|
|
877
|
+
<p role="status" class="text-muted">{{ t('storefront.notFound') }}</p>
|
|
878
|
+
</Container>
|
|
879
|
+
</Section>
|
|
880
|
+
|
|
881
|
+
<EditorPlaceholder
|
|
882
|
+
v-else-if="editing"
|
|
883
|
+
:label="t('product.hintLabel')"
|
|
884
|
+
:help="t('product.hintHelp')"
|
|
885
|
+
/>
|
|
886
|
+
</template>
|