@eldrajs/theme-cli 0.0.0 → 0.1.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 +69 -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-C6jB8_Oc.js +510 -0
- package/package.json +50 -2
- package/template/.eldra/block-types.d.ts +429 -0
- package/template/.eldra/manifest.json +9377 -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 +52 -0
- package/template/.storybook/shims-vue.d.ts +10 -0
- package/template/.storybook/virtual-eldra.d.ts +27 -0
- package/template/README.md +288 -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 +247 -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 +1495 -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 +148 -0
- package/template/package.json +55 -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/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/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 +334 -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 +89 -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 +393 -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 +161 -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 +171 -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 +46 -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,181 @@
|
|
|
1
|
+
{
|
|
2
|
+
"apiId": "article-list",
|
|
3
|
+
"name": "Article list",
|
|
4
|
+
"description": "A list of journal stories as a card grid, a featured-first layout or thumbnail rows, with optional category chips and pagination.",
|
|
5
|
+
"icon": "news",
|
|
6
|
+
"category": "content",
|
|
7
|
+
"version": 1,
|
|
8
|
+
"fields": [
|
|
9
|
+
{
|
|
10
|
+
"fieldId": "variant",
|
|
11
|
+
"name": "Variant",
|
|
12
|
+
"type": "select",
|
|
13
|
+
"helpText": "grid is the default.",
|
|
14
|
+
"metadata": { "options": ["grid", "featured-first", "list"] },
|
|
15
|
+
"validators": { "required": true }
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"fieldId": "heading",
|
|
19
|
+
"name": "Heading",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"isTitle": true,
|
|
22
|
+
"localized": true,
|
|
23
|
+
"helpText": "\"From the journal\" is the default. Optional."
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"fieldId": "viewAllLabel",
|
|
27
|
+
"name": "View all label",
|
|
28
|
+
"type": "string",
|
|
29
|
+
"localized": true,
|
|
30
|
+
"helpText": "For example \"View all stories\". Placed in the block head."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"fieldId": "viewAllHref",
|
|
34
|
+
"name": "View all URL",
|
|
35
|
+
"type": "string",
|
|
36
|
+
"helpText": "The journal index."
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"fieldId": "source",
|
|
40
|
+
"name": "Source",
|
|
41
|
+
"type": "select",
|
|
42
|
+
"helpText": "The starter has no journal query of its own, so every mode renders the items below; this only documents intent for a later data source.",
|
|
43
|
+
"metadata": { "options": ["latest", "category", "manual"] },
|
|
44
|
+
"validators": { "required": true }
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"fieldId": "categoryHref",
|
|
48
|
+
"name": "Category URL",
|
|
49
|
+
"type": "string",
|
|
50
|
+
"helpText": "Used when source is category. Also matched against each chip to mark the active one."
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"fieldId": "items",
|
|
54
|
+
"name": "Items",
|
|
55
|
+
"type": "list",
|
|
56
|
+
"helpText": "1-12 stories. Used when source is manual.",
|
|
57
|
+
"metadata": {
|
|
58
|
+
"item": {
|
|
59
|
+
"fieldId": "item",
|
|
60
|
+
"name": "Story",
|
|
61
|
+
"type": "composite",
|
|
62
|
+
"metadata": {
|
|
63
|
+
"fields": [
|
|
64
|
+
{
|
|
65
|
+
"fieldId": "title",
|
|
66
|
+
"name": "Title",
|
|
67
|
+
"type": "string",
|
|
68
|
+
"localized": true,
|
|
69
|
+
"validators": { "required": true }
|
|
70
|
+
},
|
|
71
|
+
{ "fieldId": "dek", "name": "Dek", "type": "text", "localized": true },
|
|
72
|
+
{
|
|
73
|
+
"fieldId": "href",
|
|
74
|
+
"name": "Link URL",
|
|
75
|
+
"type": "string",
|
|
76
|
+
"validators": { "required": true }
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"fieldId": "categoryLabel",
|
|
80
|
+
"name": "Category label",
|
|
81
|
+
"type": "string",
|
|
82
|
+
"localized": true
|
|
83
|
+
},
|
|
84
|
+
{ "fieldId": "categoryHref", "name": "Category URL", "type": "string" },
|
|
85
|
+
{
|
|
86
|
+
"fieldId": "publishedAt",
|
|
87
|
+
"name": "Published at",
|
|
88
|
+
"type": "datetime",
|
|
89
|
+
"helpText": "Rendered in a <time datetime>."
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"fieldId": "readingTime",
|
|
93
|
+
"name": "Reading time",
|
|
94
|
+
"type": "string",
|
|
95
|
+
"localized": true,
|
|
96
|
+
"helpText": "For example \"6 min read\"."
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"fieldId": "image",
|
|
100
|
+
"name": "Image",
|
|
101
|
+
"type": "media",
|
|
102
|
+
"helpText": "3:2 crop, taken from the top. Decorative; the title carries the meaning.",
|
|
103
|
+
"metadata": { "multiple": false }
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"fieldId": "perPage",
|
|
112
|
+
"name": "Per page",
|
|
113
|
+
"type": "select",
|
|
114
|
+
"helpText": "6 is the default. For featured-first, choose 4, 7 or 10 so the rows fill.",
|
|
115
|
+
"metadata": { "options": ["3", "6", "9", "12"] }
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"fieldId": "showFilters",
|
|
119
|
+
"name": "Show filters",
|
|
120
|
+
"type": "bool",
|
|
121
|
+
"helpText": "Category chips built from the categories that have stories."
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"fieldId": "filters",
|
|
125
|
+
"name": "Filters",
|
|
126
|
+
"type": "list",
|
|
127
|
+
"helpText": "The theme's stand-in for derived category chips.",
|
|
128
|
+
"metadata": {
|
|
129
|
+
"item": {
|
|
130
|
+
"fieldId": "item",
|
|
131
|
+
"name": "Filter",
|
|
132
|
+
"type": "composite",
|
|
133
|
+
"metadata": {
|
|
134
|
+
"fields": [
|
|
135
|
+
{
|
|
136
|
+
"fieldId": "label",
|
|
137
|
+
"name": "Label",
|
|
138
|
+
"type": "string",
|
|
139
|
+
"localized": true,
|
|
140
|
+
"validators": { "required": true }
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"fieldId": "href",
|
|
144
|
+
"name": "Link URL",
|
|
145
|
+
"type": "string",
|
|
146
|
+
"validators": { "required": true }
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"fieldId": "showPagination",
|
|
155
|
+
"name": "Show pagination",
|
|
156
|
+
"type": "bool",
|
|
157
|
+
"helpText": "True on the journal index, false in a homepage teaser — link to the journal with the view-all link instead."
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"fieldId": "showExcerpt",
|
|
161
|
+
"name": "Show excerpt",
|
|
162
|
+
"type": "bool",
|
|
163
|
+
"default": true,
|
|
164
|
+
"helpText": "In the list variant, excerpts are always hidden below 48rem of block width."
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"fieldId": "emptyTitle",
|
|
168
|
+
"name": "Empty title",
|
|
169
|
+
"type": "string",
|
|
170
|
+
"localized": true,
|
|
171
|
+
"helpText": "\"No stories yet\" is the default."
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"fieldId": "emptyText",
|
|
175
|
+
"name": "Empty text",
|
|
176
|
+
"type": "text",
|
|
177
|
+
"localized": true,
|
|
178
|
+
"helpText": "\"Browse every story from the journal.\" is the default."
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"variant": "grid",
|
|
3
|
+
"heading": "From the journal",
|
|
4
|
+
"viewAllLabel": "View all stories",
|
|
5
|
+
"viewAllHref": "",
|
|
6
|
+
"source": "manual",
|
|
7
|
+
"perPage": "6",
|
|
8
|
+
"showFilters": true,
|
|
9
|
+
"filters": [
|
|
10
|
+
{ "label": "All", "href": "/journal" },
|
|
11
|
+
{ "label": "Ceramics", "href": "/journal/ceramics" },
|
|
12
|
+
{ "label": "Care", "href": "/journal/care" },
|
|
13
|
+
{ "label": "Recipes", "href": "/journal/recipes" },
|
|
14
|
+
{ "label": "Makers", "href": "/journal/makers" },
|
|
15
|
+
{ "label": "Home", "href": "/journal/home" }
|
|
16
|
+
],
|
|
17
|
+
"showPagination": true,
|
|
18
|
+
"showExcerpt": true,
|
|
19
|
+
"emptyTitle": "No stories yet",
|
|
20
|
+
"emptyText": "Our kitchen team is testing a few. Until then, browse every story from the journal.",
|
|
21
|
+
"items": [
|
|
22
|
+
{
|
|
23
|
+
"title": "How we glaze our stoneware",
|
|
24
|
+
"dek": "Two firings, three pairs of hands and a kiln that always has the last word. A morning in the Portland studio.",
|
|
25
|
+
"href": "/journal/how-we-glaze-our-stoneware",
|
|
26
|
+
"categoryLabel": "Ceramics",
|
|
27
|
+
"categoryHref": "",
|
|
28
|
+
"publishedAt": "2026-09-18",
|
|
29
|
+
"readingTime": "6 min read"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"title": "Caring for merino: a winter guide",
|
|
33
|
+
"dek": "Wash less, air more. How to keep a knit soft and shape-true for a decade, pills and all.",
|
|
34
|
+
"href": "/journal/caring-for-merino",
|
|
35
|
+
"categoryLabel": "Care",
|
|
36
|
+
"categoryHref": "",
|
|
37
|
+
"publishedAt": "2026-09-09",
|
|
38
|
+
"readingTime": "4 min read"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"title": "Five-minute brown butter oats",
|
|
42
|
+
"dek": "Our kitchen team's weekday breakfast, made in one Everyday saucepan with whatever fruit is in the bowl.",
|
|
43
|
+
"href": "/journal/brown-butter-oats",
|
|
44
|
+
"categoryLabel": "Recipes",
|
|
45
|
+
"categoryHref": "",
|
|
46
|
+
"publishedAt": "2026-08-28",
|
|
47
|
+
"readingTime": "3 min read"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"title": "Inside the Porto linen mill",
|
|
51
|
+
"dek": "Three generations, one loom room and the reason our tea towels soften with every wash.",
|
|
52
|
+
"href": "/journal/porto-linen-mill",
|
|
53
|
+
"categoryLabel": "Makers",
|
|
54
|
+
"categoryHref": "",
|
|
55
|
+
"publishedAt": "2026-08-14",
|
|
56
|
+
"readingTime": "7 min read"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"title": "Setting a slow table for six",
|
|
60
|
+
"dek": "Mismatched plates, one good candle and a menu you can make the day before.",
|
|
61
|
+
"href": "/journal/slow-table-for-six",
|
|
62
|
+
"categoryLabel": "Home",
|
|
63
|
+
"categoryHref": "",
|
|
64
|
+
"publishedAt": "2026-07-30",
|
|
65
|
+
"readingTime": "5 min read"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"items": [
|
|
3
|
+
{
|
|
4
|
+
"title": "How we glaze our stoneware",
|
|
5
|
+
"dek": "Two firings, three pairs of hands and a kiln that always has the last word. A morning in the Portland studio.",
|
|
6
|
+
"href": "/journal/how-we-glaze-our-stoneware",
|
|
7
|
+
"categoryLabel": "Ceramics",
|
|
8
|
+
"categoryHref": "/journal/ceramics",
|
|
9
|
+
"publishedAt": "2026-09-18",
|
|
10
|
+
"readingTime": "6 min read",
|
|
11
|
+
"image": {
|
|
12
|
+
"assetId": "demo-gallery-1",
|
|
13
|
+
"url": "/demo/gallery-1.svg",
|
|
14
|
+
"altText": "",
|
|
15
|
+
"width": 1600,
|
|
16
|
+
"height": 1000
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"title": "Caring for merino: a winter guide",
|
|
21
|
+
"dek": "Wash less, air more. How to keep a knit soft and shape-true for a decade, pills and all.",
|
|
22
|
+
"href": "/journal/caring-for-merino",
|
|
23
|
+
"categoryLabel": "Care",
|
|
24
|
+
"categoryHref": "/journal/care",
|
|
25
|
+
"publishedAt": "2026-09-09",
|
|
26
|
+
"readingTime": "4 min read",
|
|
27
|
+
"image": {
|
|
28
|
+
"assetId": "demo-gallery-2",
|
|
29
|
+
"url": "/demo/gallery-2.svg",
|
|
30
|
+
"altText": "",
|
|
31
|
+
"width": 1600,
|
|
32
|
+
"height": 1000
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"title": "Five-minute brown butter oats",
|
|
37
|
+
"dek": "Our kitchen team's weekday breakfast, made in one Everyday saucepan with whatever fruit is in the bowl.",
|
|
38
|
+
"href": "/journal/brown-butter-oats",
|
|
39
|
+
"categoryLabel": "Recipes",
|
|
40
|
+
"categoryHref": "/journal/recipes",
|
|
41
|
+
"publishedAt": "2026-08-28",
|
|
42
|
+
"readingTime": "3 min read",
|
|
43
|
+
"image": {
|
|
44
|
+
"assetId": "demo-gallery-3",
|
|
45
|
+
"url": "/demo/gallery-3.svg",
|
|
46
|
+
"altText": "",
|
|
47
|
+
"width": 1600,
|
|
48
|
+
"height": 1000
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"title": "Inside the Porto linen mill",
|
|
53
|
+
"dek": "Three generations, one loom room and the reason our tea towels soften with every wash.",
|
|
54
|
+
"href": "/journal/porto-linen-mill",
|
|
55
|
+
"categoryLabel": "Makers",
|
|
56
|
+
"categoryHref": "/journal/makers",
|
|
57
|
+
"publishedAt": "2026-08-14",
|
|
58
|
+
"readingTime": "7 min read",
|
|
59
|
+
"image": {
|
|
60
|
+
"assetId": "demo-gallery-4",
|
|
61
|
+
"url": "/demo/gallery-4.svg",
|
|
62
|
+
"altText": "",
|
|
63
|
+
"width": 1600,
|
|
64
|
+
"height": 1000
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"title": "Setting a slow table for six",
|
|
69
|
+
"dek": "Mismatched plates, one good candle and a menu you can make the day before.",
|
|
70
|
+
"href": "/journal/slow-table-for-six",
|
|
71
|
+
"categoryLabel": "Home",
|
|
72
|
+
"categoryHref": "/journal/home",
|
|
73
|
+
"publishedAt": "2026-07-30",
|
|
74
|
+
"readingTime": "5 min read",
|
|
75
|
+
"image": {
|
|
76
|
+
"assetId": "demo-gallery-5",
|
|
77
|
+
"url": "/demo/gallery-5.svg",
|
|
78
|
+
"altText": "",
|
|
79
|
+
"width": 1600,
|
|
80
|
+
"height": 1000
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Breadcrumbs · a trail from Home to the current page, wrapping `@eldrajs/ui`'s `Breadcrumb`.
|
|
4
|
+
*
|
|
5
|
+
* The design spec (`02-blocks.md` "Breadcrumbs") builds the trail from the page tree, but a block
|
|
6
|
+
* cannot read the route (no Nuxt globals here, and `useEldraPage()` is page-level, not
|
|
7
|
+
* block-level — see `block.json`'s own `description`). `trail` is this theme's stand-in: a flat
|
|
8
|
+
* list of `{label, href}` levels the page
|
|
9
|
+
* author fills by hand, root first, with `currentTitle` standing in for "the page title" the spec
|
|
10
|
+
* assumes is always available.
|
|
11
|
+
*
|
|
12
|
+
* **`fromProduct` is the one level this block can fill by itself**: on a product page, the store's
|
|
13
|
+
* own category trail for the product the route resolved — root category down to the product's own,
|
|
14
|
+
* each level a link into the catalogue filtered by it
|
|
15
|
+
* (`app/storefront/categories.ts`). It exists because the seeded product
|
|
16
|
+
* *template* has no authored `trail` and cannot have one: a template renders whatever product its
|
|
17
|
+
* `:slug` matched, so `app/templates.ts` empties the list, and the breadcrumbs on a merchant's first
|
|
18
|
+
* product page were the Home crumb alone — one item, which is fewer than two, which is nothing.
|
|
19
|
+
*
|
|
20
|
+
* It reads `storefront.catalog.product()` for the route's own handle, which is the **same result**
|
|
21
|
+
* `product-detail` on the same page creates: identical method, identical sources, therefore an
|
|
22
|
+
* identical prerender key, so Nuxt's `useAsyncData` answers both from one read and the trail rides
|
|
23
|
+
* to the browser in the page payload with the rest of the product. Nothing is fetched when the
|
|
24
|
+
* option is off or the route names no product (the source is `null`, which makes no request).
|
|
25
|
+
*
|
|
26
|
+
* **`fromCategory` is the other one**, on a *category* page: the levels above the category the route
|
|
27
|
+
* resolved, each linking to its own page, and the category's own name as the last crumb when the
|
|
28
|
+
* page set no `currentTitle` of its own. The two never both fire — a route resolves a product or a
|
|
29
|
+
* category, never both.
|
|
30
|
+
*
|
|
31
|
+
* Resolved item order: `homeLabel` (when `showHome`) → `trail`, in order → the product's category
|
|
32
|
+
* trail (when `fromProduct`) → the category's own ancestors (when `fromCategory`) → `currentTitle`,
|
|
33
|
+
* or the category's name (when `showCurrent` and either is non-empty). The authored levels
|
|
34
|
+
* come first because they are the page-tree levels *above* the catalogue, while a category is the
|
|
35
|
+
* level nearest the product. Spec "Empty (freshly inserted)" row: on a top-level page (empty
|
|
36
|
+
* `trail`, no `currentTitle`) there is nothing to show a trail *between*, so with fewer than two
|
|
37
|
+
* resolved items nothing renders live at all — only the editor sees a hint explaining why.
|
|
38
|
+
*/
|
|
39
|
+
import { computed, ref, watchEffect } from 'vue';
|
|
40
|
+
import { Breadcrumb, Container, EditorPlaceholder } from '@eldrajs/ui';
|
|
41
|
+
import type { BreadcrumbItem } from '@eldrajs/ui';
|
|
42
|
+
import { useBlockData } from '../../app/composables/useBlockData';
|
|
43
|
+
import { useEditing } from '../../app/composables/useEditing';
|
|
44
|
+
import { useStorefront } from '../../app/composables/useStorefront';
|
|
45
|
+
import { useI18n } from 'vue-i18n';
|
|
46
|
+
import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
|
|
47
|
+
import { categoryHref, isInternalHref, safeHref } from '../../app/utils/links';
|
|
48
|
+
|
|
49
|
+
const props = defineProps<{ entry: EldraBlockEntry<'breadcrumbs'> }>();
|
|
50
|
+
const { data } = useBlockData(props, 'breadcrumbs');
|
|
51
|
+
const editing = useEditing();
|
|
52
|
+
const storefront = useStorefront();
|
|
53
|
+
const { t } = useI18n();
|
|
54
|
+
|
|
55
|
+
const showHome = computed(() => data.value.showHome !== false);
|
|
56
|
+
/**
|
|
57
|
+
* **On unless the author turned it off**, which is what `!== false` means here and nowhere else in
|
|
58
|
+
* this block (`showHome` and `showCurrent` read the same way, and for the same reason).
|
|
59
|
+
*
|
|
60
|
+
* It matters because of what "absent" is. A `fromProduct` the page document does not carry is not
|
|
61
|
+
* an author's "no" — it is a product template written before the field existed, which is every
|
|
62
|
+
* site deployed up to now: Core stores the block data a seed wrote and does not backfill a field
|
|
63
|
+
* added later. Reading an absent value as `false` therefore left the trail switched off on exactly
|
|
64
|
+
* the pages it exists for, with nothing in the inspector to explain it, while the seeded template
|
|
65
|
+
* beside it also turns Product detail's own `showCategory` off — so a live product page had no
|
|
66
|
+
* category trail in either place.
|
|
67
|
+
*
|
|
68
|
+
* **How this relates to `product-detail`'s `showCategory`, which is also on by default.** That
|
|
69
|
+
* field names the product's category as **one label** above the title, never a trail (see that
|
|
70
|
+
* block's own `categoryLeaf`), so the two do not repeat each other: the trail from Home down to the
|
|
71
|
+
* category is this block's, the shelf the product sits on is that block's. What a page with both on
|
|
72
|
+
* does show twice is the leaf's own name — once as the last crumb here, once as that label — which
|
|
73
|
+
* is why both fields say to turn one of the two off if a page should name the category only once.
|
|
74
|
+
* This block cannot know what else is on the page, so neither default can guarantee more than that.
|
|
75
|
+
*
|
|
76
|
+
* `preview.json` turns it off for the generated story and the preview tile alone, because the demo
|
|
77
|
+
* storefront's route *is* a product by default (`app/storefront/demo.ts`) — so without the overlay
|
|
78
|
+
* this block's own tile would draw the demo product's category on top of `mock.json`'s authored
|
|
79
|
+
* levels, which is a picture of two trails rather than of this block.
|
|
80
|
+
*/
|
|
81
|
+
const fromProduct = computed(() => data.value.fromProduct !== false);
|
|
82
|
+
/**
|
|
83
|
+
* **The second level this block can fill by itself**: on a *category* page, the levels above the
|
|
84
|
+
* category the route resolved — each linking to its own page — plus the category's own name as the
|
|
85
|
+
* last crumb when the page set no `currentTitle`.
|
|
86
|
+
*
|
|
87
|
+
* On unless the author turned it off, for exactly the reason `fromProduct` reads that way: an
|
|
88
|
+
* absent value is a template written before the field existed, not an author's "no".
|
|
89
|
+
*
|
|
90
|
+
* It and `fromProduct` never both fire: a route resolves a product or a category, never both, so
|
|
91
|
+
* each is inert on the other's page and neither needs to know about the other.
|
|
92
|
+
*/
|
|
93
|
+
const fromCategory = computed(() => data.value.fromCategory !== false);
|
|
94
|
+
const homeLabel = computed(() => data.value.homeLabel || 'Home');
|
|
95
|
+
const showCurrent = computed(() => data.value.showCurrent !== false);
|
|
96
|
+
const currentTitle = computed(() => data.value.currentTitle?.trim() ?? '');
|
|
97
|
+
const containerWidth = computed(() => data.value.container ?? 'wide');
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Each trail level's `href` is page-author content, not a trusted literal (unlike the hard-coded
|
|
101
|
+
* `/` below), so it goes through `safeHref` like every other field-sourced destination in this
|
|
102
|
+
* theme. A level with no safe href or no label is dropped rather than rendered with a broken link.
|
|
103
|
+
*/
|
|
104
|
+
const trailItems = computed<BreadcrumbItem[]>(() =>
|
|
105
|
+
(data.value.trail ?? []).flatMap((level) => {
|
|
106
|
+
const href = safeHref(level.href);
|
|
107
|
+
if (href === null || !level.label) return [];
|
|
108
|
+
return [{ label: level.label, href }];
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The product **this page** resolved, read once rather than watched — `null` whenever `fromProduct`
|
|
114
|
+
* is off, so a page that does not want the store's trail makes no read at all.
|
|
115
|
+
*
|
|
116
|
+
* `route.productHandle` is the committed route's and is settled before any block on the page is
|
|
117
|
+
* created, which is what makes this result's key the one the prerender left a payload under
|
|
118
|
+
* (`StorefrontResult`'s "sources final at setup time" rule). Reading it *inside* the computed made
|
|
119
|
+
* it a live source instead, and this block sits on pages that are not product pages: a click on a
|
|
120
|
+
* product card commits the destination route while the collection page is still mounted, so the
|
|
121
|
+
* collection page's own breadcrumbs re-keyed onto the clicked product and fetched it — a second
|
|
122
|
+
* read of a product the destination page already has in its payload. Capturing the value here keeps
|
|
123
|
+
* a block on a non-product page at `null` for its whole life, and the destination page's own blocks
|
|
124
|
+
* are created fresh against the committed route.
|
|
125
|
+
*/
|
|
126
|
+
const routeProductHandle = storefront.route.productHandle;
|
|
127
|
+
const productHandle = computed<string | null>(() =>
|
|
128
|
+
fromProduct.value ? routeProductHandle : null
|
|
129
|
+
);
|
|
130
|
+
const productResult = storefront.catalog.product(productHandle);
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The category **this page** resolved, captured at setup for the same reason the product handle is
|
|
134
|
+
* (see above) and `null` whenever `fromCategory` is off — so a page that does not want the
|
|
135
|
+
* category's trail makes no read at all.
|
|
136
|
+
*
|
|
137
|
+
* It is the **same result** `collection-header` in category mode creates on the same page:
|
|
138
|
+
* identical method, identical source, therefore an identical prerender key, so Nuxt's
|
|
139
|
+
* `useAsyncData` answers both from one read.
|
|
140
|
+
*/
|
|
141
|
+
const routeCategoryPath = storefront.route.categoryPath;
|
|
142
|
+
const categoryPath = computed<string | null>(() => (fromCategory.value ? routeCategoryPath : null));
|
|
143
|
+
const categoryResult = storefront.catalog.category(categoryPath);
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The store's category trail for that product, through the same `safeHref` gate the authored levels
|
|
147
|
+
* pass. Empty for every honest absence — no product, a product with no category, a category read
|
|
148
|
+
* that failed — and an empty one simply leaves the trail as the author's own.
|
|
149
|
+
*/
|
|
150
|
+
const productTrailItems = computed<BreadcrumbItem[]>(() =>
|
|
151
|
+
(productResult.data.value?.categoryTrail ?? []).flatMap((level) => {
|
|
152
|
+
const href = safeHref(level.href);
|
|
153
|
+
if (href === null || !level.label) return [];
|
|
154
|
+
return [{ label: level.label, href }];
|
|
155
|
+
})
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The levels **above** the current category, root first, each a link to its own page. The category
|
|
160
|
+
* itself is not one of them: it is the current page, and `currentLabel` below names it.
|
|
161
|
+
*
|
|
162
|
+
* Through the same `safeHref` gate every other level passes, even though `categoryHref` builds the
|
|
163
|
+
* path itself — one gate for every destination this block renders, so there is no second rule to
|
|
164
|
+
* keep in step.
|
|
165
|
+
*/
|
|
166
|
+
const categoryTrailItems = computed<BreadcrumbItem[]>(() =>
|
|
167
|
+
(categoryResult.data.value?.ancestors ?? []).flatMap((ancestor) => {
|
|
168
|
+
const href = safeHref(categoryHref(ancestor.path));
|
|
169
|
+
return href === null || ancestor.title === '' ? [] : [{ label: ancestor.title, href }];
|
|
170
|
+
})
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The last crumb's text: the author's `currentTitle`, else — on a category page — the category's
|
|
175
|
+
* own name.
|
|
176
|
+
*
|
|
177
|
+
* The fallback exists because a seeded *template* has no authored title to carry: the category page
|
|
178
|
+
* binds `currentTitle` to the routed category's `{{ title }}`, and a merchant who clears that
|
|
179
|
+
* binding would otherwise be left with a trail that stops at the parent. It is the category's name
|
|
180
|
+
* either way, so the two can never disagree.
|
|
181
|
+
*/
|
|
182
|
+
const currentLabel = computed(() => currentTitle.value || (categoryResult.data.value?.title ?? ''));
|
|
183
|
+
|
|
184
|
+
const items = computed<BreadcrumbItem[]>(() => {
|
|
185
|
+
const resolved: BreadcrumbItem[] = [];
|
|
186
|
+
if (showHome.value) resolved.push({ label: homeLabel.value, href: '/' });
|
|
187
|
+
resolved.push(...trailItems.value);
|
|
188
|
+
resolved.push(...productTrailItems.value);
|
|
189
|
+
resolved.push(...categoryTrailItems.value);
|
|
190
|
+
if (showCurrent.value && currentLabel.value !== '') {
|
|
191
|
+
resolved.push({ label: currentLabel.value });
|
|
192
|
+
}
|
|
193
|
+
return resolved;
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
/** Spec "States every block must handle" → Empty row, this block's own reading of it (see the
|
|
197
|
+
* top-of-file comment): fewer than two levels means there is no trail to show. */
|
|
198
|
+
const hasTrail = computed(() => items.value.length >= 2);
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* `Breadcrumb.linkAs` applies to every level alike (see `BreadcrumbProps.linkAs`'s own comment) —
|
|
202
|
+
* there is no per-item override — so this picks one tag for the whole trail rather than per link,
|
|
203
|
+
* unlike `cta`'s/`feature-grid`'s per-link `isInternalHref` check. The trail is the page tree
|
|
204
|
+
* (`homeLabel` → `/`, always same-site; `trail` levels are meant to be site-internal collection/
|
|
205
|
+
* category paths too), so every safe href here is ordinarily internal; the `every(...)` guard
|
|
206
|
+
* still falls back to a plain `<a>` for the whole trail if a page author ever puts an absolute
|
|
207
|
+
* off-site URL in a level, rather than silently routing an external destination through the
|
|
208
|
+
* router.
|
|
209
|
+
*/
|
|
210
|
+
const linkAs = computed(() =>
|
|
211
|
+
items.value.every((item) => item.href === undefined || isInternalHref(item.href))
|
|
212
|
+
? EldraRouterLink
|
|
213
|
+
: undefined
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Spec "Breadcrumbs" → Layout, "From 64rem": "The current title truncates with an ellipsis at
|
|
218
|
+
* 40ch (single line)." — a per-consumer override of `Breadcrumb`'s own default (the primitive
|
|
219
|
+
* itself deliberately never truncates a label; see `packages/ui/README.md`'s Deviations entry),
|
|
220
|
+
* applied only through the sanctioned `classes` extension point, and only from the package's own
|
|
221
|
+
* `@content` container-query breakpoint (64rem, the same one `Container`'s desktop gutter reads —
|
|
222
|
+
* `Breadcrumb`'s own root is itself a `@container`, so this measures the trail's own rendered
|
|
223
|
+
* width, matching the spec's "the breadcrumb responds to its own width" rule). Below that width
|
|
224
|
+
* the trail keeps the primitive's own default wrapping behaviour, per the spec's "may wrap to a
|
|
225
|
+
* second line" note for narrow widths.
|
|
226
|
+
*/
|
|
227
|
+
const currentClasses = { current: '@content:truncate @content:max-w-[40ch]' };
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* 40ch CSS truncation only ever *visually* clips text — the full string stays in the DOM and in
|
|
231
|
+
* the accessible name either way — but the spec's own acceptance criterion additionally wants the
|
|
232
|
+
* full text "in `title`" (a hover tooltip for sighted mouse users). `Breadcrumb` has no per-item
|
|
233
|
+
* `title` hook (nor a slot to render the current item itself), so this reaches the rendered
|
|
234
|
+
* current-page element the same sanctioned way `classes` does: by its stable `data-part="current"`
|
|
235
|
+
* anatomy name (see the package README's "composed children are addressed by `data-part`" rule).
|
|
236
|
+
* `breadcrumbRoot` is a plain DOM ref (not a component ref) so this stays framework-idiomatic and
|
|
237
|
+
* SSR-safe: it is `null` until the client mounts, `watchEffect` re-runs once it appears, and it
|
|
238
|
+
* re-runs again whenever the resolved label changes (e.g. a live edit in the page-builder).
|
|
239
|
+
*/
|
|
240
|
+
const breadcrumbRoot = ref<HTMLElement | null>(null);
|
|
241
|
+
const lastItemLabel = computed(() => items.value.at(-1)?.label ?? '');
|
|
242
|
+
watchEffect(() => {
|
|
243
|
+
const currentEl = breadcrumbRoot.value?.querySelector('[data-part="current"]');
|
|
244
|
+
currentEl?.setAttribute('title', lastItemLabel.value);
|
|
245
|
+
});
|
|
246
|
+
/**
|
|
247
|
+
* Spec "Breadcrumbs" → Container/Section line: "Section background none (inherits the page
|
|
248
|
+
* ground) · Section spacing none". This root is a plain `@container` wrapper, never `@eldrajs/ui`'s
|
|
249
|
+
* `Section` — `Section` marks every ground, including `none`, with `data-section-bg` so its own
|
|
250
|
+
* adjacent-same-background CSS rule can drop the *next* sibling's top padding. Breadcrumbs sits
|
|
251
|
+
* directly under the header on product/collection/article pages and must never trigger that rule
|
|
252
|
+
* against the block that follows it: the spec's page narrative treats it as a thin trail, not a
|
|
253
|
+
* section the following block's padding collapses against. Omitting `data-section`/`data-section-bg`
|
|
254
|
+
* here (while still giving `Container` a `@container` ancestor for its own gutter breakpoints) is
|
|
255
|
+
* what keeps the next block's full top padding intact.
|
|
256
|
+
*/
|
|
257
|
+
</script>
|
|
258
|
+
|
|
259
|
+
<template>
|
|
260
|
+
<div v-if="hasTrail" class="bg-background text-text @container">
|
|
261
|
+
<Container :width="containerWidth" :classes="{ root: 'py-3' }">
|
|
262
|
+
<div ref="breadcrumbRoot" class="contents">
|
|
263
|
+
<Breadcrumb
|
|
264
|
+
:items="items"
|
|
265
|
+
:collapse-after="1"
|
|
266
|
+
:keep-last="2"
|
|
267
|
+
:link-as="linkAs"
|
|
268
|
+
:classes="currentClasses"
|
|
269
|
+
/>
|
|
270
|
+
</div>
|
|
271
|
+
</Container>
|
|
272
|
+
</div>
|
|
273
|
+
<EditorPlaceholder
|
|
274
|
+
v-else-if="editing"
|
|
275
|
+
:label="t('breadcrumbs.hintLabel')"
|
|
276
|
+
:help="t('breadcrumbs.hintHelp')"
|
|
277
|
+
/>
|
|
278
|
+
</template>
|