@eldrajs/theme-cli 0.0.0-stage → 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 +27 -2
- 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 +56 -3
- 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,288 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Team: a grid of the people behind the shop, each with a photo, name, role, short bio and
|
|
4
|
+
* optional links (spec `02-blocks.md` 2102–2192, "Team"). No `variant` field.
|
|
5
|
+
*
|
|
6
|
+
* Every person is one shared shape at every breakpoint — only the surrounding `<ul>`/`<li>` change
|
|
7
|
+
* their layout through container queries, the same "one card shape, sized differently" split
|
|
8
|
+
* `testimonials` uses for its own `figure`. Breakpoints follow this codebase's own container-query
|
|
9
|
+
* scale (`packages/ui/src/styles/tailwind.css`): the spec's "36rem of the block's own width" is
|
|
10
|
+
* this package's extra `@two-col` variant (`--container-two-col: 36rem`), and "64rem" is `@content`
|
|
11
|
+
* (`--container-content`) — never a viewport media query.
|
|
12
|
+
*
|
|
13
|
+
* Layout (spec → Layout):
|
|
14
|
+
* - Below `@two-col` (36rem): one column of rows (`grid-cols-1`, `gap-y-6` = 1.5rem apart). Each
|
|
15
|
+
* `<li>` is a row (`flex`): a 6.5rem-wide 4:5 photo beside the body, 1rem gap, top-aligned.
|
|
16
|
+
* - From `@two-col`: 2 columns (`gap-y-12`/`gap-x-6` = 3rem row × 1.5rem column gap); each `<li>`
|
|
17
|
+
* switches to a column (`flex-col`) so the photo sits above the text, still a 1rem gap, and the
|
|
18
|
+
* photo grows to the column's own width instead of staying a fixed 6.5rem thumbnail.
|
|
19
|
+
* - From `@content` (64rem): 4 columns, in the `wide` (80rem) container.
|
|
20
|
+
* - A single rendered person caps the whole grid at 18rem (`isSinglePerson`), the same "cap and
|
|
21
|
+
* centre a lone item" move `testimonials`' grid variant makes for one review.
|
|
22
|
+
*
|
|
23
|
+
* `people[].photo` is optional (spec States, "No image"): with no photo, the person becomes
|
|
24
|
+
* text-only with a 1px `border-t` rule and 1rem top padding so the grid still reads as a set — the
|
|
25
|
+
* same "top rule instead of a card" convention `stats`' own item border uses, applied per item here
|
|
26
|
+
* rather than to a whole grid.
|
|
27
|
+
*
|
|
28
|
+
* Icon links (`people[].links`) resolve through `@eldrajs/ui`'s `Button` (`variant="ghost"`,
|
|
29
|
+
* `iconOnly`, `size="sm"` — the spec's 2rem target), the same `#leadingIcon` + `EldraIcon` recipe
|
|
30
|
+
* `footer`'s own social row uses: the button's `label` prop is its one accessible-name prop (see
|
|
31
|
+
* `Button.vue`'s own `ariaLabel` computed — `iconOnly` always names the control from `label`, never
|
|
32
|
+
* a package-wide `ariaLabel` prop, which this component set only gives to `Section`/`Carousel`/
|
|
33
|
+
* `Tabs`/`Lightbox`/`Drawer`/`SearchModal`/`ChipGroup`/`Pagination`/`AvatarGroup`), and the icon
|
|
34
|
+
* itself stays `aria-hidden` (`EldraIcon` with no `label` of its own — `Icon.vue`'s default). A
|
|
35
|
+
* `mailto:` href passes `safeHref` like any other (`app/utils/links.ts` allows the `mailto:`
|
|
36
|
+
* protocol), and a same-site `href` (never expected among these five link types in practice, but
|
|
37
|
+
* handled the same way every other block does) routes through `EldraRouterLink`.
|
|
38
|
+
*
|
|
39
|
+
* "Live: only people with a name or role render; editing: every person renders, including a
|
|
40
|
+
* freshly seeded blank repeater item, which shows its own hint instead of vanishing" is the same
|
|
41
|
+
* split `testimonials`/`stats` use for their own list items. The whole section additionally gates
|
|
42
|
+
* on there being at least one real person at all (`hasPeople || isEditing`) — spec States, "Empty
|
|
43
|
+
* (freshly inserted)": "Live site renders nothing for an empty list" — the same "the list is the
|
|
44
|
+
* one thing this block cannot do without" reasoning `faq` applies to its own `items`.
|
|
45
|
+
*/
|
|
46
|
+
import { computed } from 'vue';
|
|
47
|
+
import { Button, Container, EditorPlaceholder, Link, Section } from '@eldrajs/ui';
|
|
48
|
+
import type { SectionBackground } from '@eldrajs/ui';
|
|
49
|
+
import { useBlockData } from '../../app/composables/useBlockData';
|
|
50
|
+
import { useEditing } from '../../app/composables/useEditing';
|
|
51
|
+
import { useI18n } from 'vue-i18n';
|
|
52
|
+
import { useUiId } from '../../app/composables/useUiId';
|
|
53
|
+
import EldraIcon from '../../app/components/EldraIcon.vue';
|
|
54
|
+
import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
|
|
55
|
+
import type { ThemeIconName } from '../../app/icons';
|
|
56
|
+
import UiImage from '../../app/components/ui/UiImage.vue';
|
|
57
|
+
import { isInternalHref, safeHref } from '../../app/utils/links';
|
|
58
|
+
|
|
59
|
+
const props = defineProps<{ entry: EldraBlockEntry<'team'> }>();
|
|
60
|
+
const { data } = useBlockData(props, 'team');
|
|
61
|
+
const { t } = useI18n();
|
|
62
|
+
const isEditing = useEditing();
|
|
63
|
+
const headingId = `team-heading-${useUiId()}`;
|
|
64
|
+
|
|
65
|
+
const sectionBackground = computed<SectionBackground>(() => data.value.sectionBackground ?? 'none');
|
|
66
|
+
|
|
67
|
+
const heading = computed(() => (data.value.heading ?? '').trim());
|
|
68
|
+
const hasHeading = computed(() => heading.value !== '');
|
|
69
|
+
const showHeadingHint = computed(() => isEditing.value && !hasHeading.value);
|
|
70
|
+
|
|
71
|
+
const intro = computed(() => (data.value.intro ?? '').trim());
|
|
72
|
+
const hasIntro = computed(() => intro.value !== '');
|
|
73
|
+
|
|
74
|
+
const linkHref = computed(() => safeHref(data.value.linkHref));
|
|
75
|
+
const hasLink = computed(() => Boolean(data.value.linkLabel) && linkHref.value !== null);
|
|
76
|
+
const linkAs = computed(() =>
|
|
77
|
+
linkHref.value !== null && isInternalHref(linkHref.value) ? EldraRouterLink : undefined
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const hasHead = computed(
|
|
81
|
+
() => hasHeading.value || hasIntro.value || hasLink.value || showHeadingHint.value
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
interface PersonLink {
|
|
85
|
+
type?: 'instagram' | 'email' | 'website' | 'tiktok' | 'pinterest';
|
|
86
|
+
href?: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface Person {
|
|
90
|
+
photo?: EldraMedia;
|
|
91
|
+
name?: string;
|
|
92
|
+
role?: string;
|
|
93
|
+
bio?: string;
|
|
94
|
+
links?: PersonLink[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function isPersonEmpty(person: Person): boolean {
|
|
98
|
+
return (person.name ?? '').trim() === '' && (person.role ?? '').trim() === '';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const allPeople = computed<Person[]>(() => data.value.people ?? []);
|
|
102
|
+
/** Editing always shows at least one item: a genuinely empty `people` list (a block just dragged
|
|
103
|
+
* onto the page, before Studio's own repeater has seeded anything) still gets one synthetic blank
|
|
104
|
+
* person so its "Add a person" hint has somewhere to render (spec → States, "Empty (freshly
|
|
105
|
+
* inserted)": "a striped 4:5 photo placeholder and 'Add a person'"). */
|
|
106
|
+
const editorPeople = computed<Person[]>(() =>
|
|
107
|
+
allPeople.value.length > 0 ? allPeople.value : [{}]
|
|
108
|
+
);
|
|
109
|
+
/** Live: only people with a name or role render (Global Constraints, "Editor vs live"); editing:
|
|
110
|
+
* every person renders, so a still-empty repeater item shows its own hint instead of vanishing. */
|
|
111
|
+
const renderedPeople = computed(() =>
|
|
112
|
+
isEditing.value ? editorPeople.value : allPeople.value.filter((person) => !isPersonEmpty(person))
|
|
113
|
+
);
|
|
114
|
+
const hasPeople = computed(() => renderedPeople.value.length > 0);
|
|
115
|
+
|
|
116
|
+
/** Spec "Team" → Layout: "A single person's grid is capped at 18rem wide." */
|
|
117
|
+
const isSinglePerson = computed(() => renderedPeople.value.length === 1);
|
|
118
|
+
const gridClass = computed(() => [
|
|
119
|
+
'grid grid-cols-1 gap-y-6 @two-col:grid-cols-2 @two-col:gap-x-6 @two-col:gap-y-12 @content:grid-cols-4',
|
|
120
|
+
isSinglePerson.value ? 'mx-auto max-w-[18rem]' : '',
|
|
121
|
+
]);
|
|
122
|
+
|
|
123
|
+
/** Typed against the theme's own icon set, so a name it does not bundle is a type error. */
|
|
124
|
+
const ICON_NAMES: Record<NonNullable<PersonLink['type']>, ThemeIconName> = {
|
|
125
|
+
instagram: 'brand-instagram',
|
|
126
|
+
email: 'mail',
|
|
127
|
+
website: 'world',
|
|
128
|
+
tiktok: 'brand-tiktok',
|
|
129
|
+
pinterest: 'brand-pinterest',
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const NAME_KEYS: Record<NonNullable<PersonLink['type']>, MessageKey> = {
|
|
133
|
+
instagram: 'team.onInstagram',
|
|
134
|
+
email: 'team.emailPerson',
|
|
135
|
+
website: 'team.website',
|
|
136
|
+
tiktok: 'team.onTiktok',
|
|
137
|
+
pinterest: 'team.onPinterest',
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
interface ResolvedLink {
|
|
141
|
+
type: NonNullable<PersonLink['type']>;
|
|
142
|
+
href: string;
|
|
143
|
+
as: typeof EldraRouterLink | undefined;
|
|
144
|
+
icon: string;
|
|
145
|
+
label: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Drops a link with no known type or an unsafe/missing href — the same "skip, don't crash" shape
|
|
149
|
+
* `footer`'s own `resolveLinks` uses. */
|
|
150
|
+
function resolveLinks(person: Person): ResolvedLink[] {
|
|
151
|
+
const name = person.name ?? '';
|
|
152
|
+
return (person.links ?? []).flatMap((link) => {
|
|
153
|
+
const type = link.type;
|
|
154
|
+
const href = safeHref(link.href);
|
|
155
|
+
// A `type` outside the field's own option set (stale content after an option is removed, or
|
|
156
|
+
// a hand-edited entry) has no icon and no name template, so the link is skipped rather than
|
|
157
|
+
// crashing the whole block on a missing message key.
|
|
158
|
+
if (type === undefined || !(type in ICON_NAMES) || href === null) return [];
|
|
159
|
+
return [
|
|
160
|
+
{
|
|
161
|
+
type,
|
|
162
|
+
href,
|
|
163
|
+
as: isInternalHref(href) ? EldraRouterLink : undefined,
|
|
164
|
+
icon: ICON_NAMES[type],
|
|
165
|
+
label: t(NAME_KEYS[type], { name }),
|
|
166
|
+
},
|
|
167
|
+
];
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
interface DisplayPerson extends Person {
|
|
172
|
+
resolvedLinks: ResolvedLink[];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Resolved once per person per render (not re-derived per icon in the template), the same
|
|
176
|
+
* "compute the list once" shape `footer`'s own `socialLinks` computed uses. */
|
|
177
|
+
const displayPeople = computed<DisplayPerson[]>(() =>
|
|
178
|
+
renderedPeople.value.map((person) => ({ ...person, resolvedLinks: resolveLinks(person) }))
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
/** Spec "Team" → Keyboard & accessibility: "Photo alt defaults to 'Portrait of {name}' (the editor
|
|
182
|
+
* can override it)." An explicit, non-empty `altText` always wins. */
|
|
183
|
+
function photoAlt(person: Person): string {
|
|
184
|
+
const altText = (person.photo?.altText ?? '').trim();
|
|
185
|
+
return altText !== '' ? altText : t('team.portraitOf', { name: person.name ?? '' });
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** Spec "Team" → States, "No image": a person with no photo gets a 1px top rule instead — not
|
|
189
|
+
* applied to a still-empty editor placeholder, which draws its own dashed border. */
|
|
190
|
+
function itemClass(person: Person): string {
|
|
191
|
+
if (isEditing.value && isPersonEmpty(person)) return '';
|
|
192
|
+
return person.photo ? '' : 'border-border border-t pt-4';
|
|
193
|
+
}
|
|
194
|
+
</script>
|
|
195
|
+
|
|
196
|
+
<template>
|
|
197
|
+
<Section
|
|
198
|
+
v-if="hasPeople || isEditing"
|
|
199
|
+
:background="sectionBackground"
|
|
200
|
+
spacing="md"
|
|
201
|
+
:labelled-by="headingId"
|
|
202
|
+
>
|
|
203
|
+
<Container width="wide">
|
|
204
|
+
<div v-if="hasHead" class="mb-8 flex flex-wrap items-end justify-between gap-x-8 gap-y-4">
|
|
205
|
+
<div class="max-w-[40rem]">
|
|
206
|
+
<h2
|
|
207
|
+
v-if="hasHeading"
|
|
208
|
+
:id="headingId"
|
|
209
|
+
class="font-heading @tablet:text-h2 text-[1.625rem] leading-[1.15] font-bold tracking-[-0.015em]"
|
|
210
|
+
>
|
|
211
|
+
{{ heading }}
|
|
212
|
+
</h2>
|
|
213
|
+
<EditorPlaceholder
|
|
214
|
+
v-else-if="showHeadingHint"
|
|
215
|
+
:id="headingId"
|
|
216
|
+
inline
|
|
217
|
+
:label="t('team.headingHintLabel')"
|
|
218
|
+
:help="t('team.headingHintHelp')"
|
|
219
|
+
/>
|
|
220
|
+
<p v-if="hasIntro" class="text-muted mt-2 text-base">{{ intro }}</p>
|
|
221
|
+
</div>
|
|
222
|
+
<Link
|
|
223
|
+
v-if="hasLink"
|
|
224
|
+
:href="linkHref!"
|
|
225
|
+
:as="linkAs"
|
|
226
|
+
variant="standalone"
|
|
227
|
+
arrow
|
|
228
|
+
:underline="false"
|
|
229
|
+
>
|
|
230
|
+
{{ data.linkLabel }}
|
|
231
|
+
</Link>
|
|
232
|
+
</div>
|
|
233
|
+
|
|
234
|
+
<ul role="list" :class="gridClass">
|
|
235
|
+
<li
|
|
236
|
+
v-for="(person, index) in displayPeople"
|
|
237
|
+
:key="index"
|
|
238
|
+
class="@two-col:flex-col flex gap-4"
|
|
239
|
+
:class="itemClass(person)"
|
|
240
|
+
>
|
|
241
|
+
<EditorPlaceholder
|
|
242
|
+
v-if="isEditing && isPersonEmpty(person)"
|
|
243
|
+
inline
|
|
244
|
+
class="w-full"
|
|
245
|
+
:label="t('team.itemHintLabel')"
|
|
246
|
+
:help="t('team.itemHintHelp')"
|
|
247
|
+
/>
|
|
248
|
+
<template v-else>
|
|
249
|
+
<UiImage
|
|
250
|
+
v-if="person.photo"
|
|
251
|
+
:src="person.photo.url"
|
|
252
|
+
:alt="photoAlt(person)"
|
|
253
|
+
:framing="person.photo.framing ?? null"
|
|
254
|
+
aspect="4/5"
|
|
255
|
+
rounded="lg"
|
|
256
|
+
class="@two-col:w-full @two-col:shrink w-[6.5rem] shrink-0"
|
|
257
|
+
/>
|
|
258
|
+
<div class="flex min-w-0 flex-col gap-1">
|
|
259
|
+
<h3 class="font-heading text-[1.125rem] font-semibold">{{ person.name }}</h3>
|
|
260
|
+
<p class="text-muted text-body-sm font-semibold">{{ person.role }}</p>
|
|
261
|
+
<p v-if="person.bio" class="text-muted text-body-sm mt-1">{{ person.bio }}</p>
|
|
262
|
+
<ul
|
|
263
|
+
v-if="person.resolvedLinks.length > 0"
|
|
264
|
+
role="list"
|
|
265
|
+
class="-ml-2 flex items-center gap-1"
|
|
266
|
+
>
|
|
267
|
+
<li v-for="link in person.resolvedLinks" :key="link.type">
|
|
268
|
+
<Button
|
|
269
|
+
icon-only
|
|
270
|
+
variant="ghost"
|
|
271
|
+
size="sm"
|
|
272
|
+
:href="link.href"
|
|
273
|
+
:as="link.as"
|
|
274
|
+
:label="link.label"
|
|
275
|
+
>
|
|
276
|
+
<template #leadingIcon>
|
|
277
|
+
<EldraIcon :name="link.icon" size="sm" />
|
|
278
|
+
</template>
|
|
279
|
+
</Button>
|
|
280
|
+
</li>
|
|
281
|
+
</ul>
|
|
282
|
+
</div>
|
|
283
|
+
</template>
|
|
284
|
+
</li>
|
|
285
|
+
</ul>
|
|
286
|
+
</Container>
|
|
287
|
+
</Section>
|
|
288
|
+
</template>
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { mount } from '@vue/test-utils';
|
|
3
|
+
import { ELDRA_KEY } from '@eldrajs/theme-vue';
|
|
4
|
+
import { axe } from '../../../test/support/axe';
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
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
|
+
|
|
11
|
+
/** `mock.json` is Studio's insert seed (no media); `preview.json` is the demo-imagery overlay a
|
|
12
|
+
* story/preview merges on top of it — same shallow-merge shape `testimonials`'s own test uses. */
|
|
13
|
+
const withMedia = { ...mock, ...preview };
|
|
14
|
+
|
|
15
|
+
/** The genuinely minimal fixture: only the fields the block requires. */
|
|
16
|
+
const bare = {
|
|
17
|
+
heading: mock.heading,
|
|
18
|
+
people: [{ name: 'A. Baker', role: 'Team member' }],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const SECTION_BACKGROUNDS = ['none', 'surface', 'surface-strong'] as const;
|
|
22
|
+
|
|
23
|
+
/** The injected fetcher still resolves through a promise; flush one microtask/macrotask turn
|
|
24
|
+
* before asserting on icon markup — the same wait `feature-grid`'s own spec uses. */
|
|
25
|
+
async function flushIcons(): Promise<void> {
|
|
26
|
+
await new Promise((resolve) => setTimeout(resolve));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function mountBlock(data: Record<string, unknown>, options: { editing?: boolean } = {}) {
|
|
30
|
+
const base = mountOptions({ entry: { id: 'e1', data } });
|
|
31
|
+
const opts = {
|
|
32
|
+
...base,
|
|
33
|
+
};
|
|
34
|
+
if (options.editing) {
|
|
35
|
+
const context = opts.global.provide[ELDRA_KEY] as {
|
|
36
|
+
preview: { active: boolean; mode: string };
|
|
37
|
+
};
|
|
38
|
+
context.preview.active = true;
|
|
39
|
+
context.preview.mode = 'edit';
|
|
40
|
+
}
|
|
41
|
+
return mount(Block, opts);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The outer people grid is the first `<ul>` in the block (a person's own icon-link row is a
|
|
45
|
+
* second, nested `<ul>`) — its direct `<li>` children are the people. */
|
|
46
|
+
function personItems(wrapper: ReturnType<typeof mountBlock>): Element[] {
|
|
47
|
+
const grid = wrapper.findAll('ul')[0]!;
|
|
48
|
+
return Array.from(grid.element.querySelectorAll(':scope > li'));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
describe('team block', () => {
|
|
52
|
+
it('renders the full (mock + preview) content with no axe violations', async () => {
|
|
53
|
+
const wrapper = mountBlock(withMedia);
|
|
54
|
+
expect(wrapper.text()).toContain(withMedia.heading);
|
|
55
|
+
expect(wrapper.text()).toContain(withMedia.intro);
|
|
56
|
+
for (const person of withMedia.people) expect(wrapper.text()).toContain(person.name);
|
|
57
|
+
await flushIcons();
|
|
58
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('renders no header link when linkHref is empty, even with linkLabel set — the seeded state', () => {
|
|
62
|
+
const wrapper = mountBlock(mock);
|
|
63
|
+
expect(wrapper.text()).not.toContain(mock.linkLabel);
|
|
64
|
+
// Each person's own social links still render — only the header's own link is gated.
|
|
65
|
+
const personLinkCount = mock.people.flatMap((p) => p.links ?? []).length;
|
|
66
|
+
expect(wrapper.findAll('a')).toHaveLength(personLinkCount);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('renders the bare, required-fields-only content with no axe violations', async () => {
|
|
70
|
+
const wrapper = mountBlock(bare);
|
|
71
|
+
expect(wrapper.text()).toContain(bare.heading);
|
|
72
|
+
expect(wrapper.text()).toContain(bare.people[0]!.name);
|
|
73
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it.each(SECTION_BACKGROUNDS)(
|
|
77
|
+
'renders sectionBackground "%s" with no axe violations',
|
|
78
|
+
async (sectionBackground) => {
|
|
79
|
+
const wrapper = mountBlock({ ...withMedia, sectionBackground });
|
|
80
|
+
await flushIcons();
|
|
81
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
it('defaults sectionBackground to none when unset', () => {
|
|
86
|
+
const { sectionBackground: _omit, ...withoutBackground } = mock;
|
|
87
|
+
const wrapper = mountBlock(withoutBackground);
|
|
88
|
+
expect(wrapper.get('section').attributes('data-section-bg')).toBe('none');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('people are a <ul> of <li> with each name as an <h3> under the block’s own <h2>', () => {
|
|
92
|
+
const wrapper = mountBlock(mock);
|
|
93
|
+
const heading = wrapper.get('h2');
|
|
94
|
+
const grid = wrapper.findAll('ul')[0]!;
|
|
95
|
+
expect(
|
|
96
|
+
heading.element.compareDocumentPosition(grid.element) & Node.DOCUMENT_POSITION_FOLLOWING
|
|
97
|
+
).toBeTruthy();
|
|
98
|
+
const names = wrapper.findAll('h3').map((h) => h.text());
|
|
99
|
+
expect(names).toEqual(mock.people.map((person) => person.name));
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("names every icon link with the person's name, and keeps the icon itself aria-hidden", async () => {
|
|
103
|
+
const wrapper = mountBlock(mock);
|
|
104
|
+
await flushIcons();
|
|
105
|
+
for (const person of mock.people) {
|
|
106
|
+
for (const link of person.links ?? []) {
|
|
107
|
+
const anchor = wrapper.get(`a[href="${link.href}"]`);
|
|
108
|
+
expect(anchor.attributes('aria-label')).toContain(person.name);
|
|
109
|
+
expect(anchor.get('svg').attributes('aria-hidden')).toBe('true');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('defaults photo alt to "Portrait of {name}", and an explicit altText wins', () => {
|
|
115
|
+
const wrapper = mountBlock(withMedia);
|
|
116
|
+
const firstPerson = withMedia.people[0]!;
|
|
117
|
+
const firstImg = wrapper.findAll('img')[0]!;
|
|
118
|
+
expect(firstImg.attributes('alt')).toBe(`Portrait of ${firstPerson.name}`);
|
|
119
|
+
|
|
120
|
+
const customAlt = 'Ingrid at the market stall, laughing';
|
|
121
|
+
const overridden = {
|
|
122
|
+
...withMedia,
|
|
123
|
+
people: withMedia.people.map((person, index) =>
|
|
124
|
+
index === 0 ? { ...person, photo: { ...person.photo, altText: customAlt } } : person
|
|
125
|
+
),
|
|
126
|
+
};
|
|
127
|
+
const overriddenWrapper = mountBlock(overridden);
|
|
128
|
+
expect(overriddenWrapper.findAll('img')[0]!.attributes('alt')).toBe(customAlt);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('with no photos every item carries the top-rule class, and nothing renders an <img>', () => {
|
|
132
|
+
const wrapper = mountBlock(mock);
|
|
133
|
+
expect(wrapper.find('img').exists()).toBe(false);
|
|
134
|
+
const items = personItems(wrapper);
|
|
135
|
+
expect(items).toHaveLength(mock.people.length);
|
|
136
|
+
for (const item of items) {
|
|
137
|
+
expect(item.classList.contains('border-t')).toBe(true);
|
|
138
|
+
expect(item.classList.contains('pt-4')).toBe(true);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('caps a single person’s grid at 18rem', () => {
|
|
143
|
+
const wrapper = mountBlock({ ...mock, people: [mock.people[0]] });
|
|
144
|
+
const grid = wrapper.findAll('ul')[0]!;
|
|
145
|
+
expect(grid.classes()).toEqual(expect.arrayContaining(['mx-auto', 'max-w-[18rem]']));
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('does not cap the grid when there is more than one person', () => {
|
|
149
|
+
const wrapper = mountBlock(mock);
|
|
150
|
+
const grid = wrapper.findAll('ul')[0]!;
|
|
151
|
+
expect(grid.classes()).not.toContain('max-w-[18rem]');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('renders 12 people as 12 list items', () => {
|
|
155
|
+
const people = Array.from({ length: 12 }, (_, index) => ({
|
|
156
|
+
name: `Person ${index + 1}`,
|
|
157
|
+
role: 'Team member',
|
|
158
|
+
}));
|
|
159
|
+
const wrapper = mountBlock({ ...mock, people });
|
|
160
|
+
expect(personItems(wrapper)).toHaveLength(12);
|
|
161
|
+
expect(wrapper.findAll('h3')).toHaveLength(12);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
describe('empty people', () => {
|
|
165
|
+
it('renders nothing live when people is empty', () => {
|
|
166
|
+
const wrapper = mountBlock({ ...mock, people: [] });
|
|
167
|
+
expect(wrapper.find('section').exists()).toBe(false);
|
|
168
|
+
expect(wrapper.text()).toBe('');
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('shows heading and person hints in the editor when people is empty, with no axe violations', async () => {
|
|
172
|
+
const wrapper = mountBlock({ ...mock, heading: '', people: [] }, { editing: true });
|
|
173
|
+
expect(wrapper.find('section').exists()).toBe(true);
|
|
174
|
+
expect(wrapper.text()).toContain('Add a heading');
|
|
175
|
+
expect(wrapper.text()).toContain('Add a person');
|
|
176
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('shows an editor-only hint for a still-empty person, and renders it live as nothing', async () => {
|
|
180
|
+
const data = { ...mock, people: [{ name: '', role: '' }] };
|
|
181
|
+
const live = mountBlock(data);
|
|
182
|
+
expect(live.find('section').exists()).toBe(false);
|
|
183
|
+
|
|
184
|
+
const editing = mountBlock(data, { editing: true });
|
|
185
|
+
expect(editing.text()).toContain('Add a person');
|
|
186
|
+
expect(await axe(editing.element)).toHaveNoViolations();
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
describe('keyboard path', () => {
|
|
191
|
+
it('Tab reaches the header link, then each person’s links, in reading order', () => {
|
|
192
|
+
const linkHref = '/pages/makers';
|
|
193
|
+
const wrapper = mountBlock({ ...mock, linkHref });
|
|
194
|
+
const hrefs = wrapper.findAll('a').map((a) => a.attributes('href'));
|
|
195
|
+
const expected = [
|
|
196
|
+
linkHref,
|
|
197
|
+
...mock.people.flatMap((person) => (person.links ?? []).map((link) => link.href)),
|
|
198
|
+
];
|
|
199
|
+
expect(hrefs).toEqual(expected);
|
|
200
|
+
// Nothing anywhere in the block carries an explicit tabindex, so nothing is pulled out of
|
|
201
|
+
// or reordered within the natural document tab order.
|
|
202
|
+
expect(wrapper.findAll('[tabindex]')).toHaveLength(0);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('skips a link whose type is outside the option set instead of failing the render', async () => {
|
|
207
|
+
const people = [
|
|
208
|
+
{
|
|
209
|
+
...mock.people[0]!,
|
|
210
|
+
links: [
|
|
211
|
+
{ type: 'myspace', href: 'https://myspace.example/ingrid' },
|
|
212
|
+
{ type: 'email', href: 'mailto:ingrid@northwind.example' },
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
|
+
];
|
|
216
|
+
const wrapper = mountBlock({ ...mock, people });
|
|
217
|
+
expect(wrapper.findAll('li a')).toHaveLength(1);
|
|
218
|
+
expect(wrapper.find('li a').attributes('href')).toBe('mailto:ingrid@northwind.example');
|
|
219
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
220
|
+
});
|
|
221
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
{
|
|
2
|
+
"apiId": "team",
|
|
3
|
+
"name": "Team",
|
|
4
|
+
"description": "A grid of the people behind the shop, each with a photo, name, role, short bio and optional links.",
|
|
5
|
+
"icon": "users",
|
|
6
|
+
"category": "marketing",
|
|
7
|
+
"version": 1,
|
|
8
|
+
"fields": [
|
|
9
|
+
{
|
|
10
|
+
"fieldId": "heading",
|
|
11
|
+
"name": "Heading",
|
|
12
|
+
"type": "string",
|
|
13
|
+
"isTitle": true,
|
|
14
|
+
"localized": true,
|
|
15
|
+
"helpText": "Rendered as an h2.",
|
|
16
|
+
"validators": { "required": true }
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"fieldId": "intro",
|
|
20
|
+
"name": "Intro",
|
|
21
|
+
"type": "text",
|
|
22
|
+
"localized": true,
|
|
23
|
+
"helpText": "One or two sentences."
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"fieldId": "linkLabel",
|
|
27
|
+
"name": "Link label",
|
|
28
|
+
"type": "string",
|
|
29
|
+
"localized": true,
|
|
30
|
+
"helpText": "Header link, e.g. \"Meet our makers\"."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"fieldId": "linkHref",
|
|
34
|
+
"name": "Link",
|
|
35
|
+
"type": "string"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"fieldId": "people",
|
|
39
|
+
"name": "People",
|
|
40
|
+
"type": "list",
|
|
41
|
+
"helpText": "1-12 people. Multiples of 4 fill the desktop grid.",
|
|
42
|
+
"metadata": {
|
|
43
|
+
"item": {
|
|
44
|
+
"fieldId": "person",
|
|
45
|
+
"name": "Person",
|
|
46
|
+
"type": "composite",
|
|
47
|
+
"metadata": {
|
|
48
|
+
"fields": [
|
|
49
|
+
{
|
|
50
|
+
"fieldId": "photo",
|
|
51
|
+
"name": "Photo",
|
|
52
|
+
"type": "media",
|
|
53
|
+
"helpText": "Portrait 4:5 with a focal point.",
|
|
54
|
+
"metadata": { "multiple": false, "framing": true, "framingAspectRatio": "4/5" }
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"fieldId": "name",
|
|
58
|
+
"name": "Name",
|
|
59
|
+
"type": "string",
|
|
60
|
+
"localized": true,
|
|
61
|
+
"helpText": "Rendered as an h3.",
|
|
62
|
+
"validators": { "required": true }
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"fieldId": "role",
|
|
66
|
+
"name": "Role",
|
|
67
|
+
"type": "string",
|
|
68
|
+
"localized": true,
|
|
69
|
+
"helpText": "For example \"Head potter\".",
|
|
70
|
+
"validators": { "required": true }
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"fieldId": "bio",
|
|
74
|
+
"name": "Bio",
|
|
75
|
+
"type": "text",
|
|
76
|
+
"localized": true,
|
|
77
|
+
"helpText": "About 120 characters maximum.",
|
|
78
|
+
"validators": { "maxLength": 120 }
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"fieldId": "links",
|
|
82
|
+
"name": "Links",
|
|
83
|
+
"type": "list",
|
|
84
|
+
"helpText": "Up to 3.",
|
|
85
|
+
"metadata": {
|
|
86
|
+
"item": {
|
|
87
|
+
"fieldId": "link",
|
|
88
|
+
"name": "Link",
|
|
89
|
+
"type": "composite",
|
|
90
|
+
"metadata": {
|
|
91
|
+
"fields": [
|
|
92
|
+
{
|
|
93
|
+
"fieldId": "type",
|
|
94
|
+
"name": "Type",
|
|
95
|
+
"type": "select",
|
|
96
|
+
"metadata": {
|
|
97
|
+
"options": ["instagram", "email", "website", "tiktok", "pinterest"]
|
|
98
|
+
},
|
|
99
|
+
"validators": { "required": true }
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"fieldId": "href",
|
|
103
|
+
"name": "URL",
|
|
104
|
+
"type": "string",
|
|
105
|
+
"validators": { "required": true }
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"fieldId": "sectionBackground",
|
|
119
|
+
"name": "Section background",
|
|
120
|
+
"type": "select",
|
|
121
|
+
"helpText": "none is the default.",
|
|
122
|
+
"metadata": { "options": ["none", "surface", "surface-strong"] }
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"heading": "The people behind the parcels",
|
|
3
|
+
"intro": "Eleven of us in Portland, and 38 makers we work with directly.",
|
|
4
|
+
"linkLabel": "Meet our makers",
|
|
5
|
+
"linkHref": "",
|
|
6
|
+
"people": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Ingrid Solberg",
|
|
9
|
+
"role": "Founder and buyer",
|
|
10
|
+
"bio": "Started Northwind on a market stall in 2014 and still chooses every piece we stock.",
|
|
11
|
+
"links": [
|
|
12
|
+
{ "type": "instagram", "href": "https://instagram.com/ingrid.northwind" },
|
|
13
|
+
{ "type": "email", "href": "mailto:ingrid@northwind.example" }
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "Tomás Ferreira",
|
|
18
|
+
"role": "Head potter",
|
|
19
|
+
"bio": "Throws about sixty mugs a day. Found our speckled glaze by accident in 2016.",
|
|
20
|
+
"links": [{ "type": "instagram", "href": "https://instagram.com/tomas.throws" }]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "Aiko Mori",
|
|
24
|
+
"role": "Weaver",
|
|
25
|
+
"bio": "Runs the 1960s Dobcross loom and teaches the Saturday weaving class.",
|
|
26
|
+
"links": [
|
|
27
|
+
{ "type": "instagram", "href": "https://instagram.com/aiko.weaves" },
|
|
28
|
+
{ "type": "website", "href": "https://aikomori.example" }
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "Dele Okafor",
|
|
33
|
+
"role": "Customer care lead",
|
|
34
|
+
"bio": "Answers your emails, sorts your returns and knows where every parcel is.",
|
|
35
|
+
"links": [{ "type": "email", "href": "mailto:dele@northwind.example" }]
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"sectionBackground": "none"
|
|
39
|
+
}
|