@eldrajs/theme-cli 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -0
- package/LICENSE +21 -0
- package/README.md +26 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +203 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.js +3 -0
- package/dist/validate-DprFpjV7.js +535 -0
- package/package.json +50 -2
- package/template/.eldra/block-types.d.ts +429 -0
- package/template/.eldra/manifest.json +9378 -0
- package/template/.eldra/previews.json +36 -0
- package/template/.github/workflows/eldra-deploy.yml +24 -0
- package/template/.gitlab-ci.yml +16 -0
- package/template/.storybook/eldra.ts +123 -0
- package/template/.storybook/i18n.ts +23 -0
- package/template/.storybook/main.ts +59 -0
- package/template/.storybook/nuxt-link-stub.ts +23 -0
- package/template/.storybook/preview.ts +53 -0
- package/template/.storybook/shims-vue.d.ts +10 -0
- package/template/.storybook/virtual-eldra.d.ts +32 -0
- package/template/README.md +293 -0
- package/template/app/app.vue +126 -0
- package/template/app/assets/main.css +404 -0
- package/template/app/components/EldraIcon.vue +66 -0
- package/template/app/components/EldraRouterLink.vue +62 -0
- package/template/app/components/ui/UiImage.stories.ts +30 -0
- package/template/app/components/ui/UiImage.vue +224 -0
- package/template/app/components/ui/__tests__/UiImage.spec.ts +292 -0
- package/template/app/composables/iconComponent.ts +84 -0
- package/template/app/composables/iconFetcher.ts +14 -0
- package/template/app/composables/useBlockData.ts +30 -0
- package/template/app/composables/useEditing.ts +31 -0
- package/template/app/composables/useEldraIcon.ts +46 -0
- package/template/app/composables/useRevalidating.ts +69 -0
- package/template/app/composables/useRichTextScrollRegions.ts +80 -0
- package/template/app/composables/useStorefront.ts +18 -0
- package/template/app/composables/useStorefrontFeedback.ts +49 -0
- package/template/app/composables/useUiId.ts +18 -0
- package/template/app/composables/useWishlist.ts +42 -0
- package/template/app/i18n.d.ts +28 -0
- package/template/app/icons.ts +185 -0
- package/template/app/pages/[...slug].vue +134 -0
- package/template/app/plugins/eldra-i18n.ts +98 -0
- package/template/app/plugins/eldra-storefront.ts +288 -0
- package/template/app/plugins/eldra-ui-messages.ts +112 -0
- package/template/app/storefront/cart.ts +245 -0
- package/template/app/storefront/categories.ts +283 -0
- package/template/app/storefront/collectionSelector.ts +60 -0
- package/template/app/storefront/commerce.ts +58 -0
- package/template/app/storefront/demo.ts +1313 -0
- package/template/app/storefront/facets.ts +476 -0
- package/template/app/storefront/feedback.ts +122 -0
- package/template/app/storefront/gateway.ts +2256 -0
- package/template/app/storefront/history.ts +233 -0
- package/template/app/storefront/money.ts +248 -0
- package/template/app/storefront/options.ts +71 -0
- package/template/app/storefront/prerender.ts +77 -0
- package/template/app/storefront/refresh.ts +222 -0
- package/template/app/storefront/toProductCard.ts +154 -0
- package/template/app/storefront/types.ts +815 -0
- package/template/app/storefront/volatile.ts +211 -0
- package/template/app/templates.ts +544 -0
- package/template/app/utils/classes.ts +40 -0
- package/template/app/utils/links.ts +70 -0
- package/template/app/utils/pageStructure.ts +77 -0
- package/template/app/utils/pageTitle.ts +37 -0
- package/template/app/virtual-eldra.d.ts +12 -0
- package/template/bitbucket-pipelines.yml +19 -0
- package/template/blocks/announcement-bar/Block.vue +203 -0
- package/template/blocks/announcement-bar/__tests__/Block.spec.ts +227 -0
- package/template/blocks/announcement-bar/block.json +45 -0
- package/template/blocks/announcement-bar/mock.json +7 -0
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/Block.vue +317 -0
- package/template/blocks/article/__tests__/Block.spec.ts +229 -0
- package/template/blocks/article/block.json +148 -0
- package/template/blocks/article/mock.json +512 -0
- package/template/blocks/article/preview.json +16 -0
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/Block.vue +343 -0
- package/template/blocks/article-list/__tests__/Block.spec.ts +279 -0
- package/template/blocks/article-list/block.json +181 -0
- package/template/blocks/article-list/mock.json +68 -0
- package/template/blocks/article-list/preview.json +84 -0
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/Block.vue +278 -0
- package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +461 -0
- package/template/blocks/breadcrumbs/block.json +89 -0
- package/template/blocks/breadcrumbs/mock.json +11 -0
- package/template/blocks/breadcrumbs/preview.json +3 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/Block.vue +372 -0
- package/template/blocks/cart/__tests__/Block.spec.ts +561 -0
- package/template/blocks/cart/__tests__/ShippingBar.spec.ts +78 -0
- package/template/blocks/cart/__tests__/Summary.spec.ts +245 -0
- package/template/blocks/cart/block.json +74 -0
- package/template/blocks/cart/mock.json +11 -0
- package/template/blocks/cart/parts/CartLines.vue +257 -0
- package/template/blocks/cart/parts/ShippingBar.vue +105 -0
- package/template/blocks/cart/parts/Summary.vue +291 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +1832 -0
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +3037 -0
- package/template/blocks/collection-grid/__tests__/groups.spec.ts +731 -0
- package/template/blocks/collection-grid/block.json +187 -0
- package/template/blocks/collection-grid/mock.json +23 -0
- package/template/blocks/collection-grid/parts/groups.ts +861 -0
- package/template/blocks/collection-grid/preview.json +7 -0
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +533 -0
- package/template/blocks/collection-header/__tests__/Block.spec.ts +381 -0
- package/template/blocks/collection-header/block.json +140 -0
- package/template/blocks/collection-header/mock.json +28 -0
- package/template/blocks/collection-header/preview.json +14 -0
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/Block.vue +621 -0
- package/template/blocks/contact/__tests__/Block.spec.ts +347 -0
- package/template/blocks/contact/block.json +174 -0
- package/template/blocks/contact/mock.json +28 -0
- package/template/blocks/contact/preview.json +9 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/Block.vue +383 -0
- package/template/blocks/cta/__tests__/Block.spec.ts +309 -0
- package/template/blocks/cta/block.json +86 -0
- package/template/blocks/cta/mock.json +10 -0
- package/template/blocks/cta/preview.json +9 -0
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/Block.vue +254 -0
- package/template/blocks/faq/__tests__/Block.spec.ts +312 -0
- package/template/blocks/faq/block.json +113 -0
- package/template/blocks/faq/mock.json +115 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/Block.vue +241 -0
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +311 -0
- package/template/blocks/feature-grid/block.json +106 -0
- package/template/blocks/feature-grid/mock.json +29 -0
- package/template/blocks/feature-grid/preview.json +45 -0
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +652 -0
- package/template/blocks/footer/__tests__/Block.spec.ts +700 -0
- package/template/blocks/footer/block.json +240 -0
- package/template/blocks/footer/mock.json +161 -0
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/gallery/Block.vue +416 -0
- package/template/blocks/gallery/__tests__/Block.spec.ts +289 -0
- package/template/blocks/gallery/block.json +87 -0
- package/template/blocks/gallery/mock.json +16 -0
- package/template/blocks/gallery/preview.json +64 -0
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +378 -0
- package/template/blocks/hero/__tests__/Block.spec.ts +324 -0
- package/template/blocks/hero/block.json +146 -0
- package/template/blocks/hero/mock.json +11 -0
- package/template/blocks/hero/preview.json +55 -0
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/Block.vue +232 -0
- package/template/blocks/image/__tests__/Block.spec.ts +224 -0
- package/template/blocks/image/block.json +67 -0
- package/template/blocks/image/mock.json +7 -0
- package/template/blocks/image/preview.json +9 -0
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/Block.vue +206 -0
- package/template/blocks/logo-cloud/__tests__/Block.spec.ts +210 -0
- package/template/blocks/logo-cloud/block.json +79 -0
- package/template/blocks/logo-cloud/mock.json +15 -0
- package/template/blocks/logo-cloud/preview.json +92 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +1348 -0
- package/template/blocks/navigation/__tests__/Block.spec.ts +2030 -0
- package/template/blocks/navigation/block.json +167 -0
- package/template/blocks/navigation/mock.json +191 -0
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/navigation/useMegaMenuKeys.ts +276 -0
- package/template/blocks/newsletter/Block.vue +399 -0
- package/template/blocks/newsletter/__tests__/Block.spec.ts +365 -0
- package/template/blocks/newsletter/block.json +105 -0
- package/template/blocks/newsletter/mock.json +31 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/Block.vue +754 -0
- package/template/blocks/order-status/__tests__/Block.spec.ts +515 -0
- package/template/blocks/order-status/block.json +138 -0
- package/template/blocks/order-status/mock.json +19 -0
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/Block.vue +297 -0
- package/template/blocks/pricing-table/__tests__/Block.spec.ts +357 -0
- package/template/blocks/pricing-table/block.json +155 -0
- package/template/blocks/pricing-table/mock.json +47 -0
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +459 -0
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +957 -0
- package/template/blocks/product-carousel/block.json +71 -0
- package/template/blocks/product-carousel/mock.json +9 -0
- package/template/blocks/product-carousel/preview.json +7 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +886 -0
- package/template/blocks/product-detail/__tests__/Block.spec.ts +1492 -0
- package/template/blocks/product-detail/__tests__/stock.spec.ts +119 -0
- package/template/blocks/product-detail/block.json +155 -0
- package/template/blocks/product-detail/mock.json +113 -0
- package/template/blocks/product-detail/parts/Gallery.vue +181 -0
- package/template/blocks/product-detail/parts/StickyBuyBar.vue +99 -0
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/product-detail/stock.ts +150 -0
- package/template/blocks/quote/Block.vue +206 -0
- package/template/blocks/quote/__tests__/Block.spec.ts +265 -0
- package/template/blocks/quote/block.json +76 -0
- package/template/blocks/quote/mock.json +9 -0
- package/template/blocks/quote/preview.json +16 -0
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/Block.vue +143 -0
- package/template/blocks/rich-text/__tests__/Block.spec.ts +191 -0
- package/template/blocks/rich-text/block.json +57 -0
- package/template/blocks/rich-text/mock.json +87 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +589 -0
- package/template/blocks/search/PopularChips.vue +40 -0
- package/template/blocks/search/TypeSection.vue +148 -0
- package/template/blocks/search/__tests__/Block.spec.ts +718 -0
- package/template/blocks/search/__tests__/results.spec.ts +166 -0
- package/template/blocks/search/block.json +102 -0
- package/template/blocks/search/mock.json +18 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/search/results.ts +85 -0
- package/template/blocks/split-content/Block.vue +195 -0
- package/template/blocks/split-content/__tests__/Block.spec.ts +225 -0
- package/template/blocks/split-content/block.json +70 -0
- package/template/blocks/split-content/mock.json +45 -0
- package/template/blocks/split-content/preview.json +58 -0
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/Block.vue +159 -0
- package/template/blocks/stats/__tests__/Block.spec.ts +194 -0
- package/template/blocks/stats/block.json +73 -0
- package/template/blocks/stats/mock.json +12 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/Block.vue +278 -0
- package/template/blocks/tabs/__tests__/Block.spec.ts +303 -0
- package/template/blocks/tabs/block.json +97 -0
- package/template/blocks/tabs/mock.json +129 -0
- package/template/blocks/tabs/preview.json +153 -0
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/Block.vue +288 -0
- package/template/blocks/team/__tests__/Block.spec.ts +221 -0
- package/template/blocks/team/block.json +125 -0
- package/template/blocks/team/mock.json +39 -0
- package/template/blocks/team/preview.json +62 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/Block.vue +408 -0
- package/template/blocks/testimonials/__tests__/Block.spec.ts +319 -0
- package/template/blocks/testimonials/block.json +121 -0
- package/template/blocks/testimonials/mock.json +46 -0
- package/template/blocks/testimonials/preview.json +68 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/Block.vue +274 -0
- package/template/blocks/timeline/__tests__/Block.spec.ts +310 -0
- package/template/blocks/timeline/block.json +98 -0
- package/template/blocks/timeline/mock.json +27 -0
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +330 -0
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +290 -0
- package/template/blocks/trust-strip/block.json +117 -0
- package/template/blocks/trust-strip/mock.json +37 -0
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/Block.vue +354 -0
- package/template/blocks/video-embed/__tests__/Block.spec.ts +219 -0
- package/template/blocks/video-embed/__tests__/embed.spec.ts +76 -0
- package/template/blocks/video-embed/block.json +94 -0
- package/template/blocks/video-embed/embed.ts +84 -0
- package/template/blocks/video-embed/mock.json +13 -0
- package/template/blocks/video-embed/preview.json +9 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/Block.vue +367 -0
- package/template/blocks/wishlist/__tests__/Block.spec.ts +508 -0
- package/template/blocks/wishlist/block.json +42 -0
- package/template/blocks/wishlist/mock.json +9 -0
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +602 -0
- package/template/i18n/is-IS.json +602 -0
- package/template/nuxt.config.ts +156 -0
- package/template/package.json +56 -0
- package/template/pages/article.page.json +731 -0
- package/template/pages/cart.page.json +85 -0
- package/template/pages/category.page.json +133 -0
- package/template/pages/collection.page.json +194 -0
- package/template/pages/home.page.json +353 -0
- package/template/pages/product.page.json +323 -0
- package/template/pages/products.page.json +144 -0
- package/template/pages/search.page.json +83 -0
- package/template/pages/wishlist.page.json +88 -0
- package/template/public/apple-touch-icon.png +0 -0
- package/template/public/demo/article-cover.svg +1 -0
- package/template/public/demo/article-figure.svg +1 -0
- package/template/public/demo/avatar-1.svg +3 -0
- package/template/public/demo/avatar-2.svg +3 -0
- package/template/public/demo/avatar-3.svg +3 -0
- package/template/public/demo/avatar-4.svg +3 -0
- package/template/public/demo/avatar-5.svg +3 -0
- package/template/public/demo/avatar-6.svg +3 -0
- package/template/public/demo/avatar-7.svg +3 -0
- package/template/public/demo/avatar-8.svg +3 -0
- package/template/public/demo/collection-1.svg +1 -0
- package/template/public/demo/collection-2.svg +1 -0
- package/template/public/demo/cta-split.svg +1 -0
- package/template/public/demo/feature-1.svg +1 -0
- package/template/public/demo/feature-2.svg +1 -0
- package/template/public/demo/feature-3.svg +1 -0
- package/template/public/demo/feature-4.svg +1 -0
- package/template/public/demo/gallery-1.svg +1 -0
- package/template/public/demo/gallery-2.svg +1 -0
- package/template/public/demo/gallery-3.svg +1 -0
- package/template/public/demo/gallery-4.svg +1 -0
- package/template/public/demo/gallery-5.svg +1 -0
- package/template/public/demo/gallery-6.svg +1 -0
- package/template/public/demo/gallery-7.svg +1 -0
- package/template/public/demo/gallery-8.svg +1 -0
- package/template/public/demo/hero-slide-1.svg +1 -0
- package/template/public/demo/hero-slide-2.svg +1 -0
- package/template/public/demo/hero-slide-3.svg +1 -0
- package/template/public/demo/hero-slide-4.svg +1 -0
- package/template/public/demo/hero-wide.svg +1 -0
- package/template/public/demo/hero.svg +1 -0
- package/template/public/demo/logo-1.svg +4 -0
- package/template/public/demo/logo-2.svg +4 -0
- package/template/public/demo/logo-3.svg +4 -0
- package/template/public/demo/logo-4.svg +4 -0
- package/template/public/demo/logo-5.svg +4 -0
- package/template/public/demo/logo-6.svg +4 -0
- package/template/public/demo/logo-7.svg +4 -0
- package/template/public/demo/logo-8.svg +4 -0
- package/template/public/demo/logo.svg +3 -0
- package/template/public/demo/map.svg +1 -0
- package/template/public/demo/poster.svg +1 -0
- package/template/public/demo/product-1.svg +4 -0
- package/template/public/demo/product-10.svg +4 -0
- package/template/public/demo/product-11.svg +4 -0
- package/template/public/demo/product-12.svg +4 -0
- package/template/public/demo/product-2.svg +4 -0
- package/template/public/demo/product-3.svg +4 -0
- package/template/public/demo/product-4.svg +4 -0
- package/template/public/demo/product-5.svg +4 -0
- package/template/public/demo/product-6.svg +4 -0
- package/template/public/demo/product-7.svg +4 -0
- package/template/public/demo/product-8.svg +4 -0
- package/template/public/demo/product-9.svg +4 -0
- package/template/public/demo/product-square-1.svg +4 -0
- package/template/public/demo/product-square-2.svg +4 -0
- package/template/public/demo/product-square-3.svg +4 -0
- package/template/public/demo/product-square-4.svg +4 -0
- package/template/public/demo/product-square-5.svg +4 -0
- package/template/public/demo/product-square-6.svg +4 -0
- package/template/public/demo/quote-portrait.svg +4 -0
- package/template/public/demo/split-1.svg +1 -0
- package/template/public/demo/split-2.svg +1 -0
- package/template/public/demo/split-3.svg +1 -0
- package/template/public/demo/split-4.svg +1 -0
- package/template/public/demo/team-1.svg +4 -0
- package/template/public/demo/team-2.svg +4 -0
- package/template/public/demo/team-3.svg +4 -0
- package/template/public/demo/team-4.svg +4 -0
- package/template/public/favicon.ico +0 -0
- package/template/scripts/demo-images.mjs +393 -0
- package/template/scripts/generate-stories.mjs +156 -0
- package/template/scripts/previewHash.mjs +125 -0
- package/template/scripts/previews.mjs +149 -0
- package/template/stories/generated/announcement-bar.stories.ts +44 -0
- package/template/stories/generated/article-list.stories.ts +87 -0
- package/template/stories/generated/article.stories.ts +27 -0
- package/template/stories/generated/breadcrumbs.stories.ts +39 -0
- package/template/stories/generated/cart.stories.ts +38 -0
- package/template/stories/generated/collection-grid.stories.ts +117 -0
- package/template/stories/generated/collection-header.stories.ts +51 -0
- package/template/stories/generated/contact.stories.ts +45 -0
- package/template/stories/generated/cta.stories.ts +51 -0
- package/template/stories/generated/faq.stories.ts +56 -0
- package/template/stories/generated/feature-grid.stories.ts +69 -0
- package/template/stories/generated/footer.stories.ts +50 -0
- package/template/stories/generated/gallery.stories.ts +81 -0
- package/template/stories/generated/hero.stories.ts +75 -0
- package/template/stories/generated/image.stories.ts +99 -0
- package/template/stories/generated/logo-cloud.stories.ts +57 -0
- package/template/stories/generated/navigation.stories.ts +62 -0
- package/template/stories/generated/newsletter.stories.ts +68 -0
- package/template/stories/generated/order-status.stories.ts +32 -0
- package/template/stories/generated/pricing-table.stories.ts +44 -0
- package/template/stories/generated/product-carousel.stories.ts +75 -0
- package/template/stories/generated/product-detail.stories.ts +62 -0
- package/template/stories/generated/quote.stories.ts +69 -0
- package/template/stories/generated/rich-text.stories.ts +50 -0
- package/template/stories/generated/search.stories.ts +56 -0
- package/template/stories/generated/split-content.stories.ts +39 -0
- package/template/stories/generated/stats.stories.ts +68 -0
- package/template/stories/generated/tabs.stories.ts +45 -0
- package/template/stories/generated/team.stories.ts +45 -0
- package/template/stories/generated/testimonials.stories.ts +69 -0
- package/template/stories/generated/timeline.stories.ts +80 -0
- package/template/stories/generated/trust-strip.stories.ts +62 -0
- package/template/stories/generated/video-embed.stories.ts +63 -0
- package/template/stories/generated/wishlist.stories.ts +26 -0
- package/template/stories/pages/article.stories.ts +51 -0
- package/template/stories/pages/cart.stories.ts +56 -0
- package/template/stories/pages/category.stories.ts +56 -0
- package/template/stories/pages/collection.stories.ts +51 -0
- package/template/stories/pages/home.stories.ts +51 -0
- package/template/stories/pages/product.stories.ts +47 -0
- package/template/stories/pages/products.stories.ts +58 -0
- package/template/stories/pages/search.stories.ts +54 -0
- package/template/stories/pages/wishlist.stories.ts +53 -0
- package/template/stories/support/pageBlocks.ts +115 -0
- package/template/test/blocksEmptyData.spec.ts +52 -0
- package/template/test/carouselKeyboard.spec.ts +272 -0
- package/template/test/carouselRing.browser.spec.ts +193 -0
- package/template/test/carouselSlideWidth.browser.spec.ts +102 -0
- package/template/test/cartDrawer.spec.ts +295 -0
- package/template/test/cartToast.spec.ts +86 -0
- package/template/test/countPill.browser.spec.ts +196 -0
- package/template/test/demoImages.spec.ts +140 -0
- package/template/test/deps.spec.ts +102 -0
- package/template/test/eldraIcon.spec.ts +58 -0
- package/template/test/framing.spec.ts +76 -0
- package/template/test/i18n.spec.ts +200 -0
- package/template/test/iconComponent.spec.ts +91 -0
- package/template/test/inlineEditable.spec.ts +335 -0
- package/template/test/localePrefix.spec.ts +342 -0
- package/template/test/mainCss.spec.ts +107 -0
- package/template/test/mockGatewayContract.spec.ts +122 -0
- package/template/test/mocks/blocks.ts +20 -0
- package/template/test/mocks/breakpoints.ts +7 -0
- package/template/test/mocks/manifest.ts +11 -0
- package/template/test/moneyFormatting.spec.ts +85 -0
- package/template/test/pageTitle.spec.ts +49 -0
- package/template/test/pages/article.spec.ts +231 -0
- package/template/test/pages/category.spec.ts +185 -0
- package/template/test/pages/collection.spec.ts +396 -0
- package/template/test/pages/home.spec.ts +295 -0
- package/template/test/pages/hydration.spec.ts +557 -0
- package/template/test/pages/product.spec.ts +396 -0
- package/template/test/pages/seededPages.spec.ts +190 -0
- package/template/test/pages/ssr.spec.ts +387 -0
- package/template/test/prerenderCommerce.spec.ts +134 -0
- package/template/test/prerenderFailure.spec.ts +130 -0
- package/template/test/prerenderRefresh.browser.spec.ts +1431 -0
- package/template/test/previewsFresh.spec.ts +56 -0
- package/template/test/richText.spec.ts +164 -0
- package/template/test/richTextTypography.spec.ts +182 -0
- package/template/test/setup.ts +21 -0
- package/template/test/slugPage.spec.ts +244 -0
- package/template/test/slugPageTemplate.spec.ts +194 -0
- package/template/test/starter.spec.ts +1416 -0
- package/template/test/storefront/cart.spec.ts +404 -0
- package/template/test/storefront/categories.spec.ts +235 -0
- package/template/test/storefront/collectionSelector.spec.ts +74 -0
- package/template/test/storefront/demo.spec.ts +555 -0
- package/template/test/storefront/facets.spec.ts +425 -0
- package/template/test/storefront/feedback.spec.ts +97 -0
- package/template/test/storefront/gateway.spec.ts +2673 -0
- package/template/test/storefront/gatewayCart.spec.ts +289 -0
- package/template/test/storefront/gatewayPrerender.spec.ts +1037 -0
- package/template/test/storefront/history.spec.ts +341 -0
- package/template/test/storefront/money.spec.ts +170 -0
- package/template/test/storefront/toProductCard.spec.ts +138 -0
- package/template/test/storefront/volatile.spec.ts +284 -0
- package/template/test/support/axe.ts +14 -0
- package/template/test/support/dialog.ts +51 -0
- package/template/test/support/hydrate.ts +118 -0
- package/template/test/support/i18nText.ts +11 -0
- package/template/test/support/mockGateway.ts +1017 -0
- package/template/test/support/mountBlock.ts +194 -0
- package/template/test/support/mountPage.spec.ts +72 -0
- package/template/test/support/mountPage.ts +254 -0
- package/template/test/support/mountProbe.client.ts +69 -0
- package/template/test/support/renderSsr.ts +97 -0
- package/template/test/support/staticServer.ts +96 -0
- package/template/test/themeIcons.spec.ts +140 -0
- package/template/test/toastAnnouncement.spec.ts +133 -0
- package/template/test/tokens.spec.ts +102 -0
- package/template/test/uiMessagesPlugin.spec.ts +104 -0
- package/template/test/useBlockData.spec.ts +49 -0
- package/template/test/useEditing.spec.ts +54 -0
- package/template/test/useEldraIcon.spec.ts +126 -0
- package/template/test/useUiId.spec.ts +40 -0
- package/template/tokens.json +149 -0
- package/template/tsconfig.json +3 -0
- package/template/tsconfig.storybook.json +17 -0
- package/template/vitest-axe.d.ts +13 -0
- package/template/vitest.config.ts +44 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# Eldra Nuxt starter
|
|
2
|
+
|
|
3
|
+
This is the base every Eldra theme starts from: Tailwind v4 bound to the Eldra design tokens,
|
|
4
|
+
`@eldrajs/ui` for the accessible core components (buttons, links, form controls), the one copied
|
|
5
|
+
(not installed) primitive left under `app/components/ui/` (`UiImage`), 33 content and commerce
|
|
6
|
+
blocks, four sample pages, a demo storefront, `en-US`/`is-IS` UI strings, Storybook with generated
|
|
7
|
+
block previews, and an accessibility test harness. Running `eldra-theme init my-site` copies this
|
|
8
|
+
directory — everything in it is source you own from day one, apart from `@eldrajs/ui`, which is an
|
|
9
|
+
ordinary versioned dependency you restyle through tokens.
|
|
10
|
+
|
|
11
|
+
For the conventions behind the copied source (the block contract, why the primitives look the way
|
|
12
|
+
they do, the Tailwind CSS route this starter uses), see
|
|
13
|
+
[`docs/starter-kit.md`](../../docs/starter-kit.md) at the repo root.
|
|
14
|
+
|
|
15
|
+
## Create and run a theme locally
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
eldra-theme init my-site
|
|
19
|
+
cd my-site
|
|
20
|
+
pnpm install
|
|
21
|
+
ELDRA_GATEWAY_URL=https://web-gateway.example.com ELDRA_ORG_ID=<org-id> pnpm dev
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Set your theme's own id before the first deploy: `package.json` declares `"eldra": { "themeId":
|
|
25
|
+
"starter" }`, and Core files the theme's schemas and entries under that id (`starter:hero`), so two
|
|
26
|
+
themes in one organisation need different ids. Lower-case letters, digits and hyphens; it is the
|
|
27
|
+
theme's identity, so choose it once. See [`docs/themes.md`](../../docs/themes.md).
|
|
28
|
+
|
|
29
|
+
## Commands
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
pnpm dev # nuxi dev
|
|
33
|
+
pnpm generate # nuxi generate — real static build, prerenders /404
|
|
34
|
+
pnpm typecheck # nuxi typecheck + the Storybook config/stories (tsc)
|
|
35
|
+
pnpm test # vitest — every primitive/block spec, axe included
|
|
36
|
+
pnpm storybook # dev server on :6007
|
|
37
|
+
pnpm build-storybook # static Storybook build (also runs in CI)
|
|
38
|
+
pnpm previews # regenerate blocks/<id>/preview.png + freshness hashes
|
|
39
|
+
# (one-time setup: pnpm exec playwright install chromium)
|
|
40
|
+
pnpm demo-images # regenerate the deterministic SVG demo images
|
|
41
|
+
pnpm validate # eldra-theme validate — the same scan/validation a build runs
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## The block contract
|
|
45
|
+
|
|
46
|
+
Each `blocks/<apiId>/` directory is self-contained:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
blocks/<apiId>/
|
|
50
|
+
block.json field schema — Studio's CMS schema source
|
|
51
|
+
Block.vue the Vue renderer
|
|
52
|
+
mock.json the seed Studio writes on insert — media fields absent, no demo imagery
|
|
53
|
+
preview.json optional: demo-imagery overlay, merged onto mock.json for stories/previews
|
|
54
|
+
preview.png generated by `pnpm previews` — don't hand-edit
|
|
55
|
+
__tests__/Block.spec.ts render + axe (+ keyboard test where interactive), merged + bare mock.json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`Block.vue` declares `defineProps<{ entry: EldraBlockEntry<'my-block'> }>()` and reads fields
|
|
59
|
+
through `useBlockData(props, 'my-block')`. The `EldraBlockEntry`/`EldraBlockData` types are
|
|
60
|
+
generated from every `block.json` into `.eldra/block-types.d.ts` — refresh them with
|
|
61
|
+
`pnpm exec eldra-theme types --blocks` after changing a field schema. A block never calls Nuxt
|
|
62
|
+
globals (`useRoute`, `useHead`, `NuxtLink`, `$fetch`, `useAsyncData`) or relies on Nuxt's
|
|
63
|
+
auto-import — every `vue`/`@eldrajs/*` import is explicit, which is what lets every block render
|
|
64
|
+
correctly in Storybook (no Nuxt build step there to auto-import from). Links go through
|
|
65
|
+
`@eldrajs/ui`'s `Link`, with `safeHref` (`app/utils/links.ts`) on the destination and
|
|
66
|
+
`app/components/EldraRouterLink.vue` as `as` for a same-site path — that component is the one place
|
|
67
|
+
in the theme that writes the `<NuxtLink>` tag.
|
|
68
|
+
|
|
69
|
+
### Add a block
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
pnpm exec eldra-theme scaffold block my-block
|
|
73
|
+
pnpm validate
|
|
74
|
+
pnpm exec eldra-theme types --blocks
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Then fill in `block.json`'s fields, write `Block.vue` against `useBlockData`, and write real
|
|
78
|
+
`mock.json` content for the starter's fictional store, "Northwind Goods" (home and lifestyle
|
|
79
|
+
goods) — no lorem ipsum. If the block has a media field, leave it out of `mock.json` entirely (Core's
|
|
80
|
+
write-side validator rejects anything but `{assetId: <uuid>, framing?}`, and `mock.json` is exactly
|
|
81
|
+
what Studio writes into a freshly-inserted block's entry) and add a sibling `preview.json` with the
|
|
82
|
+
demo media instead, from `public/demo/`: `{ "assetId": "demo-<name>", "url": "/demo/<name>.svg",
|
|
83
|
+
"altText": "…" }`. Make sure `Block.vue` renders a sensible empty state with the field absent — no
|
|
84
|
+
crash, no broken layout — since that is also the state right after an author inserts the block.
|
|
85
|
+
`pnpm validate` fails with a clear message if a media field in `mock.json` is anything but absent or
|
|
86
|
+
`{assetId: uuid}`. A `reference` field follows the same rule for the same reason: leave it out of
|
|
87
|
+
`mock.json` (an inserted block must not arrive pointing at one particular collection) and put the
|
|
88
|
+
demo value in `preview.json` — `{ "_type": "collection", "id": "<a demoCollectionId() value>",
|
|
89
|
+
"slug": "<its handle>" }`, both keys, which is the shape a published read hands the block.
|
|
90
|
+
Seed data that must name a collection it cannot know the id of — a `pages/*.page.json` fixture, and
|
|
91
|
+
therefore the template seed built from it — names it by slug instead
|
|
92
|
+
(`{ "_type": "collection", "slug": "the-winter-edit" }`), which Core resolves against the
|
|
93
|
+
organisation's own catalog on deploy. A `select` field named `variant` gets a generated Storybook story per declared
|
|
94
|
+
option automatically; add an axe assertion for each variant in the block's spec, mounted from both
|
|
95
|
+
the merged (mock + preview) data and the bare `mock.json`. Run `pnpm previews` once the block
|
|
96
|
+
renders, and commit the generated `preview.png` / `.eldra/previews/*.png` / `.eldra/previews.json`
|
|
97
|
+
alongside it.
|
|
98
|
+
|
|
99
|
+
## The 33 blocks
|
|
100
|
+
|
|
101
|
+
`blocks/` groups by `block.json`'s `category`, the same grouping Studio's insert palette uses:
|
|
102
|
+
|
|
103
|
+
- **structure** — `navigation` ("Header"), `announcement-bar`, `breadcrumbs`, `footer`.
|
|
104
|
+
- **marketing** — `hero`, `cta` ("Call to action"), `feature-grid`, `split-content`, `stats`,
|
|
105
|
+
`logo-cloud`, `testimonials`, `faq`, `pricing-table`, `newsletter`, `contact`
|
|
106
|
+
("Contact and map"), `video-embed`, `team`, `timeline`.
|
|
107
|
+
- **content** — `article`, `article-list`, `rich-text`, `gallery`, `image`, `quote`, `tabs`.
|
|
108
|
+
- **commerce** — `collection-header`, `product-carousel`, `collection-grid`, `product-detail`,
|
|
109
|
+
`cart`, `search`, `order-status`, `trust-strip`.
|
|
110
|
+
|
|
111
|
+
Commerce blocks read product, cart, search and order data through `useStorefront()`
|
|
112
|
+
(`app/storefront/`), never `@eldrajs/sdk` directly — see [`docs/starter-kit.md`](../../docs/starter-kit.md)
|
|
113
|
+
for the full block contract, the `link`-pair field convention, and the version/migration rule for
|
|
114
|
+
changing a shipped block's schema.
|
|
115
|
+
|
|
116
|
+
## Sample pages
|
|
117
|
+
|
|
118
|
+
`pages/home.page.json`, `pages/product.page.json`, `pages/collection.page.json` and
|
|
119
|
+
`pages/article.page.json` are hand-authored fixtures — `{ template, title, blocks: [{ apiId, id,
|
|
120
|
+
data }] }`, the same shape a real CMS page document has — showing a realistic page rather than one
|
|
121
|
+
block in isolation. Each renders as a Storybook story (`stories/pages/*.stories.ts`) and is proven
|
|
122
|
+
by its own page-level test (`test/pages/*.spec.ts`): a whole-page axe pass, one `<h1>` with no
|
|
123
|
+
skipped heading level, unique ids across every block instance on the page, and the rest of the
|
|
124
|
+
page-level gate `docs/starter-kit.md`'s testing section describes. Use them as a starting point for
|
|
125
|
+
your own site's pages, or as a reference for how a set of blocks composes.
|
|
126
|
+
|
|
127
|
+
## Storefront forms
|
|
128
|
+
|
|
129
|
+
The newsletter (`forms.subscribe`), contact (`forms.sendMessage`) and back-in-stock
|
|
130
|
+
(`catalog.notifyBackInStock`) forms have no gateway endpoint by default: without one configured,
|
|
131
|
+
they resolve `{ ok: false, reason: 'unsupported' }` and the block renders its own "isn't set up
|
|
132
|
+
yet" copy rather than crashing. Wire a real endpoint by adding it to `nuxt.config.ts`:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
export default defineNuxtConfig({
|
|
136
|
+
runtimeConfig: {
|
|
137
|
+
public: {
|
|
138
|
+
formsEndpoint: '', // e.g. https://forms.example.com/submit
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
or by setting the matching `NUXT_PUBLIC_FORMS_ENDPOINT` environment variable at build/deploy time.
|
|
145
|
+
Once set, `app/storefront/gateway.ts` posts `{ kind: 'subscribe' | 'sendMessage' |
|
|
146
|
+
'notifyBackInStock', ...input }` as JSON to that endpoint and treats a non-2xx response as a
|
|
147
|
+
recoverable failure (the same retry-on-resubmit path each form's own spec proves).
|
|
148
|
+
|
|
149
|
+
## Checkout
|
|
150
|
+
|
|
151
|
+
Nothing to configure: the checkout page is the platform's, and `@eldrajs/sdk` asks the platform
|
|
152
|
+
where it is. As soon as the cart has an id — a line just added, or one remembered from a previous
|
|
153
|
+
visit — `app/storefront/gateway.ts` awaits `client.checkout.url({ cartId })` and the Check out
|
|
154
|
+
button appears when that resolves. If the platform publishes no checkout URL, or the read does not
|
|
155
|
+
come back, the cart still adds, updates and persists lines normally; it just has no Check out
|
|
156
|
+
button to show, since there is nowhere to hand the cart off to.
|
|
157
|
+
|
|
158
|
+
## Prices and the store currency
|
|
159
|
+
|
|
160
|
+
Nothing to configure here either, and nothing to guess: the organisation's own commerce settings
|
|
161
|
+
say what the store sells in, `@eldrajs/theme-nuxt` reads them once during the build onto
|
|
162
|
+
`runtimeConfig.public.eldra.commerce`, and `app/plugins/eldra-ui-messages.ts` provides the currency
|
|
163
|
+
to every `@eldrajs/ui` component. `app/storefront/money.ts` is the only place the theme formats or
|
|
164
|
+
converts money, and `useMoney()` is what a block calls — the formatted text in a sentence ("Add to
|
|
165
|
+
cart · 2.800 kr.") and the `<Price>` beside it therefore always agree.
|
|
166
|
+
|
|
167
|
+
They agree on the **sign**, too, because both come from `@eldrajs/ui`: `formatMoney` is the
|
|
168
|
+
package's `formatCurrency`, so every amount on the page carries the currency's wide sign
|
|
169
|
+
(`ISK 2,800` on an English page, `2.800 kr.` on an Icelandic one, `$28.00` for dollars), the same text
|
|
170
|
+
on the server and in Chrome, rather than whatever a hand-built `Intl.NumberFormat` prints there. Nothing in
|
|
171
|
+
`app/**` or `blocks/**` may build a currency formatter of its own — `test/moneyFormatting.spec.ts`
|
|
172
|
+
fails the build if anything does. The footer's currency text follows the same sign as well:
|
|
173
|
+
`currencyLabel()` names the store's currency "ISK kr." style, the code plus that sign.
|
|
174
|
+
|
|
175
|
+
A store that has not configured commerce publishes no currency, and the build says so once:
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
[eldra] the store publishes no currency — prices render as plain numbers
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Prices then render as plain numbers — in a `<Price>` element and in a formatted sentence alike,
|
|
182
|
+
never under a symbol the theme picked for you, which would misprice the page rather than merely
|
|
183
|
+
under-describe it. There is no theme-side currency setting on
|
|
184
|
+
purpose: the catalogue's amounts are in the store's currency whatever a theme claims.
|
|
185
|
+
`useStorefront().commerce` also carries `taxInclusivePricing` and `defaultTaxRate`, for a block
|
|
186
|
+
that has to say whether a price includes VAT.
|
|
187
|
+
|
|
188
|
+
## Languages
|
|
189
|
+
|
|
190
|
+
Nothing to configure. The organisation's configured content locales reach the theme through
|
|
191
|
+
`@eldrajs/theme-nuxt`: the default locale is served at `/` and every other supported locale under a
|
|
192
|
+
path prefix (`/is-IS/products/ash-glaze-mug`), with the same slug and the same page document read in
|
|
193
|
+
that locale. The build prerenders every content path once per locale, and each page declares its own
|
|
194
|
+
`<html lang>` and an `hreflang` alternate for the others.
|
|
195
|
+
|
|
196
|
+
What the theme does with it:
|
|
197
|
+
|
|
198
|
+
- the **footer's language switcher** lists the organisation's locales, each named in its own
|
|
199
|
+
language, and renders nothing at all when there is only one;
|
|
200
|
+
- **every link keeps the language** — `app/components/EldraRouterLink.vue` adds the prefix once for
|
|
201
|
+
the whole theme, since it is the component `@eldrajs/ui`'s `Link`/`Button` route through;
|
|
202
|
+
- the **UI strings and all number formatting** follow the page's locale (`i18n/*.json`, read through
|
|
203
|
+
`vue-i18n`'s own `useI18n()` — no wrapper), while the **currency stays the store's**;
|
|
204
|
+
- the **storefront** reads the catalog, search and orders in that locale too.
|
|
205
|
+
|
|
206
|
+
The theme ships `en-US` and `is-IS` message sets. A configured locale with no set of its own gets
|
|
207
|
+
English chrome around its own content — add a file under `i18n/` (the theme root, beside
|
|
208
|
+
`tokens.json`) with the same key set to change that. A store with one locale behaves exactly as it
|
|
209
|
+
did before any of this: no prefixes, no switcher, no `locale` on any read.
|
|
210
|
+
|
|
211
|
+
`ELDRA_LOCALE` still means what it meant — an override of which locale lives at `/`.
|
|
212
|
+
`docs/starter-kit.md` section 6 has the rules a customer editing blocks needs; `docs/themes.md` has
|
|
213
|
+
the routing itself.
|
|
214
|
+
|
|
215
|
+
## Restyling
|
|
216
|
+
|
|
217
|
+
Two layers, both plain files:
|
|
218
|
+
|
|
219
|
+
- **`tokens.json`** — the design spec's seventeen colour roles (`background`, `surface`,
|
|
220
|
+
`surface-strong`, `border`, `border-strong`, `overlay`, `text`, `muted`, `primary`,
|
|
221
|
+
`primary-contrast`, `accent`, `accent-contrast`, `success`, `warning`, `danger`, `focus`,
|
|
222
|
+
`focus-inner`) and layout containers (`narrow`, `content`, `wide`, `full`). These are also what
|
|
223
|
+
Studio's site settings can override live, per-site, without a redeploy (`allowSiteOverride:
|
|
224
|
+
true`). Each id becomes a `--eldra-color-<id>` custom property, which is the _same_ name
|
|
225
|
+
`@eldrajs/ui` reads — so changing a colour here restyles the package's components too, with no
|
|
226
|
+
sync step and nothing generated into `main.css`.
|
|
227
|
+
- **`app/assets/main.css`** — `@import 'tailwindcss'` then `@import '@eldrajs/ui/tailwind.css'`,
|
|
228
|
+
which brings in the `--eldra-*` variables, the Tailwind `@theme` mapping over them
|
|
229
|
+
(`bg-primary`, `rounded-md`, `shadow-md`, `font-heading`, `text-body`, …) and the package's own
|
|
230
|
+
utilities. What is left in the file is the theme's own: the section spacing scale, the container
|
|
231
|
+
rules, the base layer and the rich-text typography. Edit it directly; there's no build step.
|
|
232
|
+
Fonts are `--eldra-font-heading` / `--eldra-font-body` — override them here (the package names
|
|
233
|
+
its two faces but never loads them).
|
|
234
|
+
|
|
235
|
+
Blocks and primitives compose these through Tailwind utilities only — no scoped CSS, no `@apply`
|
|
236
|
+
outside `main.css` itself, so every block stays readable as plain markup.
|
|
237
|
+
|
|
238
|
+
## Accessibility
|
|
239
|
+
|
|
240
|
+
Every primitive and block ships an axe assertion
|
|
241
|
+
(`expect(await axe(wrapper.element)).toHaveNoViolations()`, `vitest-axe` under jsdom) and, for
|
|
242
|
+
anything interactive (menu, dialog, drawer, accordion, tabs, carousel, lightbox), a keyboard test.
|
|
243
|
+
Every interactive element carries a focus ring: `@eldrajs/ui`'s components draw the spec's own
|
|
244
|
+
(`eldra-focus`, from the `focus`/`focus-inner` tokens), and what the theme still draws itself uses
|
|
245
|
+
`app/utils/classes.ts`'s `focusRing`. Animation is gated behind `motion-safe:` so it never runs
|
|
246
|
+
for a visitor who has asked their OS to reduce motion. `pnpm test` runs the whole suite; a failing
|
|
247
|
+
axe assertion is a defect in the change, not a snapshot to update.
|
|
248
|
+
|
|
249
|
+
## Block slots
|
|
250
|
+
|
|
251
|
+
Blocks may declare bounded semantic insertion regions in `block.json` with a `slots` array, e.g. the hero's action area:
|
|
252
|
+
|
|
253
|
+
```json
|
|
254
|
+
"slots": [
|
|
255
|
+
{ "id": "actions", "label": "Action buttons", "description": "Buttons rendered under the hero copy. Falls back to the built-in CTA.", "maxItems": 2, "allowedBlockApiIds": ["cta"] }
|
|
256
|
+
]
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Each slot declares a unique lowercase-kebab `id` (used as the named slot in `Block.vue`), a `label` shown in Studio, an optional `description`, a required `maxItems` capacity between 1 and 20, and an optional `allowedBlockApiIds` allowlist of block `apiId`s that may be placed in the slot. An omitted allowlist admits any block type except the host block itself; every allowlisted id must exist in the theme or `pnpm validate` rejects the catalog.
|
|
260
|
+
|
|
261
|
+
Render the slot with an ordinary named slot plus fallback content:
|
|
262
|
+
|
|
263
|
+
```vue
|
|
264
|
+
<div class="actions">
|
|
265
|
+
<slot name="actions">
|
|
266
|
+
<a v-if="d.ctaLabel && ctaHref" class="button" :href="ctaHref">{{ d.ctaLabel }}</a>
|
|
267
|
+
</slot>
|
|
268
|
+
</div>
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
This is the fallback convention: block authors write plain `<slot name="…">` fallback content, and an empty slot renders identically in Studio preview and static output — there is no hidden persistence or executable CMS data. Layout documents may place at most `maxItems` blocks per slot; validation fails closed (`SLOT_FULL`) on overflow, and the allowlist is enforced per placement. In Studio preview, rendered slots additionally carry editor-only markers (an `aria-hidden` `data-eldra-slot-marker` element with `data-eldra-slot-id` reporting `label · n/maxItems`) and their geometry is reported over the `theme:slots-rendered` bridge message; static generation includes neither.
|
|
272
|
+
|
|
273
|
+
## Build and deploy
|
|
274
|
+
|
|
275
|
+
```sh
|
|
276
|
+
pnpm generate
|
|
277
|
+
ELDRA_API_URL=https://api.studio.example.com \
|
|
278
|
+
ELDRA_DEPLOY_TOKEN=<site-token> pnpm exec eldra-theme deploy
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
The deploy command uploads the generated static site and exact `.eldra/manifest.json`. Eldra ingests that manifest to create or update CMS schemas tagged `block`; Git is version control only and is never the schema-sync channel. Keep the site-scoped deploy token in your CI secret store.
|
|
282
|
+
|
|
283
|
+
`/404` is a reserved path in this starter: it always renders the not-found shell (prerendered to the static `404.html` hosts serve for unmatched routes), so a CMS page authored with the slug `404` will be shadowed.
|
|
284
|
+
|
|
285
|
+
## Wiring rebuilds
|
|
286
|
+
|
|
287
|
+
The starter includes GitHub Actions, GitLab CI, and Bitbucket Pipelines examples. All build locally with Node 20 and pnpm, run `nuxi generate`, then push the static output with `eldra-theme deploy`.
|
|
288
|
+
|
|
289
|
+
- GitHub: set repository variables `ELDRA_GATEWAY_URL`, `ELDRA_ORG_ID`, and `ELDRA_API_URL`, plus secret `ELDRA_DEPLOY_TOKEN`. In Studio choose the GitHub trigger and configure `https://api.github.com/repos/<owner>/<repo>/dispatches` with a token allowed to dispatch workflows.
|
|
290
|
+
- GitLab: configure those four names as project CI/CD variables, masking `ELDRA_DEPLOY_TOKEN`. In Studio use the project pipeline-trigger URL, trigger token, and branch/tag ref.
|
|
291
|
+
- Bitbucket: configure repository variables, securing `ELDRA_DEPLOY_TOKEN`. In Studio use the pipelines endpoint, `username:app-password` token, and ref; the backend selects the `eldra-rebuild` custom pipeline.
|
|
292
|
+
|
|
293
|
+
Trigger tokens and app passwords are write-only in Studio. Rebuild requests supply `ELDRA_TRIGGER_DEPLOYMENT_ID`; the deploy command returns it as multipart `triggerDeploymentId`, completing the existing MANUAL or CONTENT_PUBLISH deployment rather than creating a duplicate.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The skip link is the one piece of markup that lives outside
|
|
4
|
+
* `pages/[...slug].vue`'s own `<main id="main">` (see that file), so it
|
|
5
|
+
* reaches every route including the not-found/error shells. It is
|
|
6
|
+
* `@eldrajs/ui`'s `Link` routed through Nuxt's `<NuxtLink>` (`EldraRouterLink`,
|
|
7
|
+
* the one place the theme reaches for it), so the `#main` hash is handled by
|
|
8
|
+
* the router like every other internal destination.
|
|
9
|
+
*
|
|
10
|
+
* `Toaster` is the app's single toast host (`@eldrajs/ui`'s `useToast` is a module-level queue, so
|
|
11
|
+
* whoever raises a toast — the `cart` block's Undo, for one — needs exactly one mounted region to
|
|
12
|
+
* render it, and that region owns every timer and the hand-off into an open modal `<dialog>`). It
|
|
13
|
+
* belongs here rather than in a block: two of them would render every toast twice.
|
|
14
|
+
*
|
|
15
|
+
* The **cart drawer** is here for the same "exactly one host" reason, and for one more: a shopper
|
|
16
|
+
* must be able to open their cart from the header on every route, so it cannot be something an
|
|
17
|
+
* author places on a page — `blocks/cart/Block.vue` in its `drawer` variant, mounted once, with the
|
|
18
|
+
* entry the theme owns rather than a CMS document (the seeded `/cart` page carries its `page`-variant
|
|
19
|
+
* entry the same way). The rules behind the three `cart.drawer*` flags this file sets live in one
|
|
20
|
+
* place, on `CartStore` in `app/storefront/cart.ts`; `/cart` stays exactly what it was.
|
|
21
|
+
*
|
|
22
|
+
* `:page-key` is `@eldrajs/theme-nuxt`'s `eldraRouteKey` (auto-imported), not Nuxt's default, and
|
|
23
|
+
* it is load-bearing on a **generated** site: a host that answers `/products/ash-glaze-mug` with a
|
|
24
|
+
* redirect to `/products/ash-glaze-mug/` makes Nuxt re-navigate between the two paths while the
|
|
25
|
+
* page hydrates, and the catch-all route's default key differs between them — so the page, and
|
|
26
|
+
* every block on it, would be destroyed and built again, running each block's `setup` (and the
|
|
27
|
+
* storefront reads in it) twice. Keying by the canonical path makes that move a no-op.
|
|
28
|
+
*/
|
|
29
|
+
import { computed, watch } from 'vue';
|
|
30
|
+
import { Link, Toaster, useToast } from '@eldrajs/ui';
|
|
31
|
+
import CartBlock from '../blocks/cart/Block.vue';
|
|
32
|
+
import EldraRouterLink from './components/EldraRouterLink.vue';
|
|
33
|
+
import { useStorefront } from './composables/useStorefront';
|
|
34
|
+
import { useI18n } from 'vue-i18n';
|
|
35
|
+
import { CART_ADD_TOAST_ID } from './storefront/feedback';
|
|
36
|
+
|
|
37
|
+
const { t } = useI18n();
|
|
38
|
+
|
|
39
|
+
const cart = useStorefront().cart;
|
|
40
|
+
/** Claimed in `setup()`, not from a mount hook: every block on the page is created after this line
|
|
41
|
+
* runs, in a server render as much as in the browser, which is what makes an authored
|
|
42
|
+
* `drawer`-variant `cart` block's "defer to the host" decision the same in both
|
|
43
|
+
* (`app/storefront/cart.ts`). */
|
|
44
|
+
cart.drawerHosted.value = true;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The drawer is this shell's, so no navigation unmounts it the way a page-level one was unmounted —
|
|
48
|
+
* it has to close itself, or it sits open over wherever the shopper just went, with that page inert
|
|
49
|
+
* and not scrolling behind it (`useDialog` in `@eldrajs/ui`). One rule here covers every destination
|
|
50
|
+
* inside the drawer — each line's product title, Check out, View cart — and back/forward with it,
|
|
51
|
+
* because the router turns a `popstate` into a route change too. `flush: 'pre'` (the default) runs it
|
|
52
|
+
* before the new page renders.
|
|
53
|
+
*
|
|
54
|
+
* `useRoute` is a Nuxt auto-import; this file is Nuxt-only already (`<NuxtPage>`, `eldraRouteKey`),
|
|
55
|
+
* which is exactly why the rule belongs here and not in a block — `blocks/**` may not read the route.
|
|
56
|
+
*/
|
|
57
|
+
const route = useRoute();
|
|
58
|
+
watch(
|
|
59
|
+
() => route.fullPath,
|
|
60
|
+
() => {
|
|
61
|
+
cart.drawerOpen.value = false;
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Once the cart drawer is open, the "Added to cart" toast (`blocks/product-detail/Block.vue`,
|
|
67
|
+
* `CART_ADD_TOAST_ID`) has nothing left to confirm — the shopper is looking at the cart itself,
|
|
68
|
+
* whether they got there through the toast's own "View cart" action, the header bag, or anything
|
|
69
|
+
* else that flips `drawerOpen`. Left alone it would sit behind the drawer until its own timer (or,
|
|
70
|
+
* for the failure toast sharing this id, never) closed it. This belongs in the shell rather than
|
|
71
|
+
* the block that raised the toast because the drawer is the shell's (see above) and a toast can
|
|
72
|
+
* outlive the page that raised it (`route.fullPath` watch above unmounts no toast). Only this one
|
|
73
|
+
* id is dismissed — an unrelated toast (a different cause, a different block) stays exactly where
|
|
74
|
+
* it is.
|
|
75
|
+
*/
|
|
76
|
+
const toast = useToast();
|
|
77
|
+
watch(
|
|
78
|
+
() => cart.drawerOpen.value,
|
|
79
|
+
(open) => {
|
|
80
|
+
if (open) toast.dismiss(CART_ADD_TOAST_ID);
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* An `EldraBlockEntry` needs an id. This one is the theme's own, not a CMS entry id, and never
|
|
86
|
+
* reaches the gateway; it is the shell's own, distinct from any cart block on a page, so the two
|
|
87
|
+
* theme-owned cart entries stay tellable apart while debugging — on `/cart` both are mounted. The ids
|
|
88
|
+
* in the rendered markup do not come from here: every one of them is Vue's own `useId()`, derived
|
|
89
|
+
* from the component's position in the tree (`app/composables/useUiId.ts`).
|
|
90
|
+
*/
|
|
91
|
+
const DRAWER_ENTRY_ID = 'theme-cart-drawer';
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Every field is left to the block's own default except the empty state's destination: `/` always
|
|
95
|
+
* exists, where `/collections/all` (what `mock.json` seeds an authored cart block with) is a route
|
|
96
|
+
* only some stores have. Author-editable copy for this surface arrives with the storefront settings
|
|
97
|
+
* entry (`docs/starter-kit.md`, "The cart drawer and the `/cart` page").
|
|
98
|
+
*/
|
|
99
|
+
const drawerEntry = computed(
|
|
100
|
+
() =>
|
|
101
|
+
({
|
|
102
|
+
id: DRAWER_ENTRY_ID,
|
|
103
|
+
data: {
|
|
104
|
+
variant: 'drawer',
|
|
105
|
+
emptyLinkLabel: t('cart.continueShopping'),
|
|
106
|
+
emptyLinkHref: '/',
|
|
107
|
+
},
|
|
108
|
+
}) as EldraBlockEntry<'cart'>
|
|
109
|
+
);
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
<template>
|
|
113
|
+
<Link
|
|
114
|
+
href="#main"
|
|
115
|
+
:as="EldraRouterLink"
|
|
116
|
+
variant="standalone"
|
|
117
|
+
:classes="{
|
|
118
|
+
root: 'bg-primary text-primary-contrast rounded-md sr-only px-4 py-2 focus:not-sr-only focus:fixed focus:top-4 focus:left-4 focus:z-50',
|
|
119
|
+
}"
|
|
120
|
+
>
|
|
121
|
+
{{ t('nav.skipToContent') }}
|
|
122
|
+
</Link>
|
|
123
|
+
<NuxtPage :page-key="eldraRouteKey" />
|
|
124
|
+
<CartBlock :entry="drawerEntry" host />
|
|
125
|
+
<Toaster />
|
|
126
|
+
</template>
|