@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,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The buy box's stock line, derived — not stored. Spec `02-blocks.md` "Product detail" → States
|
|
3
|
+
* gives four mutually exclusive states, each with its own tone, icon and words, and one of them
|
|
4
|
+
* (low stock) is allowed to appear *only* when real inventory is at or below the author's
|
|
5
|
+
* threshold. Keeping that decision in one pure function is what lets `__tests__/stock.spec.ts`
|
|
6
|
+
* prove the whole matrix — including the combinations the Northwind demo catalogue cannot reach —
|
|
7
|
+
* without mounting anything, and keeps `Block.vue` free of branching over four states in its
|
|
8
|
+
* template.
|
|
9
|
+
*
|
|
10
|
+
* Every string is returned as a `MessageKey` plus its interpolation params, never as text: the
|
|
11
|
+
* block renders it through `useT()` so both locales stay in step (Global Constraints, "Strings").
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** The four states, in the order `deriveStockLine` tests them. */
|
|
15
|
+
export type StockState = 'out' | 'backorder' | 'low' | 'in';
|
|
16
|
+
|
|
17
|
+
/** `lowStockThreshold`'s stored values. `off` never shows "only N left" at all. */
|
|
18
|
+
export type LowStockThreshold = 'off' | '3' | '5' | '10';
|
|
19
|
+
|
|
20
|
+
export interface StockLineInput {
|
|
21
|
+
/**
|
|
22
|
+
* The product-level signal from the storefront source (`StorefrontProductListItem.stock`).
|
|
23
|
+
* `preorder` is what makes a product a back-order; `out` marks the whole product sold out.
|
|
24
|
+
*/
|
|
25
|
+
stock: 'in' | 'low' | 'out' | 'preorder';
|
|
26
|
+
/** Real units of the variant the buy box is selling, or `null` when they are not known for it
|
|
27
|
+
* (`StorefrontProduct.inventory`). */
|
|
28
|
+
inventory: number | null;
|
|
29
|
+
/** Whether the selected combination of options can be bought at all. */
|
|
30
|
+
variantAvailable: boolean;
|
|
31
|
+
/** The selected combination, already joined for display ("Oat / M"). Empty for an option-less product. */
|
|
32
|
+
variantLabel: string;
|
|
33
|
+
/** The author's threshold. Anything but `off` arms the low-stock line. Required, not optional:
|
|
34
|
+
* the field's own default (`3`) belongs to the block, so this function never invents one. */
|
|
35
|
+
threshold: LowStockThreshold;
|
|
36
|
+
/** The date the next batch ships, for the back-order line (`StorefrontProduct.shipsBy`). */
|
|
37
|
+
shipsBy?: string | null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface StockLine {
|
|
41
|
+
state: StockState;
|
|
42
|
+
/** Drives the colour of the words and the icon. */
|
|
43
|
+
tone: 'success' | 'warning' | 'danger';
|
|
44
|
+
/** A Tabler outline icon name — one per state, so the state is never colour alone (1.4.1). */
|
|
45
|
+
icon: 'circle-check' | 'alert-triangle' | 'circle-x' | 'clock';
|
|
46
|
+
/** `@eldrajs/ui`'s own `StockBadge` level this state draws through. */
|
|
47
|
+
level: 'in' | 'low' | 'out' | 'preorder';
|
|
48
|
+
key: MessageKey;
|
|
49
|
+
params?: Record<string, string | number>;
|
|
50
|
+
/** The explanatory line under the status, when the state has one. */
|
|
51
|
+
noteKey?: MessageKey;
|
|
52
|
+
/** The quantity stepper's own maximum: real inventory when the store tracks it. */
|
|
53
|
+
max: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Spec's own wording for an option-less product, where "Sold out in Oat / M" has no variant to
|
|
57
|
+
* name: the params are still passed, so the message keys below are chosen per case instead. */
|
|
58
|
+
const NO_VARIANT = '';
|
|
59
|
+
|
|
60
|
+
const THRESHOLD_COUNT: Record<Exclude<LowStockThreshold, 'off'>, number> = {
|
|
61
|
+
'3': 3,
|
|
62
|
+
'5': 5,
|
|
63
|
+
'10': 10,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** `QuantityStepper`'s own default maximum, for a store that does not track units. */
|
|
67
|
+
const UNTRACKED_MAX = 99;
|
|
68
|
+
|
|
69
|
+
function thresholdCount(threshold: LowStockThreshold): number | null {
|
|
70
|
+
return threshold === 'off' ? null : (THRESHOLD_COUNT[threshold] ?? null);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Tested in order, so a sold-out variant never also reads "low stock", and a back-order never
|
|
75
|
+
* reads "in stock":
|
|
76
|
+
*
|
|
77
|
+
* 1. **Sold out** — the selected combination is unavailable, the whole product is out, or real
|
|
78
|
+
* inventory has reached zero. `danger`, circle-x, plus the restock note.
|
|
79
|
+
* 2. **Back-order** — the product is made to order (`preorder`). `warning`, clock, plus the
|
|
80
|
+
* reserve-one note. Deliberately above the low-stock rule: spec States, Low stock row —
|
|
81
|
+
* "Never shown for made-to-order items".
|
|
82
|
+
* 3. **Low stock** — real, tracked inventory at or below the author's threshold. `warning`,
|
|
83
|
+
* alert-triangle. Never without a threshold, never from the coarse `stock: 'low'` flag alone:
|
|
84
|
+
* spec Do — "show 'Only N left' only from live inventory".
|
|
85
|
+
* 4. **In stock** — everything else. `success`, circle-check.
|
|
86
|
+
*/
|
|
87
|
+
export function deriveStockLine(input: StockLineInput): StockLine {
|
|
88
|
+
const { stock, inventory, variantAvailable, variantLabel } = input;
|
|
89
|
+
const named = variantLabel !== NO_VARIANT;
|
|
90
|
+
const max = inventory !== null && inventory > 0 ? inventory : UNTRACKED_MAX;
|
|
91
|
+
|
|
92
|
+
// A made-to-order product legitimately tracks zero units on hand: `preorder` is decided before
|
|
93
|
+
// the zero-inventory rule so it never reads as sold out.
|
|
94
|
+
if (!variantAvailable || stock === 'out' || (inventory === 0 && stock !== 'preorder')) {
|
|
95
|
+
return {
|
|
96
|
+
state: 'out',
|
|
97
|
+
tone: 'danger',
|
|
98
|
+
icon: 'circle-x',
|
|
99
|
+
level: 'out',
|
|
100
|
+
key: named ? 'product.soldOutIn' : 'product.soldOut',
|
|
101
|
+
params: named ? { variant: variantLabel } : undefined,
|
|
102
|
+
noteKey: 'product.restockNote',
|
|
103
|
+
max: 1,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (stock === 'preorder') {
|
|
108
|
+
const shipsBy = (input.shipsBy ?? '').trim();
|
|
109
|
+
return {
|
|
110
|
+
state: 'backorder',
|
|
111
|
+
tone: 'warning',
|
|
112
|
+
icon: 'clock',
|
|
113
|
+
level: 'preorder',
|
|
114
|
+
key: shipsBy === '' ? 'product.backorderPending' : 'product.backorderShips',
|
|
115
|
+
params: shipsBy === '' ? undefined : { date: shipsBy },
|
|
116
|
+
noteKey: 'product.backorderNote',
|
|
117
|
+
max,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const limit = thresholdCount(input.threshold);
|
|
122
|
+
if (limit !== null && inventory !== null && inventory <= limit) {
|
|
123
|
+
return {
|
|
124
|
+
state: 'low',
|
|
125
|
+
tone: 'warning',
|
|
126
|
+
icon: 'alert-triangle',
|
|
127
|
+
level: 'low',
|
|
128
|
+
key: lowStockKey(inventory, named),
|
|
129
|
+
params: named ? { count: inventory, variant: variantLabel } : { count: inventory },
|
|
130
|
+
max,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
state: 'in',
|
|
136
|
+
tone: 'success',
|
|
137
|
+
icon: 'circle-check',
|
|
138
|
+
level: 'in',
|
|
139
|
+
key: 'product.inStock',
|
|
140
|
+
params: undefined,
|
|
141
|
+
max,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Pluralised the way `header.cartOne`/`cartMany` are, and split again by whether there is a
|
|
146
|
+
* variant to name — Icelandic inflects the noun, so neither can be a `{count}`-only template. */
|
|
147
|
+
function lowStockKey(count: number, named: boolean): MessageKey {
|
|
148
|
+
if (named) return count === 1 ? 'product.lowStockOneIn' : 'product.lowStockManyIn';
|
|
149
|
+
return count === 1 ? 'product.lowStockOne' : 'product.lowStockMany';
|
|
150
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* One large pull quote from the founder, a maker or the press, with attribution and an optional
|
|
4
|
+
* portrait (spec `02-blocks.md` 2302–2396, "Quote"). `variant`:
|
|
5
|
+
*
|
|
6
|
+
* - `centered`: quote mark, quote and attribution centred in the narrow (40rem) column. The
|
|
7
|
+
* name/role block beside the avatar always stays left-aligned itself — it sits inside a
|
|
8
|
+
* horizontal flex row whose own width tracks its content, so centring the row (via the figure's
|
|
9
|
+
* `items-center`) never centres the two lines of text stacked inside it.
|
|
10
|
+
* - `with-image`: from 48rem block width, a portrait (4:5, `radius-xl`) sits in a `5fr` column
|
|
11
|
+
* beside the left-aligned quote in `7fr` (3rem gap, 4rem from 64rem, vertically centred); below
|
|
12
|
+
* 48rem the image stacks above. With no image chosen yet it falls back to the same single,
|
|
13
|
+
* left-aligned column `centered` would use if it weren't centred — `figureAlignClass` alone
|
|
14
|
+
* (not `showImageLayout`) decides that alignment, so the fallback needs no extra branch.
|
|
15
|
+
*
|
|
16
|
+
* **Icon size and stroke (package wins).** The spec's quote mark is 3rem at a thin 1.25 stroke;
|
|
17
|
+
* `@eldrajs/ui`'s `Icon` only goes up to `xl` (2rem, `size-8`) and always draws at its own fixed
|
|
18
|
+
* 1.75 stroke — the same trade `feature-grid`'s and `pricing-table`'s own doc comments make for
|
|
19
|
+
* their icons, taken here rather than reaching around the primitive for a literal size or stroke.
|
|
20
|
+
*
|
|
21
|
+
* **`sourceLink`.** The spec's field → layout mapping is explicit: "role → line under the name
|
|
22
|
+
* (wrapped in `sourceLink` when set)" — the link's visible text is the role line itself, not a
|
|
23
|
+
* second, separately-worded string. `sourceLinkLabel` therefore becomes the link's accessible name
|
|
24
|
+
* (`aria-label`, passed straight through as a fallthrough attribute — `Link` has no such prop of
|
|
25
|
+
* its own) rather than separate visible copy: a role line like "Winter gift guide, 2025" doesn't
|
|
26
|
+
* describe its own destination on its own (WCAG 2.4.4), so a friendlier name ("Read the guide")
|
|
27
|
+
* announces instead while the shorter, dated line stays what's printed. The external example link
|
|
28
|
+
* in `mock.json` is not a same-site destination (`isInternalHref` is false for an absolute
|
|
29
|
+
* `https://` URL), so it renders as a plain `Link` with `href` — no `EldraRouterLink` routing.
|
|
30
|
+
*
|
|
31
|
+
* **Colour on `primary`/`accent`.** `Section` already sets the ground's own text colour on its root
|
|
32
|
+
* (`text-text` on `none`/`surface`/`surface-strong`, `text-primary-contrast`/`text-accent-contrast`
|
|
33
|
+
* on the two inverting grounds), and that is a normal inherited CSS `color` — so the quote paragraph
|
|
34
|
+
* and the `<cite>` name carry no colour class of their own and simply inherit whichever one is
|
|
35
|
+
* right. `Link` already inverts its own `muted` tone through its `group-data-[section=…]/section:`
|
|
36
|
+
* classes, so the role line needs no extra handling when it is a link. Only the two parts with no
|
|
37
|
+
* such built-in mechanism branch by hand: the quote mark (`accent` by default, since an `accent`
|
|
38
|
+
* mark would vanish on an `accent` ground) and the plain-text role line for when there is no
|
|
39
|
+
* `sourceLinkHref` to hand it to `Link`.
|
|
40
|
+
*/
|
|
41
|
+
import { computed } from 'vue';
|
|
42
|
+
import {
|
|
43
|
+
Avatar,
|
|
44
|
+
Container,
|
|
45
|
+
EditorPlaceholder,
|
|
46
|
+
Link,
|
|
47
|
+
Section,
|
|
48
|
+
VisuallyHidden,
|
|
49
|
+
type ContainerWidth,
|
|
50
|
+
type SectionBackground,
|
|
51
|
+
} from '@eldrajs/ui';
|
|
52
|
+
import { DEFAULT_IMAGE_FRAMING, type ImageFraming } from '@eldrajs/theme-vue';
|
|
53
|
+
import { useBlockData } from '../../app/composables/useBlockData';
|
|
54
|
+
import { useEditing } from '../../app/composables/useEditing';
|
|
55
|
+
import { useI18n } from 'vue-i18n';
|
|
56
|
+
import { useUiId } from '../../app/composables/useUiId';
|
|
57
|
+
import EldraIcon from '../../app/components/EldraIcon.vue';
|
|
58
|
+
import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
|
|
59
|
+
import UiImage from '../../app/components/ui/UiImage.vue';
|
|
60
|
+
import { isInternalHref, safeHref } from '../../app/utils/links';
|
|
61
|
+
|
|
62
|
+
const props = defineProps<{ entry: EldraBlockEntry<'quote'> }>();
|
|
63
|
+
const { data, entryId } = useBlockData(props, 'quote');
|
|
64
|
+
const { t } = useI18n();
|
|
65
|
+
const isEditing = useEditing();
|
|
66
|
+
const headingId = `quote-heading-${useUiId()}`;
|
|
67
|
+
|
|
68
|
+
const variant = computed(() => data.value.variant ?? 'centered');
|
|
69
|
+
const isWithImage = computed(() => variant.value === 'with-image');
|
|
70
|
+
|
|
71
|
+
const sectionBackground = computed<SectionBackground>(() => data.value.sectionBackground ?? 'none');
|
|
72
|
+
const containerWidth = computed<ContainerWidth>(() => (isWithImage.value ? 'content' : 'narrow'));
|
|
73
|
+
|
|
74
|
+
const quoteText = computed(() => (data.value.quote ?? '').trim());
|
|
75
|
+
const hasQuote = computed(() => quoteText.value !== '');
|
|
76
|
+
const nameText = computed(() => (data.value.name ?? '').trim());
|
|
77
|
+
const hasName = computed(() => nameText.value !== '');
|
|
78
|
+
const roleText = computed(() => (data.value.role ?? '').trim());
|
|
79
|
+
const hasRole = computed(() => roleText.value !== '');
|
|
80
|
+
|
|
81
|
+
/** Live: the whole block — the `Section` root included — renders nothing without a quote (spec
|
|
82
|
+
* States → Empty: "Live site renders nothing without a quote."), the same "gate the root itself"
|
|
83
|
+
* shape `announcement-bar`'s own empty state uses. Editing: always renders, so the empty-quote and
|
|
84
|
+
* empty-name hints have somewhere to show. */
|
|
85
|
+
const showBlock = computed(() => hasQuote.value || isEditing.value);
|
|
86
|
+
|
|
87
|
+
const image = computed(() => data.value.image ?? null);
|
|
88
|
+
const hasImage = computed(() => Boolean(image.value?.url));
|
|
89
|
+
/** `with-image` with no image yet falls back to the plain single column (spec States → "No
|
|
90
|
+
* image") — `figureAlignClass` below applies the same left alignment either way. */
|
|
91
|
+
const showImageLayout = computed(() => isWithImage.value && hasImage.value);
|
|
92
|
+
const imageFraming = computed<ImageFraming>(() => image.value?.framing ?? DEFAULT_IMAGE_FRAMING);
|
|
93
|
+
|
|
94
|
+
const avatarSrc = computed(() => data.value.avatar?.url);
|
|
95
|
+
|
|
96
|
+
const sourceHref = computed(() => safeHref(data.value.sourceLinkHref));
|
|
97
|
+
const sourceLinkLabelText = computed(() => (data.value.sourceLinkLabel ?? '').trim());
|
|
98
|
+
/** Nothing to wrap without a role line to show (see the module doc comment's `sourceLink` note). */
|
|
99
|
+
const hasSourceLink = computed(() => hasRole.value && sourceHref.value !== null);
|
|
100
|
+
const sourceLinkAs = computed(() =>
|
|
101
|
+
sourceHref.value !== null && isInternalHref(sourceHref.value) ? EldraRouterLink : undefined
|
|
102
|
+
);
|
|
103
|
+
const sourceLinkAriaLabel = computed(() =>
|
|
104
|
+
sourceLinkLabelText.value !== '' ? sourceLinkLabelText.value : undefined
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
/** The mark is `accent` at rest; on `primary`/`accent` it switches to that ground's contrast
|
|
108
|
+
* colour, same as the quote and the name (spec States → "On primary"/"On accent"). */
|
|
109
|
+
const markClass = computed(() => {
|
|
110
|
+
if (sectionBackground.value === 'primary') return 'text-primary-contrast';
|
|
111
|
+
if (sectionBackground.value === 'accent') return 'text-accent-contrast';
|
|
112
|
+
return 'text-accent';
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
/** Only for the plain-text role line (no `sourceLinkHref`) — `Link` already inverts its own
|
|
116
|
+
* `muted` tone when it is one. */
|
|
117
|
+
const roleToneClass = computed(() => {
|
|
118
|
+
if (sectionBackground.value === 'primary') return 'text-primary-contrast/90';
|
|
119
|
+
if (sectionBackground.value === 'accent') return 'text-accent-contrast/90';
|
|
120
|
+
return 'text-muted';
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
/** `centered`: quote mark, quote and attribution row centred. `with-image` (image or not): a
|
|
124
|
+
* single left-aligned column — see the module doc comment. */
|
|
125
|
+
const figureAlignClass = computed(() =>
|
|
126
|
+
isWithImage.value ? 'items-start text-left' : 'items-center text-center'
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
/** Spec Layout: 1.5rem below 48rem, 2rem from 48rem, 2.25rem from 64rem for `centered` — `with-
|
|
130
|
+
* image` stays at 2rem from 64rem. */
|
|
131
|
+
const quoteClass = computed(() => [
|
|
132
|
+
'font-heading font-medium leading-[1.3] tracking-[-0.01em] text-balance',
|
|
133
|
+
'text-[1.5rem] @tablet:text-[2rem]',
|
|
134
|
+
isWithImage.value ? '' : '@content:text-[2.25rem]',
|
|
135
|
+
]);
|
|
136
|
+
</script>
|
|
137
|
+
|
|
138
|
+
<template>
|
|
139
|
+
<Section v-if="showBlock" :background="sectionBackground" spacing="md" :labelled-by="headingId">
|
|
140
|
+
<Container :width="containerWidth">
|
|
141
|
+
<VisuallyHidden as="h2" :id="headingId">{{
|
|
142
|
+
t('quote.headingFor', { name: nameText })
|
|
143
|
+
}}</VisuallyHidden>
|
|
144
|
+
|
|
145
|
+
<div
|
|
146
|
+
class="grid gap-8"
|
|
147
|
+
:class="
|
|
148
|
+
showImageLayout
|
|
149
|
+
? '@tablet:grid-cols-[5fr_7fr] @tablet:items-center @tablet:gap-12 @content:gap-16'
|
|
150
|
+
: ''
|
|
151
|
+
"
|
|
152
|
+
>
|
|
153
|
+
<UiImage
|
|
154
|
+
v-if="showImageLayout"
|
|
155
|
+
:src="image!.url!"
|
|
156
|
+
:alt="image!.altText ?? ''"
|
|
157
|
+
:framing="imageFraming"
|
|
158
|
+
:entry-id="entryId"
|
|
159
|
+
field-path="image"
|
|
160
|
+
aspect="4/5"
|
|
161
|
+
rounded="xl"
|
|
162
|
+
/>
|
|
163
|
+
|
|
164
|
+
<figure class="flex flex-col gap-6" :class="figureAlignClass">
|
|
165
|
+
<EldraIcon name="quote" size="xl" :class="markClass" />
|
|
166
|
+
|
|
167
|
+
<blockquote v-if="hasQuote" :class="quoteClass">
|
|
168
|
+
<p>{{ quoteText }}</p>
|
|
169
|
+
</blockquote>
|
|
170
|
+
<EditorPlaceholder
|
|
171
|
+
v-else-if="isEditing"
|
|
172
|
+
inline
|
|
173
|
+
:label="t('quote.quoteHintLabel')"
|
|
174
|
+
:help="t('quote.quoteHintHelp')"
|
|
175
|
+
/>
|
|
176
|
+
|
|
177
|
+
<figcaption v-if="hasQuote" class="flex items-center gap-3 text-left">
|
|
178
|
+
<Avatar :src="avatarSrc" :name="nameText" size="lg" decorative />
|
|
179
|
+
<div class="min-w-0">
|
|
180
|
+
<cite v-if="hasName" class="block text-base font-semibold not-italic">{{
|
|
181
|
+
nameText
|
|
182
|
+
}}</cite>
|
|
183
|
+
<EditorPlaceholder v-else-if="isEditing" inline :label="t('quote.nameHintLabel')" />
|
|
184
|
+
|
|
185
|
+
<!-- The role line stays a block, but the link inside it is inline so its target is
|
|
186
|
+
the line box the text sits in (spec: "at least 1.5rem tall or inline"). -->
|
|
187
|
+
<p v-if="hasSourceLink" class="text-sm">
|
|
188
|
+
<Link
|
|
189
|
+
:href="sourceHref!"
|
|
190
|
+
:as="sourceLinkAs"
|
|
191
|
+
tone="muted"
|
|
192
|
+
:aria-label="sourceLinkAriaLabel"
|
|
193
|
+
>
|
|
194
|
+
{{ roleText }}
|
|
195
|
+
</Link>
|
|
196
|
+
</p>
|
|
197
|
+
<span v-else-if="hasRole" class="block text-sm" :class="roleToneClass">{{
|
|
198
|
+
roleText
|
|
199
|
+
}}</span>
|
|
200
|
+
</div>
|
|
201
|
+
</figcaption>
|
|
202
|
+
</figure>
|
|
203
|
+
</div>
|
|
204
|
+
</Container>
|
|
205
|
+
</Section>
|
|
206
|
+
</template>
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
//
|
|
3
|
+
// `EldraIcon` (the quote mark) resolves a Tabler icon by name through `useEldraIcon`, which reads
|
|
4
|
+
// it straight out of `app/icons.ts` — no server, no fetch, so a plain `mount()` renders it.
|
|
5
|
+
import { flushPromises, mount } from '@vue/test-utils';
|
|
6
|
+
import { describe, expect, it } from 'vitest';
|
|
7
|
+
import { ELDRA_KEY } from '@eldrajs/theme-vue';
|
|
8
|
+
import { axe } from '../../../test/support/axe';
|
|
9
|
+
import { mountOptions } from '../../../test/support/mountBlock';
|
|
10
|
+
import Block from '../Block.vue';
|
|
11
|
+
import mock from '../mock.json';
|
|
12
|
+
import preview from '../preview.json';
|
|
13
|
+
|
|
14
|
+
/** `mock.json` is Studio's insert seed (no media); `preview.json` is the demo-imagery overlay a
|
|
15
|
+
* story/preview merges on top of it — same shallow-merge shape `testimonials`'s own test uses. */
|
|
16
|
+
const withMedia = { ...mock, ...preview };
|
|
17
|
+
|
|
18
|
+
/** The genuinely minimal fixture: only the fields the block requires. */
|
|
19
|
+
const bare = { quote: 'Reliable, well made, arrived on time.', name: 'A. Customer' };
|
|
20
|
+
|
|
21
|
+
function mountBlock(data: Record<string, unknown>, options: { editing?: boolean } = {}) {
|
|
22
|
+
const base = mountOptions({ entry: { id: 'e1', data } });
|
|
23
|
+
const opts = {
|
|
24
|
+
...base,
|
|
25
|
+
};
|
|
26
|
+
if (options.editing) {
|
|
27
|
+
const context = opts.global.provide[ELDRA_KEY] as {
|
|
28
|
+
preview: { active: boolean; mode: string };
|
|
29
|
+
};
|
|
30
|
+
context.preview.active = true;
|
|
31
|
+
context.preview.mode = 'edit';
|
|
32
|
+
}
|
|
33
|
+
return mount(Block, opts);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
describe('quote block', () => {
|
|
37
|
+
it('renders the full (mock + preview) content with no axe violations', async () => {
|
|
38
|
+
const wrapper = mountBlock(withMedia);
|
|
39
|
+
expect(wrapper.text()).toContain(withMedia.quote);
|
|
40
|
+
expect(wrapper.text()).toContain(withMedia.name);
|
|
41
|
+
expect(wrapper.text()).toContain(withMedia.role);
|
|
42
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('renders the bare, required-fields-only content with no axe violations', async () => {
|
|
46
|
+
const wrapper = mountBlock(bare);
|
|
47
|
+
expect(wrapper.text()).toContain(bare.quote);
|
|
48
|
+
expect(wrapper.text()).toContain(bare.name);
|
|
49
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it.each(['centered', 'with-image'] as const)(
|
|
53
|
+
'renders the %s variant with no axe violations',
|
|
54
|
+
async (variant) => {
|
|
55
|
+
const wrapper = mountBlock({ ...withMedia, variant });
|
|
56
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
it.each(['primary', 'accent'] as const)(
|
|
61
|
+
'renders the %s section background with no axe violations',
|
|
62
|
+
async (sectionBackground) => {
|
|
63
|
+
const wrapper = mountBlock({ ...withMedia, sectionBackground });
|
|
64
|
+
const section = wrapper.get('section');
|
|
65
|
+
expect(section.attributes('data-section')).toBe(sectionBackground);
|
|
66
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
it('the block root is a labelled <section> that measures its own width (@container)', () => {
|
|
71
|
+
const wrapper = mountBlock(mock);
|
|
72
|
+
const section = wrapper.get('section');
|
|
73
|
+
expect(section.classes()).toContain('@container');
|
|
74
|
+
expect(section.attributes('aria-labelledby')).toBeTruthy();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('is structured as figure > blockquote + figcaption with a cite, labelled by a hidden heading', () => {
|
|
78
|
+
const wrapper = mountBlock(mock);
|
|
79
|
+
const heading = wrapper.get(`#${wrapper.get('section').attributes('aria-labelledby')}`);
|
|
80
|
+
expect(heading.element.tagName).toBe('H2');
|
|
81
|
+
expect(heading.text()).toBe(`Quote from ${mock.name}`);
|
|
82
|
+
expect(heading.classes()).toContain('sr-only');
|
|
83
|
+
|
|
84
|
+
const figure = wrapper.get('figure');
|
|
85
|
+
const blockquote = figure.get('blockquote');
|
|
86
|
+
const figcaption = figure.get('figcaption');
|
|
87
|
+
expect(blockquote.text()).toBe(mock.quote);
|
|
88
|
+
const cite = figcaption.get('cite');
|
|
89
|
+
expect(cite.text()).toBe(mock.name);
|
|
90
|
+
|
|
91
|
+
// The full accessible text (heading, then quote, then attribution) starts with the hidden
|
|
92
|
+
// heading (spec Keyboard & accessibility: "Assistive technology hears a 'Quote from {name}'
|
|
93
|
+
// heading, then the blockquote, then the attribution").
|
|
94
|
+
expect(wrapper.text().startsWith(heading.text())).toBe(true);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('the quote mark is aria-hidden', async () => {
|
|
98
|
+
const wrapper = mountBlock(mock);
|
|
99
|
+
await flushPromises();
|
|
100
|
+
const mark = wrapper.get('figure svg');
|
|
101
|
+
expect(mark.attributes('aria-hidden')).toBe('true');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('with-image and an image renders a portrait and no single-column fallback', () => {
|
|
105
|
+
const wrapper = mountBlock({ ...withMedia, variant: 'with-image' });
|
|
106
|
+
const image = wrapper.get('img');
|
|
107
|
+
expect(image.attributes('alt')).toBe(preview.image.altText);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('with-image and no image falls back to the single left-aligned column, with no <img>', () => {
|
|
111
|
+
const wrapper = mountBlock({ ...mock, variant: 'with-image' });
|
|
112
|
+
expect(wrapper.find('img').exists()).toBe(false);
|
|
113
|
+
const figure = wrapper.get('figure');
|
|
114
|
+
expect(figure.classes()).toContain('items-start');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('centered aligns the figure centrally', () => {
|
|
118
|
+
const wrapper = mountBlock({ ...mock, variant: 'centered' });
|
|
119
|
+
const figure = wrapper.get('figure');
|
|
120
|
+
expect(figure.classes()).toContain('items-center');
|
|
121
|
+
expect(figure.classes()).toContain('text-center');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('with an avatar field but no photo, the Avatar renders initials', () => {
|
|
125
|
+
const wrapper = mountBlock(mock);
|
|
126
|
+
expect(wrapper.find('img').exists()).toBe(false);
|
|
127
|
+
const initials = wrapper.get('[data-part="initials"]');
|
|
128
|
+
expect(initials.text().length).toBeGreaterThan(0);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('with an avatar photo, the Avatar renders it', () => {
|
|
132
|
+
const wrapper = mountBlock(withMedia);
|
|
133
|
+
const avatarImage = wrapper
|
|
134
|
+
.findAll('img')
|
|
135
|
+
.find((img) => img.attributes('src') === preview.avatar.url);
|
|
136
|
+
expect(avatarImage).toBeTruthy();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('the role line is plain text with no sourceLinkHref', () => {
|
|
140
|
+
const { sourceLinkHref: _omit, ...withoutLink } = mock;
|
|
141
|
+
const wrapper = mountBlock(withoutLink);
|
|
142
|
+
expect(wrapper.text()).toContain(mock.role);
|
|
143
|
+
expect(wrapper.findAll('a')).toHaveLength(0);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('the role line is a link, and a tab stop with the package focus ring, only with sourceLinkHref', () => {
|
|
147
|
+
const sourceLinkHref = 'https://thelarder.example/winter-gift-guide';
|
|
148
|
+
const wrapper = mountBlock({ ...mock, sourceLinkHref });
|
|
149
|
+
const link = wrapper.get('a');
|
|
150
|
+
expect(link.text()).toBe(mock.role);
|
|
151
|
+
expect(link.attributes('href')).toBe(sourceLinkHref);
|
|
152
|
+
expect(link.attributes('aria-label')).toBe(mock.sourceLinkLabel);
|
|
153
|
+
expect(link.classes()).toContain('eldra-focus');
|
|
154
|
+
const focusable = Array.from(wrapper.element.querySelectorAll('a, button, input, [tabindex]'));
|
|
155
|
+
expect(focusable).toContain(link.element);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('renders an external source link as a plain <a>, not the internal router link', () => {
|
|
159
|
+
const wrapper = mountBlock({
|
|
160
|
+
...mock,
|
|
161
|
+
sourceLinkHref: 'https://thelarder.example/winter-gift-guide',
|
|
162
|
+
});
|
|
163
|
+
const link = wrapper.get('a');
|
|
164
|
+
expect(link.element.tagName).toBe('A');
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('has no italic class anywhere in the block', () => {
|
|
168
|
+
const wrapper = mountBlock(withMedia);
|
|
169
|
+
for (const element of wrapper.element.querySelectorAll('*')) {
|
|
170
|
+
expect(Array.from(element.classList)).not.toContain('italic');
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('the quote mark is text-accent at rest', async () => {
|
|
175
|
+
const wrapper = mountBlock(mock);
|
|
176
|
+
await flushPromises();
|
|
177
|
+
const mark = wrapper.get('figure svg');
|
|
178
|
+
expect(mark.classes()).toContain('text-accent');
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('on primary, the mark carries the primary-contrast class', async () => {
|
|
182
|
+
const wrapper = mountBlock({ ...mock, sectionBackground: 'primary' });
|
|
183
|
+
await flushPromises();
|
|
184
|
+
const mark = wrapper.get('figure svg');
|
|
185
|
+
expect(mark.classes()).toContain('text-primary-contrast');
|
|
186
|
+
expect(mark.classes()).not.toContain('text-accent');
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('on accent, the mark carries the accent-contrast class, not text-accent', async () => {
|
|
190
|
+
const wrapper = mountBlock({ ...mock, sectionBackground: 'accent' });
|
|
191
|
+
await flushPromises();
|
|
192
|
+
const mark = wrapper.get('figure svg');
|
|
193
|
+
expect(mark.classes()).toContain('text-accent-contrast');
|
|
194
|
+
expect(mark.classes()).not.toContain('text-accent');
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("the quote and the name carry no fixed text colour class, so they inherit the section's own", () => {
|
|
198
|
+
const wrapper = mountBlock({ ...mock, sectionBackground: 'primary' });
|
|
199
|
+
expect(wrapper.get('blockquote').classes()).not.toContain('text-text');
|
|
200
|
+
expect(wrapper.get('cite').classes()).not.toContain('text-text');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('renders nothing live without a quote — not even the section root', () => {
|
|
204
|
+
const wrapper = mountBlock({ ...mock, quote: '' });
|
|
205
|
+
expect(wrapper.find('section').exists()).toBe(false);
|
|
206
|
+
expect(wrapper.find('figure').exists()).toBe(false);
|
|
207
|
+
expect(wrapper.text()).not.toContain('Add a quote');
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('shows the empty-quote hint only in the editor, with no axe violations', async () => {
|
|
211
|
+
const data = { ...mock, quote: '' };
|
|
212
|
+
const live = mountBlock(data);
|
|
213
|
+
expect(live.find('section').exists()).toBe(false);
|
|
214
|
+
expect(live.find('figure').exists()).toBe(false);
|
|
215
|
+
|
|
216
|
+
const editing = mountBlock(data, { editing: true });
|
|
217
|
+
expect(editing.find('figure').exists()).toBe(true);
|
|
218
|
+
expect(editing.text()).toContain('Add a quote');
|
|
219
|
+
expect(editing.text()).toContain('Then the name and role or source.');
|
|
220
|
+
expect(editing.find('blockquote').exists()).toBe(false);
|
|
221
|
+
expect(await axe(editing.element)).toHaveNoViolations();
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('shows the empty-name hint only in the editor once the quote is filled in', async () => {
|
|
225
|
+
const data = { ...mock, name: '' };
|
|
226
|
+
const live = mountBlock(data);
|
|
227
|
+
expect(live.find('cite').exists()).toBe(false);
|
|
228
|
+
expect(live.text()).not.toContain('Add a name');
|
|
229
|
+
|
|
230
|
+
const editing = mountBlock(data, { editing: true });
|
|
231
|
+
expect(editing.text()).toContain('Add a name');
|
|
232
|
+
expect(await axe(editing.element)).toHaveNoViolations();
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('defaults variant to centered and sectionBackground to none when unset', () => {
|
|
236
|
+
const { variant: _v, sectionBackground: _s, ...rest } = mock;
|
|
237
|
+
const wrapper = mountBlock(rest);
|
|
238
|
+
const figure = wrapper.get('figure');
|
|
239
|
+
expect(figure.classes()).toContain('items-center');
|
|
240
|
+
expect(wrapper.get('section').attributes('data-section-bg')).toBe('none');
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('an optional role with no sourceLinkHref renders as plain muted text', () => {
|
|
244
|
+
const { sourceLinkHref: _omit, sourceLinkLabel: _omit2, ...rest } = mock;
|
|
245
|
+
const wrapper = mountBlock(rest);
|
|
246
|
+
expect(wrapper.findAll('a')).toHaveLength(0);
|
|
247
|
+
expect(wrapper.text()).toContain(mock.role);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('omits the role line entirely when role is empty', () => {
|
|
251
|
+
const wrapper = mountBlock({ ...bare });
|
|
252
|
+
expect(wrapper.text()).not.toContain(mock.role);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('the role-line link is inline inside its own line box, never a shrunken block target', () => {
|
|
256
|
+
const wrapper = mountBlock({
|
|
257
|
+
...mock,
|
|
258
|
+
sourceLinkHref: 'https://thelarder.example/winter-gift-guide',
|
|
259
|
+
});
|
|
260
|
+
const link = wrapper.get('figcaption a');
|
|
261
|
+
expect(link.classes()).not.toContain('block');
|
|
262
|
+
expect(link.element.parentElement?.tagName).toBe('P');
|
|
263
|
+
expect(link.text()).toBe(mock.role);
|
|
264
|
+
});
|
|
265
|
+
});
|