@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,343 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Article list: journal stories as a card grid, a featured-first layout or thumbnail rows, with
|
|
4
|
+
* optional category chips and pagination (spec `02-blocks.md` "Article list", 2599-2718).
|
|
5
|
+
*
|
|
6
|
+
* **One card, three layouts.** Every story is a `<li>` wrapping `@eldrajs/ui`'s `ContentCard`
|
|
7
|
+
* (which renders its own `<article>` root — no extra one is added around it) — never a bespoke
|
|
8
|
+
* card of this block's own — restyled per variant through its
|
|
9
|
+
* `classes` prop (the same technique `feature-grid`'s own `classes.iconTile`/`classes.cue`
|
|
10
|
+
* override uses): `grid` leaves the card's own vertical layout untouched; `featured-first` turns
|
|
11
|
+
* the first story's `root` into a two-column grid (image | text, `@tablet:`/`@content:` gaps) and
|
|
12
|
+
* enlarges its title from 64rem; `list` turns every story's `root` into a thumbnail-beside-text
|
|
13
|
+
* grid and hides the excerpt below 48rem of block width (`@max-tablet:hidden`, the same variant
|
|
14
|
+
* `Breadcrumb`'s own collapsing trail uses).
|
|
15
|
+
*
|
|
16
|
+
* **Three documented package limits.** (1) `ContentCard`'s own contract renders no media slot at
|
|
17
|
+
* all with no image — a plain card "renders as the surface variant" instead (its own acceptance
|
|
18
|
+
* criteria) — so a missing cover image here becomes a padded, image-less card rather than the
|
|
19
|
+
* design's literal striped placeholder; `Image`'s own live placeholder is real but only reachable
|
|
20
|
+
* when `ContentCard` actually mounts an `<Image>`, which it never does with no `image`. (2)
|
|
21
|
+
* `ContentCard`'s `ratio` has no `1x1`, so `list`'s below-48rem thumbnail stays the same 3:2 frame,
|
|
22
|
+
* narrowed by the grid track rather than a true square. (3) **No image framing.** `ContentCard`
|
|
23
|
+
* takes its media as an `image` *prop* (`{src, alt, width, height}`) and exposes no media slot, so
|
|
24
|
+
* a card's image can only be rendered by the component itself — never through this theme's
|
|
25
|
+
* `UiImage`, which is what emits the `data-eldra-framing*` markers Studio's framing controls key
|
|
26
|
+
* off and applies the focal point/zoom. `items[].image` therefore declares no `metadata.framing`:
|
|
27
|
+
* offering an editor a framing control whose result the render ignores is worse than not offering
|
|
28
|
+
* it, and the alternative — forking `ContentCard` to add a media slot — is exactly what the
|
|
29
|
+
* starter's "never fork a package component" rule forbids (a media slot on `ContentCard` is a
|
|
30
|
+
* sub-project 1 addition to raise, not something to work around here). The 3:2 crop is taken from
|
|
31
|
+
* the top, as `block.json`'s own `helpText` says. None of the three is a fork — all follow the
|
|
32
|
+
* component's published contract as given.
|
|
33
|
+
*
|
|
34
|
+
* **No route reading.** Blocks may not read the URL — `StorefrontRoute` carries `page`, never a
|
|
35
|
+
* path. So both the active chip and `hrefForPage` key off
|
|
36
|
+
* this block's *own* fields instead of the address bar: `selfPath` is `categoryHref` (the field
|
|
37
|
+
* documenting "this instance is the category page for X") falling back to `viewAllHref` (the
|
|
38
|
+
* journal index) — the one the mock ships, and the one every default chip's own `href` equals, so
|
|
39
|
+
* "All" reads active with no special case. A chip is active when its own `href` equals `selfPath`;
|
|
40
|
+
* `hrefForPage` appends `?page=n` to it (page 1 plain).
|
|
41
|
+
*
|
|
42
|
+
* **Icons.** The active chip's check mark is a plain, template-level `EldraIcon` (decorative, `sm`
|
|
43
|
+
* = 1rem) — no package prop needs a bare component for it. The empty state's `file-text` icon does
|
|
44
|
+
* need one (`EmptyState.icon` takes an already-bound `IconComponent`, the same contract
|
|
45
|
+
* `Badge`/`FeatureCard` have), so it is built the same module-scope way `pricing-table`'s own
|
|
46
|
+
* `StarIcon` is, fixed to the one icon this block ever shows there.
|
|
47
|
+
*
|
|
48
|
+
* **Pagination window.** `perPage` slices `items`; `featured-first` treats whichever story leads
|
|
49
|
+
* the *current* page as the featured one, not only the first story overall, so every page keeps a
|
|
50
|
+
* split row rather than only page one.
|
|
51
|
+
*
|
|
52
|
+
* **Empty items.** With none to show: while editing, the "freshly inserted" hint (spec States,
|
|
53
|
+
* "Showing your latest stories" / "Choose a source…") — this starter has no live journal query to
|
|
54
|
+
* fall back to (`source` only documents intent; every mode renders `items` as given), so unlike
|
|
55
|
+
* the spec's literal "the live site shows the latest stories straight away", an empty `items`
|
|
56
|
+
* field live falls to `emptyTitle`'s `EmptyState` instead, and renders nothing further when that
|
|
57
|
+
* field is also empty (this project's "empty optional content renders nothing live" rule).
|
|
58
|
+
*/
|
|
59
|
+
import { computed, defineComponent, h, type Component } from 'vue';
|
|
60
|
+
import {
|
|
61
|
+
Button,
|
|
62
|
+
Container,
|
|
63
|
+
ContentCard,
|
|
64
|
+
EditorPlaceholder,
|
|
65
|
+
EmptyState,
|
|
66
|
+
Link,
|
|
67
|
+
Pagination,
|
|
68
|
+
Section,
|
|
69
|
+
type ContentCardPart,
|
|
70
|
+
} from '@eldrajs/ui';
|
|
71
|
+
import { useBlockData } from '../../app/composables/useBlockData';
|
|
72
|
+
import { useEditing } from '../../app/composables/useEditing';
|
|
73
|
+
import { iconComponent } from '../../app/composables/iconComponent';
|
|
74
|
+
import { useStorefront } from '../../app/composables/useStorefront';
|
|
75
|
+
import { useI18n } from 'vue-i18n';
|
|
76
|
+
import { useUiId } from '../../app/composables/useUiId';
|
|
77
|
+
import EldraIcon from '../../app/components/EldraIcon.vue';
|
|
78
|
+
import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
|
|
79
|
+
import { isInternalHref, safeHref } from '../../app/utils/links';
|
|
80
|
+
|
|
81
|
+
const props = defineProps<{ entry: EldraBlockEntry<'article-list'> }>();
|
|
82
|
+
const { data } = useBlockData(props, 'article-list');
|
|
83
|
+
const editing = useEditing();
|
|
84
|
+
const { t } = useI18n();
|
|
85
|
+
const storefront = useStorefront();
|
|
86
|
+
const headingId = `article-list-heading-${useUiId()}`;
|
|
87
|
+
|
|
88
|
+
const variant = computed(() => data.value.variant ?? 'grid');
|
|
89
|
+
const isFeaturedFirst = computed(() => variant.value === 'featured-first');
|
|
90
|
+
const isList = computed(() => variant.value === 'list');
|
|
91
|
+
|
|
92
|
+
const heading = computed(() => (data.value.heading ?? '').trim());
|
|
93
|
+
const hasHeading = computed(() => heading.value !== '');
|
|
94
|
+
const showHeadingHint = computed(() => editing.value && !hasHeading.value);
|
|
95
|
+
|
|
96
|
+
const viewAllLabel = computed(() => (data.value.viewAllLabel ?? '').trim());
|
|
97
|
+
const viewAllHref = computed(() => safeHref(data.value.viewAllHref));
|
|
98
|
+
const hasViewAllLink = computed(() => viewAllLabel.value !== '' && viewAllHref.value !== null);
|
|
99
|
+
const viewAllLinkAs = computed(() =>
|
|
100
|
+
viewAllHref.value !== null && isInternalHref(viewAllHref.value) ? EldraRouterLink : undefined
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const hasHead = computed(() => hasHeading.value || showHeadingHint.value || hasViewAllLink.value);
|
|
104
|
+
|
|
105
|
+
/** See the module doc comment: this block's own stand-in for "the current page", since a block
|
|
106
|
+
* may not read the URL. */
|
|
107
|
+
const selfPath = computed(
|
|
108
|
+
() => safeHref(data.value.categoryHref) ?? safeHref(data.value.viewAllHref)
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const rawItems = computed(() => data.value.items ?? []);
|
|
112
|
+
const showItemsHint = computed(() => editing.value && rawItems.value.length === 0);
|
|
113
|
+
|
|
114
|
+
/** `6` (the spec's own default) whenever the field is unset or not a positive number — the
|
|
115
|
+
* "bare" fixture (no `perPage` at all) and any stray value both fall back the same way. */
|
|
116
|
+
const perPage = computed(() => {
|
|
117
|
+
const n = Number(data.value.perPage);
|
|
118
|
+
return Number.isFinite(n) && n > 0 ? n : 6;
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const totalPages = computed(() => Math.max(1, Math.ceil(rawItems.value.length / perPage.value)));
|
|
122
|
+
const currentPage = computed(() => Math.min(Math.max(storefront.route.page, 1), totalPages.value));
|
|
123
|
+
|
|
124
|
+
const pageItems = computed(() => {
|
|
125
|
+
const start = (currentPage.value - 1) * perPage.value;
|
|
126
|
+
return rawItems.value.slice(start, start + perPage.value);
|
|
127
|
+
});
|
|
128
|
+
const hasPageItems = computed(() => pageItems.value.length > 0);
|
|
129
|
+
|
|
130
|
+
const showFilters = computed(() => Boolean(data.value.showFilters));
|
|
131
|
+
const filters = computed(() =>
|
|
132
|
+
(data.value.filters ?? [])
|
|
133
|
+
.map((filter) => ({
|
|
134
|
+
label: (filter.label ?? '').trim(),
|
|
135
|
+
href: safeHref(filter.href),
|
|
136
|
+
}))
|
|
137
|
+
.filter(
|
|
138
|
+
(filter): filter is { label: string; href: string } =>
|
|
139
|
+
filter.label !== '' && filter.href !== null
|
|
140
|
+
)
|
|
141
|
+
.map((filter) => ({
|
|
142
|
+
...filter,
|
|
143
|
+
active: filter.href === selfPath.value,
|
|
144
|
+
linkAs: isInternalHref(filter.href) ? EldraRouterLink : undefined,
|
|
145
|
+
}))
|
|
146
|
+
);
|
|
147
|
+
const hasFilters = computed(() => showFilters.value && filters.value.length > 0);
|
|
148
|
+
|
|
149
|
+
const showExcerptField = computed(() => data.value.showExcerpt ?? true);
|
|
150
|
+
|
|
151
|
+
const emptyTitle = computed(() => (data.value.emptyTitle ?? '').trim());
|
|
152
|
+
const emptyText = computed(() => (data.value.emptyText ?? '').trim() || null);
|
|
153
|
+
const showEmptyState = computed(
|
|
154
|
+
() => !editing.value && !hasPageItems.value && emptyTitle.value !== ''
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
const showPaginationField = computed(() => Boolean(data.value.showPagination));
|
|
158
|
+
const canPaginate = computed(
|
|
159
|
+
() => showPaginationField.value && hasPageItems.value && selfPath.value !== null
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
/** Appends `?page=n` to this block's own `selfPath` (see the module doc comment); page 1 is the
|
|
163
|
+
* plain path, with no query at all. */
|
|
164
|
+
function hrefForPage(page: number): string {
|
|
165
|
+
const base = selfPath.value ?? '';
|
|
166
|
+
return page <= 1 ? base : `${base}?page=${page}`;
|
|
167
|
+
}
|
|
168
|
+
const paginationLinkAs = computed(() =>
|
|
169
|
+
selfPath.value !== null && isInternalHref(selfPath.value) ? EldraRouterLink : undefined
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
/** `EmptyState.icon` (like `Badge.icon`/`FeatureCard.icon`) takes a bare, already-bound icon
|
|
173
|
+
* component with no props of its own, so this goes through the theme's shared name→component
|
|
174
|
+
* adapter (`app/composables/iconComponent.ts`). */
|
|
175
|
+
const FileTextIcon: Component = iconComponent('file-text');
|
|
176
|
+
|
|
177
|
+
interface CardView {
|
|
178
|
+
key: number;
|
|
179
|
+
title: string;
|
|
180
|
+
dek: string | null;
|
|
181
|
+
href: string | null;
|
|
182
|
+
linkAs: typeof EldraRouterLink | undefined;
|
|
183
|
+
categoryLabel: string | null;
|
|
184
|
+
publishedAt: string | null;
|
|
185
|
+
readingTime: string | null;
|
|
186
|
+
image: { src: string; alt: string; width?: number; height?: number } | null;
|
|
187
|
+
featured: boolean;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const cards = computed<CardView[]>(() =>
|
|
191
|
+
pageItems.value.map((item, index) => {
|
|
192
|
+
const href = safeHref(item.href);
|
|
193
|
+
const media = item.image;
|
|
194
|
+
return {
|
|
195
|
+
key: index,
|
|
196
|
+
title: (item.title ?? '').trim(),
|
|
197
|
+
dek: showExcerptField.value ? (item.dek ?? '').trim() || null : null,
|
|
198
|
+
href,
|
|
199
|
+
linkAs: href !== null && isInternalHref(href) ? EldraRouterLink : undefined,
|
|
200
|
+
categoryLabel: (item.categoryLabel ?? '').trim() || null,
|
|
201
|
+
publishedAt: item.publishedAt || null,
|
|
202
|
+
readingTime: (item.readingTime ?? '').trim() || null,
|
|
203
|
+
image: media ? { src: media.url, alt: '', width: media.width, height: media.height } : null,
|
|
204
|
+
featured: isFeaturedFirst.value && index === 0,
|
|
205
|
+
};
|
|
206
|
+
})
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
/** Static, variant-keyed class lookups (Tailwind cannot see a dynamically built class name). */
|
|
210
|
+
const GRID_ROOT_CLASS =
|
|
211
|
+
'grid grid-cols-1 gap-y-8 @tablet:grid-cols-2 @tablet:gap-x-6 @tablet:gap-y-12 @content:grid-cols-3 @content:gap-x-8';
|
|
212
|
+
const LIST_ROOT_CLASS = 'flex flex-col border-t border-border';
|
|
213
|
+
const listContainerClass = computed(() => (isList.value ? LIST_ROOT_CLASS : GRID_ROOT_CLASS));
|
|
214
|
+
|
|
215
|
+
const FEATURED_CARD_CLASSES: Partial<Record<ContentCardPart, string>> = {
|
|
216
|
+
root: 'grid gap-6 @tablet:grid-cols-[7fr_5fr] @tablet:items-center @tablet:gap-8 @content:gap-12',
|
|
217
|
+
title: '@content:text-[2rem] @content:leading-[1.15]',
|
|
218
|
+
body: '@content:gap-4',
|
|
219
|
+
};
|
|
220
|
+
const LIST_CARD_CLASSES: Partial<Record<ContentCardPart, string>> = {
|
|
221
|
+
root: 'grid grid-cols-[6.5rem_1fr] items-start gap-4 @tablet:grid-cols-[15rem_1fr] @tablet:items-center @tablet:gap-8',
|
|
222
|
+
excerpt: '@max-tablet:hidden',
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
function cardClasses(card: CardView): Partial<Record<ContentCardPart, string>> | undefined {
|
|
226
|
+
if (card.featured) return FEATURED_CARD_CLASSES;
|
|
227
|
+
if (isList.value) return LIST_CARD_CLASSES;
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function itemWrapperClass(card: CardView): string {
|
|
232
|
+
if (isList.value) return 'border-b border-border py-5 @tablet:py-6';
|
|
233
|
+
return card.featured ? '@tablet:col-span-2 @content:col-span-3' : '';
|
|
234
|
+
}
|
|
235
|
+
</script>
|
|
236
|
+
|
|
237
|
+
<template>
|
|
238
|
+
<Section spacing="md" :labelled-by="hasHeading ? headingId : undefined">
|
|
239
|
+
<Container width="content">
|
|
240
|
+
<div
|
|
241
|
+
v-if="hasHead"
|
|
242
|
+
class="@tablet:flex-row @tablet:items-baseline @tablet:justify-between mb-6 flex flex-col items-start gap-2"
|
|
243
|
+
>
|
|
244
|
+
<h2
|
|
245
|
+
v-if="hasHeading"
|
|
246
|
+
:id="headingId"
|
|
247
|
+
class="font-heading text-text @tablet:text-h2 text-[1.625rem] leading-[1.15] font-bold tracking-[-0.015em]"
|
|
248
|
+
>
|
|
249
|
+
{{ heading }}
|
|
250
|
+
</h2>
|
|
251
|
+
<EditorPlaceholder
|
|
252
|
+
v-else-if="showHeadingHint"
|
|
253
|
+
inline
|
|
254
|
+
:label="t('articleList.headingHintLabel')"
|
|
255
|
+
:help="t('articleList.headingHintHelp')"
|
|
256
|
+
/>
|
|
257
|
+
|
|
258
|
+
<Link
|
|
259
|
+
v-if="hasViewAllLink"
|
|
260
|
+
:href="viewAllHref!"
|
|
261
|
+
:as="viewAllLinkAs"
|
|
262
|
+
variant="standalone"
|
|
263
|
+
arrow
|
|
264
|
+
:classes="{ root: 'text-control' }"
|
|
265
|
+
>
|
|
266
|
+
{{ viewAllLabel }}
|
|
267
|
+
</Link>
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<nav v-if="hasFilters" :aria-label="t('articleList.filterNav')" class="mb-8">
|
|
271
|
+
<ul class="flex flex-wrap gap-2">
|
|
272
|
+
<li v-for="filter in filters" :key="filter.href">
|
|
273
|
+
<Link
|
|
274
|
+
:href="filter.href"
|
|
275
|
+
:as="filter.linkAs"
|
|
276
|
+
:underline="false"
|
|
277
|
+
:aria-current="filter.active ? 'true' : undefined"
|
|
278
|
+
:classes="{
|
|
279
|
+
root: filter.active
|
|
280
|
+
? 'inline-flex min-h-10 items-center rounded-full border border-primary bg-primary px-4 text-control font-semibold text-primary-contrast'
|
|
281
|
+
: 'inline-flex min-h-10 items-center rounded-full border border-border-strong px-4 text-control font-medium text-text hover:border-text',
|
|
282
|
+
label: 'inline-flex items-center gap-1',
|
|
283
|
+
}"
|
|
284
|
+
>
|
|
285
|
+
<EldraIcon v-if="filter.active" name="check" size="sm" />
|
|
286
|
+
{{ filter.label }}
|
|
287
|
+
</Link>
|
|
288
|
+
</li>
|
|
289
|
+
</ul>
|
|
290
|
+
</nav>
|
|
291
|
+
|
|
292
|
+
<ul v-if="hasPageItems" role="list" :class="listContainerClass">
|
|
293
|
+
<li v-for="card in cards" :key="card.key" :class="itemWrapperClass(card)">
|
|
294
|
+
<ContentCard
|
|
295
|
+
v-if="card.href"
|
|
296
|
+
:title="card.title"
|
|
297
|
+
:href="card.href"
|
|
298
|
+
:link-as="card.linkAs"
|
|
299
|
+
:image="card.image"
|
|
300
|
+
ratio="3x2"
|
|
301
|
+
:eyebrow="card.categoryLabel"
|
|
302
|
+
:date="card.publishedAt"
|
|
303
|
+
:meta="card.readingTime"
|
|
304
|
+
:excerpt="card.dek"
|
|
305
|
+
:heading-level="3"
|
|
306
|
+
:classes="cardClasses(card)"
|
|
307
|
+
/>
|
|
308
|
+
</li>
|
|
309
|
+
</ul>
|
|
310
|
+
<EditorPlaceholder
|
|
311
|
+
v-else-if="showItemsHint"
|
|
312
|
+
:label="t('articleList.itemsHintLabel')"
|
|
313
|
+
:help="t('articleList.itemsHintHelp')"
|
|
314
|
+
/>
|
|
315
|
+
<EmptyState
|
|
316
|
+
v-else-if="showEmptyState"
|
|
317
|
+
variant="noResults"
|
|
318
|
+
:icon="FileTextIcon"
|
|
319
|
+
:title="emptyTitle"
|
|
320
|
+
:text="emptyText"
|
|
321
|
+
>
|
|
322
|
+
<template v-if="hasViewAllLink" #actions>
|
|
323
|
+
<Button
|
|
324
|
+
variant="outline"
|
|
325
|
+
:href="viewAllHref!"
|
|
326
|
+
:as="viewAllLinkAs"
|
|
327
|
+
:label="viewAllLabel"
|
|
328
|
+
/>
|
|
329
|
+
</template>
|
|
330
|
+
</EmptyState>
|
|
331
|
+
|
|
332
|
+
<Pagination
|
|
333
|
+
v-if="canPaginate"
|
|
334
|
+
class="mt-12"
|
|
335
|
+
:page="currentPage"
|
|
336
|
+
:total-pages="totalPages"
|
|
337
|
+
:href-for-page="hrefForPage"
|
|
338
|
+
:link-as="paginationLinkAs"
|
|
339
|
+
:aria-label="t('articleList.pages')"
|
|
340
|
+
/>
|
|
341
|
+
</Container>
|
|
342
|
+
</Section>
|
|
343
|
+
</template>
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { flushPromises, mount } from '@vue/test-utils';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { ELDRA_KEY } from '@eldrajs/theme-vue';
|
|
5
|
+
import { axe } from '../../../test/support/axe';
|
|
6
|
+
import Block from '../Block.vue';
|
|
7
|
+
import mock from '../mock.json';
|
|
8
|
+
import preview from '../preview.json';
|
|
9
|
+
import { mountOptions } from '../../../test/support/mountBlock';
|
|
10
|
+
import { createDemoStorefront } from '../../../app/storefront/demo';
|
|
11
|
+
import { STOREFRONT_KEY } from '../../../app/storefront/types';
|
|
12
|
+
|
|
13
|
+
/** `mock.json`'s items carry no `image` (Core's write-side media validator rejects a
|
|
14
|
+
* fixture-shaped object there); `preview.json` is the demo-imagery overlay, a full `items`
|
|
15
|
+
* replacement over `mock.json` (same shallow-merge contract every other rebuilt block's own
|
|
16
|
+
* `preview.json` uses). */
|
|
17
|
+
const withImages = { ...mock, ...preview };
|
|
18
|
+
|
|
19
|
+
/** Only the fields the block actually requires (`variant`, `source`) plus one story — the
|
|
20
|
+
* "genuinely minimal" fixture every rebuilt block spec covers alongside the full `mock.json`. */
|
|
21
|
+
const bare = {
|
|
22
|
+
variant: 'grid',
|
|
23
|
+
source: 'manual',
|
|
24
|
+
items: [{ title: 'Bare story', href: '/journal/bare-story' }],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function mountBlock(
|
|
28
|
+
data: Record<string, unknown>,
|
|
29
|
+
options: { editing?: boolean; page?: number } = {}
|
|
30
|
+
) {
|
|
31
|
+
const base = mountOptions({ entry: { id: 'e1', data } });
|
|
32
|
+
const storefront = createDemoStorefront();
|
|
33
|
+
if (options.page !== undefined) storefront.route.page = options.page;
|
|
34
|
+
const opts = {
|
|
35
|
+
...base,
|
|
36
|
+
global: {
|
|
37
|
+
...base.global,
|
|
38
|
+
provide: {
|
|
39
|
+
...base.global.provide,
|
|
40
|
+
[STOREFRONT_KEY]: storefront,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
if (options.editing) {
|
|
45
|
+
const context = opts.global.provide[ELDRA_KEY] as {
|
|
46
|
+
preview: { active: boolean; mode: string };
|
|
47
|
+
};
|
|
48
|
+
context.preview.active = true;
|
|
49
|
+
context.preview.mode = 'edit';
|
|
50
|
+
}
|
|
51
|
+
return mount(Block, opts);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe('article-list block', () => {
|
|
55
|
+
it('renders the merged (mock + preview) content with no axe violations', async () => {
|
|
56
|
+
const wrapper = mountBlock(withImages);
|
|
57
|
+
await flushPromises();
|
|
58
|
+
expect(wrapper.text()).toContain(withImages.heading);
|
|
59
|
+
for (const item of withImages.items) expect(wrapper.text()).toContain(item.title);
|
|
60
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('renders the bare minimal fixture with no axe violations', async () => {
|
|
64
|
+
const wrapper = mountBlock(bare);
|
|
65
|
+
await flushPromises();
|
|
66
|
+
expect(wrapper.text()).toContain('Bare story');
|
|
67
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('passes axe for every declared variant', async () => {
|
|
71
|
+
for (const variant of ['grid', 'featured-first', 'list']) {
|
|
72
|
+
const wrapper = mountBlock({ ...withImages, variant });
|
|
73
|
+
await flushPromises();
|
|
74
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
75
|
+
wrapper.unmount();
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('passes axe with zero items', async () => {
|
|
80
|
+
const wrapper = mountBlock({ ...mock, items: [] });
|
|
81
|
+
await flushPromises();
|
|
82
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('renders each card as one tab stop whose accessible name is its title', async () => {
|
|
86
|
+
const wrapper = mountBlock(withImages);
|
|
87
|
+
await flushPromises();
|
|
88
|
+
const articles = wrapper.findAll('article');
|
|
89
|
+
expect(articles).toHaveLength(withImages.items.length);
|
|
90
|
+
articles.forEach((article, index) => {
|
|
91
|
+
const links = article.findAll('a');
|
|
92
|
+
expect(links).toHaveLength(1);
|
|
93
|
+
expect(links[0]!.text()).toBe(withImages.items[index]!.title);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('renders card images as decorative (alt="")', async () => {
|
|
98
|
+
const wrapper = mountBlock(withImages);
|
|
99
|
+
await flushPromises();
|
|
100
|
+
const images = wrapper.findAll('article img');
|
|
101
|
+
expect(images.length).toBeGreaterThan(0);
|
|
102
|
+
for (const image of images) expect(image.attributes('alt')).toBe('');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('renders an item with no image without an <img>, title still readable', async () => {
|
|
106
|
+
// `mock.json` itself carries no `image` on any item (media fields are absent from the insert
|
|
107
|
+
// seed) — `ContentCard`'s own contract renders no media slot at all in that case (its
|
|
108
|
+
// acceptance criteria: "a plain card with no image renders as the surface variant"), so this
|
|
109
|
+
// also proves the package-constrained fallback documented in `Block.vue`'s own comment.
|
|
110
|
+
const wrapper = mountBlock(mock);
|
|
111
|
+
await flushPromises();
|
|
112
|
+
const articles = wrapper.findAll('article');
|
|
113
|
+
expect(articles.length).toBeGreaterThan(0);
|
|
114
|
+
for (const article of articles) {
|
|
115
|
+
expect(article.find('img').exists()).toBe(false);
|
|
116
|
+
}
|
|
117
|
+
expect(wrapper.text()).toContain(mock.items[0]!.title);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('marks the active chip with aria-current, a check icon and a weight class — every chip a link', async () => {
|
|
121
|
+
const wrapper = mountBlock({ ...withImages, categoryHref: '/journal/ceramics' });
|
|
122
|
+
await flushPromises();
|
|
123
|
+
const nav = wrapper.get('nav[aria-label="Filter stories by category"]');
|
|
124
|
+
const chipLinks = nav.findAll('a');
|
|
125
|
+
expect(chipLinks).toHaveLength(mock.filters.length);
|
|
126
|
+
for (const link of chipLinks) expect(link.element.tagName).toBe('A');
|
|
127
|
+
|
|
128
|
+
const active = chipLinks.find((link) => link.text().includes('Ceramics'))!;
|
|
129
|
+
expect(active.attributes('aria-current')).toBe('true');
|
|
130
|
+
expect(active.find('svg').exists()).toBe(true);
|
|
131
|
+
expect(active.classes().join(' ')).toContain('font-semibold');
|
|
132
|
+
|
|
133
|
+
const inactive = chipLinks.find((link) => link.text().includes('Care'))!;
|
|
134
|
+
expect(inactive.attributes('aria-current')).toBeUndefined();
|
|
135
|
+
expect(inactive.find('svg').exists()).toBe(false);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('marks "All" active by default (no category context set)', async () => {
|
|
139
|
+
// `selfPath` (this instance's own route) falls back to `viewAllHref` when `categoryHref` is
|
|
140
|
+
// unset — the seed carries neither (no dead demo link ships), so a real page using this
|
|
141
|
+
// variant supplies its own `viewAllHref`, which this test stands in for.
|
|
142
|
+
const wrapper = mountBlock({ ...withImages, viewAllHref: '/journal' });
|
|
143
|
+
await flushPromises();
|
|
144
|
+
const nav = wrapper.get('nav[aria-label="Filter stories by category"]');
|
|
145
|
+
const all = nav.findAll('a').find((link) => link.text().includes('All'))!;
|
|
146
|
+
expect(all.attributes('aria-current')).toBe('true');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('renders no "self path" chrome (active chip, pagination) when neither categoryHref nor viewAllHref is set — the seeded state', async () => {
|
|
150
|
+
// `mock.json` ships both empty — an inserted block links to no demo path nothing serves —
|
|
151
|
+
// so without either, the block has no page of its own to build `?page=n` links or an
|
|
152
|
+
// active-chip match against: it renders the filter chips and items with nothing marked
|
|
153
|
+
// current, and no pagination.
|
|
154
|
+
const wrapper = mountBlock({ ...withImages, perPage: '3' });
|
|
155
|
+
await flushPromises();
|
|
156
|
+
const nav = wrapper.get('nav[aria-label="Filter stories by category"]');
|
|
157
|
+
expect(nav.findAll('[aria-current="true"]')).toHaveLength(0);
|
|
158
|
+
expect(wrapper.find('nav[aria-label="Journal pages"]').exists()).toBe(false);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('paginates: page links, current page, and disabled ends carry the right ARIA', async () => {
|
|
162
|
+
const wrapper = mountBlock({ ...withImages, viewAllHref: '/journal', perPage: '3' });
|
|
163
|
+
await flushPromises();
|
|
164
|
+
const nav = wrapper.get('nav[aria-label="Journal pages"]');
|
|
165
|
+
const current = nav.get('[aria-current="page"]');
|
|
166
|
+
expect(current.text()).toBe('1');
|
|
167
|
+
expect(nav.text()).toContain('Previous');
|
|
168
|
+
expect(nav.text()).toContain('Next');
|
|
169
|
+
|
|
170
|
+
const pageTwo = nav.findAll('a').find((link) => link.attributes('aria-label') === 'Page 2')!;
|
|
171
|
+
expect(pageTwo.attributes('href')).toBe('/journal?page=2');
|
|
172
|
+
|
|
173
|
+
const prevControls = nav.findAll('[aria-disabled="true"]');
|
|
174
|
+
expect(prevControls.length).toBeGreaterThan(0);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('shows the last page as disabled at the end and hides pagination for one page', async () => {
|
|
178
|
+
const wrapper = mountBlock(
|
|
179
|
+
{ ...withImages, viewAllHref: '/journal', perPage: '3' },
|
|
180
|
+
{ page: 2 }
|
|
181
|
+
);
|
|
182
|
+
await flushPromises();
|
|
183
|
+
const nav = wrapper.get('nav[aria-label="Journal pages"]');
|
|
184
|
+
const current = nav.get('[aria-current="page"]');
|
|
185
|
+
expect(current.text()).toBe('2');
|
|
186
|
+
const disabled = nav.findAll('[aria-disabled="true"]');
|
|
187
|
+
expect(disabled.length).toBeGreaterThan(0);
|
|
188
|
+
|
|
189
|
+
const onePage = mountBlock({ ...withImages, viewAllHref: '/journal', perPage: '12' });
|
|
190
|
+
await flushPromises();
|
|
191
|
+
expect(onePage.find('nav[aria-label="Journal pages"]').exists()).toBe(false);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('perPage larger than the list renders every item on the one page, with no padding or duplication', async () => {
|
|
195
|
+
const wrapper = mountBlock({ ...withImages, perPage: '12' }); // withImages has 5 items
|
|
196
|
+
await flushPromises();
|
|
197
|
+
const titles = wrapper.findAll('h3').map((h) => h.text());
|
|
198
|
+
expect(titles).toEqual(withImages.items.map((item) => item.title));
|
|
199
|
+
expect(wrapper.findAll('li[class]').length).toBeGreaterThanOrEqual(titles.length);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('a page number beyond totalPages clamps to the last real page instead of rendering blank', async () => {
|
|
203
|
+
const wrapper = mountBlock(
|
|
204
|
+
{ ...withImages, viewAllHref: '/journal', perPage: '3' },
|
|
205
|
+
{ page: 99 }
|
|
206
|
+
);
|
|
207
|
+
await flushPromises();
|
|
208
|
+
// withImages has 5 items at perPage 3, so totalPages is 2 — page 99 clamps to it.
|
|
209
|
+
const nav = wrapper.get('nav[aria-label="Journal pages"]');
|
|
210
|
+
expect(nav.get('[aria-current="page"]').text()).toBe('2');
|
|
211
|
+
const titles = wrapper.findAll('h3').map((h) => h.text());
|
|
212
|
+
expect(titles).toEqual(withImages.items.slice(3, 5).map((item) => item.title));
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('drops a card with an unsafe href instead of rendering a broken link', async () => {
|
|
216
|
+
const wrapper = mountBlock({
|
|
217
|
+
...mock,
|
|
218
|
+
items: [
|
|
219
|
+
{ title: 'Bad story', href: 'javascript:alert(1)' },
|
|
220
|
+
{ title: 'Good story', href: '/journal/good-story' },
|
|
221
|
+
],
|
|
222
|
+
});
|
|
223
|
+
await flushPromises();
|
|
224
|
+
expect(wrapper.text()).not.toContain('Bad story');
|
|
225
|
+
expect(wrapper.text()).toContain('Good story');
|
|
226
|
+
expect(
|
|
227
|
+
wrapper.findAll('a').some((a) => (a.attributes('href') ?? '').startsWith('javascript'))
|
|
228
|
+
).toBe(false);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('list variant hides the excerpt below 48rem of block width', async () => {
|
|
232
|
+
const wrapper = mountBlock({ ...withImages, variant: 'list' });
|
|
233
|
+
await flushPromises();
|
|
234
|
+
const excerpt = wrapper.find('[data-part="excerpt"]');
|
|
235
|
+
expect(excerpt.exists()).toBe(true);
|
|
236
|
+
expect(excerpt.classes()).toContain('@max-tablet:hidden');
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('renders the empty state with a working "View all stories" link and no pagination', async () => {
|
|
240
|
+
const wrapper = mountBlock({ ...mock, items: [], viewAllHref: '/journal' });
|
|
241
|
+
await flushPromises();
|
|
242
|
+
expect(wrapper.text()).toContain(mock.emptyTitle);
|
|
243
|
+
expect(wrapper.text()).toContain(mock.emptyText);
|
|
244
|
+
const link = wrapper.get('a');
|
|
245
|
+
expect(link.text()).toContain(mock.viewAllLabel);
|
|
246
|
+
expect(link.attributes('href')).toBe('/journal');
|
|
247
|
+
expect(wrapper.find('nav[aria-label="Journal pages"]').exists()).toBe(false);
|
|
248
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it('renders the empty state with no "view all" anchor when viewAllHref is empty — the seeded state', async () => {
|
|
252
|
+
// `showFilters` chips are a separate `href` field and still render their own anchors, so this
|
|
253
|
+
// checks specifically for the empty-state action link, not any anchor.
|
|
254
|
+
const wrapper = mountBlock({ ...mock, items: [], showFilters: false });
|
|
255
|
+
await flushPromises();
|
|
256
|
+
expect(wrapper.text()).toContain(mock.emptyTitle);
|
|
257
|
+
expect(wrapper.text()).toContain(mock.emptyText);
|
|
258
|
+
expect(wrapper.find('a').exists()).toBe(false);
|
|
259
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('shows the freshly inserted items hint while editing instead of the empty state', async () => {
|
|
263
|
+
const wrapper = mountBlock({ ...mock, items: [] }, { editing: true });
|
|
264
|
+
await flushPromises();
|
|
265
|
+
expect(wrapper.text()).toContain('Showing your latest stories');
|
|
266
|
+
expect(wrapper.text()).not.toContain(mock.emptyTitle);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('shows the heading editor hint only while editing, and renders no heading live', async () => {
|
|
270
|
+
const editingWrapper = mountBlock({ ...mock, heading: '' }, { editing: true });
|
|
271
|
+
await flushPromises();
|
|
272
|
+
expect(editingWrapper.text()).toContain('Add a heading');
|
|
273
|
+
|
|
274
|
+
const liveWrapper = mountBlock({ ...mock, heading: '' });
|
|
275
|
+
await flushPromises();
|
|
276
|
+
expect(liveWrapper.find('h2').exists()).toBe(false);
|
|
277
|
+
expect(liveWrapper.text()).not.toContain('Add a heading');
|
|
278
|
+
});
|
|
279
|
+
});
|