@eldrajs/theme-cli 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (483) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/LICENSE +21 -0
  3. package/README.md +26 -1
  4. package/dist/cli.d.ts +1 -0
  5. package/dist/cli.js +203 -0
  6. package/dist/index.d.ts +174 -0
  7. package/dist/index.js +3 -0
  8. package/dist/validate-C6jB8_Oc.js +510 -0
  9. package/package.json +50 -2
  10. package/template/.eldra/block-types.d.ts +429 -0
  11. package/template/.eldra/manifest.json +9377 -0
  12. package/template/.eldra/previews.json +36 -0
  13. package/template/.github/workflows/eldra-deploy.yml +24 -0
  14. package/template/.gitlab-ci.yml +16 -0
  15. package/template/.storybook/eldra.ts +123 -0
  16. package/template/.storybook/i18n.ts +23 -0
  17. package/template/.storybook/main.ts +59 -0
  18. package/template/.storybook/nuxt-link-stub.ts +23 -0
  19. package/template/.storybook/preview.ts +52 -0
  20. package/template/.storybook/shims-vue.d.ts +10 -0
  21. package/template/.storybook/virtual-eldra.d.ts +27 -0
  22. package/template/README.md +288 -0
  23. package/template/app/app.vue +126 -0
  24. package/template/app/assets/main.css +404 -0
  25. package/template/app/components/EldraIcon.vue +66 -0
  26. package/template/app/components/EldraRouterLink.vue +62 -0
  27. package/template/app/components/ui/UiImage.stories.ts +30 -0
  28. package/template/app/components/ui/UiImage.vue +224 -0
  29. package/template/app/components/ui/__tests__/UiImage.spec.ts +292 -0
  30. package/template/app/composables/iconComponent.ts +84 -0
  31. package/template/app/composables/iconFetcher.ts +14 -0
  32. package/template/app/composables/useBlockData.ts +30 -0
  33. package/template/app/composables/useEditing.ts +31 -0
  34. package/template/app/composables/useEldraIcon.ts +46 -0
  35. package/template/app/composables/useRevalidating.ts +69 -0
  36. package/template/app/composables/useRichTextScrollRegions.ts +80 -0
  37. package/template/app/composables/useStorefront.ts +18 -0
  38. package/template/app/composables/useStorefrontFeedback.ts +49 -0
  39. package/template/app/composables/useUiId.ts +18 -0
  40. package/template/app/composables/useWishlist.ts +42 -0
  41. package/template/app/i18n.d.ts +28 -0
  42. package/template/app/icons.ts +185 -0
  43. package/template/app/pages/[...slug].vue +134 -0
  44. package/template/app/plugins/eldra-i18n.ts +98 -0
  45. package/template/app/plugins/eldra-storefront.ts +288 -0
  46. package/template/app/plugins/eldra-ui-messages.ts +112 -0
  47. package/template/app/storefront/cart.ts +245 -0
  48. package/template/app/storefront/categories.ts +283 -0
  49. package/template/app/storefront/collectionSelector.ts +60 -0
  50. package/template/app/storefront/commerce.ts +58 -0
  51. package/template/app/storefront/demo.ts +1313 -0
  52. package/template/app/storefront/facets.ts +476 -0
  53. package/template/app/storefront/feedback.ts +122 -0
  54. package/template/app/storefront/gateway.ts +2256 -0
  55. package/template/app/storefront/history.ts +233 -0
  56. package/template/app/storefront/money.ts +247 -0
  57. package/template/app/storefront/options.ts +71 -0
  58. package/template/app/storefront/prerender.ts +77 -0
  59. package/template/app/storefront/refresh.ts +222 -0
  60. package/template/app/storefront/toProductCard.ts +154 -0
  61. package/template/app/storefront/types.ts +815 -0
  62. package/template/app/storefront/volatile.ts +211 -0
  63. package/template/app/templates.ts +544 -0
  64. package/template/app/utils/classes.ts +40 -0
  65. package/template/app/utils/links.ts +70 -0
  66. package/template/app/utils/pageStructure.ts +77 -0
  67. package/template/app/utils/pageTitle.ts +37 -0
  68. package/template/app/virtual-eldra.d.ts +12 -0
  69. package/template/bitbucket-pipelines.yml +19 -0
  70. package/template/blocks/announcement-bar/Block.vue +203 -0
  71. package/template/blocks/announcement-bar/__tests__/Block.spec.ts +227 -0
  72. package/template/blocks/announcement-bar/block.json +45 -0
  73. package/template/blocks/announcement-bar/mock.json +7 -0
  74. package/template/blocks/announcement-bar/preview.png +0 -0
  75. package/template/blocks/article/Block.vue +317 -0
  76. package/template/blocks/article/__tests__/Block.spec.ts +229 -0
  77. package/template/blocks/article/block.json +148 -0
  78. package/template/blocks/article/mock.json +512 -0
  79. package/template/blocks/article/preview.json +16 -0
  80. package/template/blocks/article/preview.png +0 -0
  81. package/template/blocks/article-list/Block.vue +343 -0
  82. package/template/blocks/article-list/__tests__/Block.spec.ts +279 -0
  83. package/template/blocks/article-list/block.json +181 -0
  84. package/template/blocks/article-list/mock.json +68 -0
  85. package/template/blocks/article-list/preview.json +84 -0
  86. package/template/blocks/article-list/preview.png +0 -0
  87. package/template/blocks/breadcrumbs/Block.vue +278 -0
  88. package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +461 -0
  89. package/template/blocks/breadcrumbs/block.json +89 -0
  90. package/template/blocks/breadcrumbs/mock.json +11 -0
  91. package/template/blocks/breadcrumbs/preview.json +3 -0
  92. package/template/blocks/breadcrumbs/preview.png +0 -0
  93. package/template/blocks/cart/Block.vue +372 -0
  94. package/template/blocks/cart/__tests__/Block.spec.ts +561 -0
  95. package/template/blocks/cart/__tests__/ShippingBar.spec.ts +78 -0
  96. package/template/blocks/cart/__tests__/Summary.spec.ts +245 -0
  97. package/template/blocks/cart/block.json +74 -0
  98. package/template/blocks/cart/mock.json +11 -0
  99. package/template/blocks/cart/parts/CartLines.vue +257 -0
  100. package/template/blocks/cart/parts/ShippingBar.vue +105 -0
  101. package/template/blocks/cart/parts/Summary.vue +291 -0
  102. package/template/blocks/cart/preview.png +0 -0
  103. package/template/blocks/collection-grid/Block.vue +1832 -0
  104. package/template/blocks/collection-grid/__tests__/Block.spec.ts +3037 -0
  105. package/template/blocks/collection-grid/__tests__/groups.spec.ts +731 -0
  106. package/template/blocks/collection-grid/block.json +187 -0
  107. package/template/blocks/collection-grid/mock.json +23 -0
  108. package/template/blocks/collection-grid/parts/groups.ts +861 -0
  109. package/template/blocks/collection-grid/preview.json +7 -0
  110. package/template/blocks/collection-grid/preview.png +0 -0
  111. package/template/blocks/collection-header/Block.vue +533 -0
  112. package/template/blocks/collection-header/__tests__/Block.spec.ts +381 -0
  113. package/template/blocks/collection-header/block.json +140 -0
  114. package/template/blocks/collection-header/mock.json +28 -0
  115. package/template/blocks/collection-header/preview.json +14 -0
  116. package/template/blocks/collection-header/preview.png +0 -0
  117. package/template/blocks/contact/Block.vue +621 -0
  118. package/template/blocks/contact/__tests__/Block.spec.ts +347 -0
  119. package/template/blocks/contact/block.json +174 -0
  120. package/template/blocks/contact/mock.json +28 -0
  121. package/template/blocks/contact/preview.json +9 -0
  122. package/template/blocks/contact/preview.png +0 -0
  123. package/template/blocks/cta/Block.vue +383 -0
  124. package/template/blocks/cta/__tests__/Block.spec.ts +309 -0
  125. package/template/blocks/cta/block.json +86 -0
  126. package/template/blocks/cta/mock.json +10 -0
  127. package/template/blocks/cta/preview.json +9 -0
  128. package/template/blocks/cta/preview.png +0 -0
  129. package/template/blocks/faq/Block.vue +254 -0
  130. package/template/blocks/faq/__tests__/Block.spec.ts +312 -0
  131. package/template/blocks/faq/block.json +113 -0
  132. package/template/blocks/faq/mock.json +115 -0
  133. package/template/blocks/faq/preview.png +0 -0
  134. package/template/blocks/feature-grid/Block.vue +241 -0
  135. package/template/blocks/feature-grid/__tests__/Block.spec.ts +311 -0
  136. package/template/blocks/feature-grid/block.json +106 -0
  137. package/template/blocks/feature-grid/mock.json +29 -0
  138. package/template/blocks/feature-grid/preview.json +45 -0
  139. package/template/blocks/feature-grid/preview.png +0 -0
  140. package/template/blocks/footer/Block.vue +652 -0
  141. package/template/blocks/footer/__tests__/Block.spec.ts +700 -0
  142. package/template/blocks/footer/block.json +240 -0
  143. package/template/blocks/footer/mock.json +161 -0
  144. package/template/blocks/footer/preview.png +0 -0
  145. package/template/blocks/gallery/Block.vue +416 -0
  146. package/template/blocks/gallery/__tests__/Block.spec.ts +289 -0
  147. package/template/blocks/gallery/block.json +87 -0
  148. package/template/blocks/gallery/mock.json +16 -0
  149. package/template/blocks/gallery/preview.json +64 -0
  150. package/template/blocks/gallery/preview.png +0 -0
  151. package/template/blocks/hero/Block.vue +378 -0
  152. package/template/blocks/hero/__tests__/Block.spec.ts +324 -0
  153. package/template/blocks/hero/block.json +146 -0
  154. package/template/blocks/hero/mock.json +11 -0
  155. package/template/blocks/hero/preview.json +55 -0
  156. package/template/blocks/hero/preview.png +0 -0
  157. package/template/blocks/image/Block.vue +232 -0
  158. package/template/blocks/image/__tests__/Block.spec.ts +224 -0
  159. package/template/blocks/image/block.json +67 -0
  160. package/template/blocks/image/mock.json +7 -0
  161. package/template/blocks/image/preview.json +9 -0
  162. package/template/blocks/image/preview.png +0 -0
  163. package/template/blocks/logo-cloud/Block.vue +206 -0
  164. package/template/blocks/logo-cloud/__tests__/Block.spec.ts +210 -0
  165. package/template/blocks/logo-cloud/block.json +79 -0
  166. package/template/blocks/logo-cloud/mock.json +15 -0
  167. package/template/blocks/logo-cloud/preview.json +92 -0
  168. package/template/blocks/logo-cloud/preview.png +0 -0
  169. package/template/blocks/navigation/Block.vue +1348 -0
  170. package/template/blocks/navigation/__tests__/Block.spec.ts +2030 -0
  171. package/template/blocks/navigation/block.json +167 -0
  172. package/template/blocks/navigation/mock.json +191 -0
  173. package/template/blocks/navigation/preview.png +0 -0
  174. package/template/blocks/navigation/useMegaMenuKeys.ts +276 -0
  175. package/template/blocks/newsletter/Block.vue +399 -0
  176. package/template/blocks/newsletter/__tests__/Block.spec.ts +365 -0
  177. package/template/blocks/newsletter/block.json +105 -0
  178. package/template/blocks/newsletter/mock.json +31 -0
  179. package/template/blocks/newsletter/preview.png +0 -0
  180. package/template/blocks/order-status/Block.vue +754 -0
  181. package/template/blocks/order-status/__tests__/Block.spec.ts +515 -0
  182. package/template/blocks/order-status/block.json +138 -0
  183. package/template/blocks/order-status/mock.json +19 -0
  184. package/template/blocks/order-status/preview.png +0 -0
  185. package/template/blocks/pricing-table/Block.vue +297 -0
  186. package/template/blocks/pricing-table/__tests__/Block.spec.ts +357 -0
  187. package/template/blocks/pricing-table/block.json +155 -0
  188. package/template/blocks/pricing-table/mock.json +47 -0
  189. package/template/blocks/pricing-table/preview.png +0 -0
  190. package/template/blocks/product-carousel/Block.vue +459 -0
  191. package/template/blocks/product-carousel/__tests__/Block.spec.ts +957 -0
  192. package/template/blocks/product-carousel/block.json +71 -0
  193. package/template/blocks/product-carousel/mock.json +9 -0
  194. package/template/blocks/product-carousel/preview.json +7 -0
  195. package/template/blocks/product-carousel/preview.png +0 -0
  196. package/template/blocks/product-detail/Block.vue +886 -0
  197. package/template/blocks/product-detail/__tests__/Block.spec.ts +1495 -0
  198. package/template/blocks/product-detail/__tests__/stock.spec.ts +119 -0
  199. package/template/blocks/product-detail/block.json +155 -0
  200. package/template/blocks/product-detail/mock.json +113 -0
  201. package/template/blocks/product-detail/parts/Gallery.vue +181 -0
  202. package/template/blocks/product-detail/parts/StickyBuyBar.vue +99 -0
  203. package/template/blocks/product-detail/preview.png +0 -0
  204. package/template/blocks/product-detail/stock.ts +150 -0
  205. package/template/blocks/quote/Block.vue +206 -0
  206. package/template/blocks/quote/__tests__/Block.spec.ts +265 -0
  207. package/template/blocks/quote/block.json +76 -0
  208. package/template/blocks/quote/mock.json +9 -0
  209. package/template/blocks/quote/preview.json +16 -0
  210. package/template/blocks/quote/preview.png +0 -0
  211. package/template/blocks/rich-text/Block.vue +143 -0
  212. package/template/blocks/rich-text/__tests__/Block.spec.ts +191 -0
  213. package/template/blocks/rich-text/block.json +57 -0
  214. package/template/blocks/rich-text/mock.json +87 -0
  215. package/template/blocks/rich-text/preview.png +0 -0
  216. package/template/blocks/search/Block.vue +589 -0
  217. package/template/blocks/search/PopularChips.vue +40 -0
  218. package/template/blocks/search/TypeSection.vue +148 -0
  219. package/template/blocks/search/__tests__/Block.spec.ts +718 -0
  220. package/template/blocks/search/__tests__/results.spec.ts +166 -0
  221. package/template/blocks/search/block.json +102 -0
  222. package/template/blocks/search/mock.json +18 -0
  223. package/template/blocks/search/preview.png +0 -0
  224. package/template/blocks/search/results.ts +85 -0
  225. package/template/blocks/split-content/Block.vue +195 -0
  226. package/template/blocks/split-content/__tests__/Block.spec.ts +225 -0
  227. package/template/blocks/split-content/block.json +70 -0
  228. package/template/blocks/split-content/mock.json +45 -0
  229. package/template/blocks/split-content/preview.json +58 -0
  230. package/template/blocks/split-content/preview.png +0 -0
  231. package/template/blocks/stats/Block.vue +159 -0
  232. package/template/blocks/stats/__tests__/Block.spec.ts +194 -0
  233. package/template/blocks/stats/block.json +73 -0
  234. package/template/blocks/stats/mock.json +12 -0
  235. package/template/blocks/stats/preview.png +0 -0
  236. package/template/blocks/tabs/Block.vue +278 -0
  237. package/template/blocks/tabs/__tests__/Block.spec.ts +303 -0
  238. package/template/blocks/tabs/block.json +97 -0
  239. package/template/blocks/tabs/mock.json +129 -0
  240. package/template/blocks/tabs/preview.json +153 -0
  241. package/template/blocks/tabs/preview.png +0 -0
  242. package/template/blocks/team/Block.vue +288 -0
  243. package/template/blocks/team/__tests__/Block.spec.ts +221 -0
  244. package/template/blocks/team/block.json +125 -0
  245. package/template/blocks/team/mock.json +39 -0
  246. package/template/blocks/team/preview.json +62 -0
  247. package/template/blocks/team/preview.png +0 -0
  248. package/template/blocks/testimonials/Block.vue +408 -0
  249. package/template/blocks/testimonials/__tests__/Block.spec.ts +319 -0
  250. package/template/blocks/testimonials/block.json +121 -0
  251. package/template/blocks/testimonials/mock.json +46 -0
  252. package/template/blocks/testimonials/preview.json +68 -0
  253. package/template/blocks/testimonials/preview.png +0 -0
  254. package/template/blocks/timeline/Block.vue +274 -0
  255. package/template/blocks/timeline/__tests__/Block.spec.ts +310 -0
  256. package/template/blocks/timeline/block.json +98 -0
  257. package/template/blocks/timeline/mock.json +27 -0
  258. package/template/blocks/timeline/preview.png +0 -0
  259. package/template/blocks/trust-strip/Block.vue +330 -0
  260. package/template/blocks/trust-strip/__tests__/Block.spec.ts +290 -0
  261. package/template/blocks/trust-strip/block.json +117 -0
  262. package/template/blocks/trust-strip/mock.json +37 -0
  263. package/template/blocks/trust-strip/preview.png +0 -0
  264. package/template/blocks/video-embed/Block.vue +354 -0
  265. package/template/blocks/video-embed/__tests__/Block.spec.ts +219 -0
  266. package/template/blocks/video-embed/__tests__/embed.spec.ts +76 -0
  267. package/template/blocks/video-embed/block.json +94 -0
  268. package/template/blocks/video-embed/embed.ts +84 -0
  269. package/template/blocks/video-embed/mock.json +13 -0
  270. package/template/blocks/video-embed/preview.json +9 -0
  271. package/template/blocks/video-embed/preview.png +0 -0
  272. package/template/blocks/wishlist/Block.vue +367 -0
  273. package/template/blocks/wishlist/__tests__/Block.spec.ts +508 -0
  274. package/template/blocks/wishlist/block.json +42 -0
  275. package/template/blocks/wishlist/mock.json +9 -0
  276. package/template/blocks/wishlist/preview.png +0 -0
  277. package/template/i18n/en-US.json +602 -0
  278. package/template/i18n/is-IS.json +602 -0
  279. package/template/nuxt.config.ts +148 -0
  280. package/template/package.json +55 -0
  281. package/template/pages/article.page.json +731 -0
  282. package/template/pages/cart.page.json +85 -0
  283. package/template/pages/category.page.json +133 -0
  284. package/template/pages/collection.page.json +194 -0
  285. package/template/pages/home.page.json +353 -0
  286. package/template/pages/product.page.json +323 -0
  287. package/template/pages/products.page.json +144 -0
  288. package/template/pages/search.page.json +83 -0
  289. package/template/pages/wishlist.page.json +88 -0
  290. package/template/public/demo/article-cover.svg +1 -0
  291. package/template/public/demo/article-figure.svg +1 -0
  292. package/template/public/demo/avatar-1.svg +3 -0
  293. package/template/public/demo/avatar-2.svg +3 -0
  294. package/template/public/demo/avatar-3.svg +3 -0
  295. package/template/public/demo/avatar-4.svg +3 -0
  296. package/template/public/demo/avatar-5.svg +3 -0
  297. package/template/public/demo/avatar-6.svg +3 -0
  298. package/template/public/demo/avatar-7.svg +3 -0
  299. package/template/public/demo/avatar-8.svg +3 -0
  300. package/template/public/demo/collection-1.svg +1 -0
  301. package/template/public/demo/collection-2.svg +1 -0
  302. package/template/public/demo/cta-split.svg +1 -0
  303. package/template/public/demo/feature-1.svg +1 -0
  304. package/template/public/demo/feature-2.svg +1 -0
  305. package/template/public/demo/feature-3.svg +1 -0
  306. package/template/public/demo/feature-4.svg +1 -0
  307. package/template/public/demo/gallery-1.svg +1 -0
  308. package/template/public/demo/gallery-2.svg +1 -0
  309. package/template/public/demo/gallery-3.svg +1 -0
  310. package/template/public/demo/gallery-4.svg +1 -0
  311. package/template/public/demo/gallery-5.svg +1 -0
  312. package/template/public/demo/gallery-6.svg +1 -0
  313. package/template/public/demo/gallery-7.svg +1 -0
  314. package/template/public/demo/gallery-8.svg +1 -0
  315. package/template/public/demo/hero-slide-1.svg +1 -0
  316. package/template/public/demo/hero-slide-2.svg +1 -0
  317. package/template/public/demo/hero-slide-3.svg +1 -0
  318. package/template/public/demo/hero-slide-4.svg +1 -0
  319. package/template/public/demo/hero-wide.svg +1 -0
  320. package/template/public/demo/hero.svg +1 -0
  321. package/template/public/demo/logo-1.svg +4 -0
  322. package/template/public/demo/logo-2.svg +4 -0
  323. package/template/public/demo/logo-3.svg +4 -0
  324. package/template/public/demo/logo-4.svg +4 -0
  325. package/template/public/demo/logo-5.svg +4 -0
  326. package/template/public/demo/logo-6.svg +4 -0
  327. package/template/public/demo/logo-7.svg +4 -0
  328. package/template/public/demo/logo-8.svg +4 -0
  329. package/template/public/demo/logo.svg +3 -0
  330. package/template/public/demo/map.svg +1 -0
  331. package/template/public/demo/poster.svg +1 -0
  332. package/template/public/demo/product-1.svg +4 -0
  333. package/template/public/demo/product-10.svg +4 -0
  334. package/template/public/demo/product-11.svg +4 -0
  335. package/template/public/demo/product-12.svg +4 -0
  336. package/template/public/demo/product-2.svg +4 -0
  337. package/template/public/demo/product-3.svg +4 -0
  338. package/template/public/demo/product-4.svg +4 -0
  339. package/template/public/demo/product-5.svg +4 -0
  340. package/template/public/demo/product-6.svg +4 -0
  341. package/template/public/demo/product-7.svg +4 -0
  342. package/template/public/demo/product-8.svg +4 -0
  343. package/template/public/demo/product-9.svg +4 -0
  344. package/template/public/demo/product-square-1.svg +4 -0
  345. package/template/public/demo/product-square-2.svg +4 -0
  346. package/template/public/demo/product-square-3.svg +4 -0
  347. package/template/public/demo/product-square-4.svg +4 -0
  348. package/template/public/demo/product-square-5.svg +4 -0
  349. package/template/public/demo/product-square-6.svg +4 -0
  350. package/template/public/demo/quote-portrait.svg +4 -0
  351. package/template/public/demo/split-1.svg +1 -0
  352. package/template/public/demo/split-2.svg +1 -0
  353. package/template/public/demo/split-3.svg +1 -0
  354. package/template/public/demo/split-4.svg +1 -0
  355. package/template/public/demo/team-1.svg +4 -0
  356. package/template/public/demo/team-2.svg +4 -0
  357. package/template/public/demo/team-3.svg +4 -0
  358. package/template/public/demo/team-4.svg +4 -0
  359. package/template/scripts/demo-images.mjs +393 -0
  360. package/template/scripts/generate-stories.mjs +156 -0
  361. package/template/scripts/previewHash.mjs +125 -0
  362. package/template/scripts/previews.mjs +149 -0
  363. package/template/stories/generated/announcement-bar.stories.ts +44 -0
  364. package/template/stories/generated/article-list.stories.ts +87 -0
  365. package/template/stories/generated/article.stories.ts +27 -0
  366. package/template/stories/generated/breadcrumbs.stories.ts +39 -0
  367. package/template/stories/generated/cart.stories.ts +38 -0
  368. package/template/stories/generated/collection-grid.stories.ts +117 -0
  369. package/template/stories/generated/collection-header.stories.ts +51 -0
  370. package/template/stories/generated/contact.stories.ts +45 -0
  371. package/template/stories/generated/cta.stories.ts +51 -0
  372. package/template/stories/generated/faq.stories.ts +56 -0
  373. package/template/stories/generated/feature-grid.stories.ts +69 -0
  374. package/template/stories/generated/footer.stories.ts +50 -0
  375. package/template/stories/generated/gallery.stories.ts +81 -0
  376. package/template/stories/generated/hero.stories.ts +75 -0
  377. package/template/stories/generated/image.stories.ts +99 -0
  378. package/template/stories/generated/logo-cloud.stories.ts +57 -0
  379. package/template/stories/generated/navigation.stories.ts +62 -0
  380. package/template/stories/generated/newsletter.stories.ts +68 -0
  381. package/template/stories/generated/order-status.stories.ts +32 -0
  382. package/template/stories/generated/pricing-table.stories.ts +44 -0
  383. package/template/stories/generated/product-carousel.stories.ts +75 -0
  384. package/template/stories/generated/product-detail.stories.ts +62 -0
  385. package/template/stories/generated/quote.stories.ts +69 -0
  386. package/template/stories/generated/rich-text.stories.ts +50 -0
  387. package/template/stories/generated/search.stories.ts +56 -0
  388. package/template/stories/generated/split-content.stories.ts +39 -0
  389. package/template/stories/generated/stats.stories.ts +68 -0
  390. package/template/stories/generated/tabs.stories.ts +45 -0
  391. package/template/stories/generated/team.stories.ts +45 -0
  392. package/template/stories/generated/testimonials.stories.ts +69 -0
  393. package/template/stories/generated/timeline.stories.ts +80 -0
  394. package/template/stories/generated/trust-strip.stories.ts +62 -0
  395. package/template/stories/generated/video-embed.stories.ts +63 -0
  396. package/template/stories/generated/wishlist.stories.ts +26 -0
  397. package/template/stories/pages/article.stories.ts +51 -0
  398. package/template/stories/pages/cart.stories.ts +56 -0
  399. package/template/stories/pages/category.stories.ts +56 -0
  400. package/template/stories/pages/collection.stories.ts +51 -0
  401. package/template/stories/pages/home.stories.ts +51 -0
  402. package/template/stories/pages/product.stories.ts +47 -0
  403. package/template/stories/pages/products.stories.ts +58 -0
  404. package/template/stories/pages/search.stories.ts +54 -0
  405. package/template/stories/pages/wishlist.stories.ts +53 -0
  406. package/template/stories/support/pageBlocks.ts +115 -0
  407. package/template/test/blocksEmptyData.spec.ts +52 -0
  408. package/template/test/carouselKeyboard.spec.ts +272 -0
  409. package/template/test/carouselRing.browser.spec.ts +193 -0
  410. package/template/test/carouselSlideWidth.browser.spec.ts +102 -0
  411. package/template/test/cartDrawer.spec.ts +295 -0
  412. package/template/test/cartToast.spec.ts +86 -0
  413. package/template/test/countPill.browser.spec.ts +196 -0
  414. package/template/test/demoImages.spec.ts +140 -0
  415. package/template/test/deps.spec.ts +102 -0
  416. package/template/test/eldraIcon.spec.ts +58 -0
  417. package/template/test/framing.spec.ts +76 -0
  418. package/template/test/i18n.spec.ts +200 -0
  419. package/template/test/iconComponent.spec.ts +91 -0
  420. package/template/test/inlineEditable.spec.ts +334 -0
  421. package/template/test/localePrefix.spec.ts +342 -0
  422. package/template/test/mainCss.spec.ts +107 -0
  423. package/template/test/mockGatewayContract.spec.ts +122 -0
  424. package/template/test/mocks/blocks.ts +20 -0
  425. package/template/test/mocks/breakpoints.ts +7 -0
  426. package/template/test/mocks/manifest.ts +11 -0
  427. package/template/test/moneyFormatting.spec.ts +89 -0
  428. package/template/test/pageTitle.spec.ts +49 -0
  429. package/template/test/pages/article.spec.ts +231 -0
  430. package/template/test/pages/category.spec.ts +185 -0
  431. package/template/test/pages/collection.spec.ts +396 -0
  432. package/template/test/pages/home.spec.ts +295 -0
  433. package/template/test/pages/hydration.spec.ts +557 -0
  434. package/template/test/pages/product.spec.ts +396 -0
  435. package/template/test/pages/seededPages.spec.ts +190 -0
  436. package/template/test/pages/ssr.spec.ts +393 -0
  437. package/template/test/prerenderCommerce.spec.ts +134 -0
  438. package/template/test/prerenderFailure.spec.ts +130 -0
  439. package/template/test/prerenderRefresh.browser.spec.ts +1431 -0
  440. package/template/test/previewsFresh.spec.ts +56 -0
  441. package/template/test/richText.spec.ts +161 -0
  442. package/template/test/richTextTypography.spec.ts +182 -0
  443. package/template/test/setup.ts +21 -0
  444. package/template/test/slugPage.spec.ts +244 -0
  445. package/template/test/slugPageTemplate.spec.ts +194 -0
  446. package/template/test/starter.spec.ts +1416 -0
  447. package/template/test/storefront/cart.spec.ts +404 -0
  448. package/template/test/storefront/categories.spec.ts +235 -0
  449. package/template/test/storefront/collectionSelector.spec.ts +74 -0
  450. package/template/test/storefront/demo.spec.ts +555 -0
  451. package/template/test/storefront/facets.spec.ts +425 -0
  452. package/template/test/storefront/feedback.spec.ts +97 -0
  453. package/template/test/storefront/gateway.spec.ts +2673 -0
  454. package/template/test/storefront/gatewayCart.spec.ts +289 -0
  455. package/template/test/storefront/gatewayPrerender.spec.ts +1037 -0
  456. package/template/test/storefront/history.spec.ts +341 -0
  457. package/template/test/storefront/money.spec.ts +171 -0
  458. package/template/test/storefront/toProductCard.spec.ts +138 -0
  459. package/template/test/storefront/volatile.spec.ts +284 -0
  460. package/template/test/support/axe.ts +14 -0
  461. package/template/test/support/dialog.ts +51 -0
  462. package/template/test/support/hydrate.ts +118 -0
  463. package/template/test/support/i18nText.ts +11 -0
  464. package/template/test/support/mockGateway.ts +1017 -0
  465. package/template/test/support/mountBlock.ts +194 -0
  466. package/template/test/support/mountPage.spec.ts +72 -0
  467. package/template/test/support/mountPage.ts +254 -0
  468. package/template/test/support/mountProbe.client.ts +69 -0
  469. package/template/test/support/renderSsr.ts +97 -0
  470. package/template/test/support/staticServer.ts +96 -0
  471. package/template/test/themeIcons.spec.ts +140 -0
  472. package/template/test/toastAnnouncement.spec.ts +133 -0
  473. package/template/test/tokens.spec.ts +102 -0
  474. package/template/test/uiMessagesPlugin.spec.ts +104 -0
  475. package/template/test/useBlockData.spec.ts +46 -0
  476. package/template/test/useEditing.spec.ts +54 -0
  477. package/template/test/useEldraIcon.spec.ts +126 -0
  478. package/template/test/useUiId.spec.ts +40 -0
  479. package/template/tokens.json +149 -0
  480. package/template/tsconfig.json +3 -0
  481. package/template/tsconfig.storybook.json +17 -0
  482. package/template/vitest-axe.d.ts +13 -0
  483. package/template/vitest.config.ts +44 -0
@@ -0,0 +1,652 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Site footer (spec `eldra-starter-spec/02-blocks.md` lines 440–597). `variant`:
4
+ * - `default`: brand (wordmark, description, social), link groups, an optional newsletter
5
+ * sign-up. Legal row below a hairline, with the locale/currency selectors.
6
+ * - `minimal`: brand, a flat row of links, social. Then the same legal row.
7
+ *
8
+ * Editor hints (`EditorPlaceholder`, gated by `useEditing()`) cover the spec's three Footer
9
+ * "States" rows — description, link groups, newsletter — on the `default` variant; see `editing`
10
+ * below.
11
+ *
12
+ * Landmark naming follows the spec literally per variant (line 549): `default`'s `<footer>` is
13
+ * `aria-labelledby` a visually hidden `<h2>` ("Site footer"); `minimal` has no heading of its own
14
+ * (no groups, no newsletter title), so it names the landmark directly with `aria-label` instead —
15
+ * both are real, valid accessible names, this is just which mechanism supplies it.
16
+ *
17
+ * The locale `Select` renders with no `leadingIcon` (spec: decorative "world" icon).
18
+ * `Select.leadingIcon` needs a synchronous `IconComponent`; this theme's only icon resolution path
19
+ * (`EldraIcon`/`useEldraIcon`) is name-based and asynchronous (an HTTP fetch under Nuxt, with no
20
+ * client-side raw-SVG source to resolve one synchronously from). Wiring one in would mean either
21
+ * forking `@eldrajs/ui`'s `Select` or hand-rolling a second, parallel icon-loading path outside
22
+ * `useEldraIcon` for a purely decorative detail with no acceptance criterion or test coverage —
23
+ * left out rather than doing either. The currency slot below renders its own "credit-card" icon
24
+ * directly as an `EldraIcon` (not through `Select.leadingIcon`), so that constraint does not apply
25
+ * to it.
26
+ *
27
+ * Every group/flat/legal destination is a `link` value — a collection, product, page or entry the
28
+ * platform knows, or an external URL — resolved once through `useEldraLink()`. A row whose target
29
+ * has been deleted, or that the site has no route for, keeps its label and renders as plain text
30
+ * rather than a dead anchor; a row with no label renders nothing. A same-site path routes through
31
+ * `EldraRouterLink` (see `app/utils/links.ts`). `tone="muted"` + `:underline="false"` is the
32
+ * spec's tertiary link, turning `text` with an underline only on hover; legal links keep the
33
+ * package's own underline-at-rest default (spec: "always underlined").
34
+ *
35
+ * The locale selector is **not** CMS content, and it is not a theme constant either: its options are
36
+ * the organisation's own content locales (`useEldraLocale().supported`, read once at build onto the
37
+ * runtime config by `@eldrajs/theme-nuxt`). The spec called them "mock-independent theme constants"
38
+ * and the block shipped a `us-en / ca-en / ca-fr` demo list, which named three locales no store has
39
+ * and switched to none of them. Each option is labelled with the locale's **own** name through
40
+ * `Intl.DisplayNames(tag, { type: 'language' })` — "íslenska (Ísland)", not "Icelandic" — because a
41
+ * visitor looking for their language is looking for it written the way they write it; the raw tag is
42
+ * the fallback for a locale the runtime has no name for. Choosing one navigates to the same page
43
+ * under that locale (`select()`), and with a single locale there is nothing to choose, so it renders
44
+ * nothing at all — the same rule the currency slot already follows. `Select` commits only on `Enter`
45
+ * or a click (its own contract; arrow keys alone only move the active option), so nothing extra is
46
+ * needed here to satisfy "prices reload only after Enter or a click" (3.2.2).
47
+ *
48
+ * The currency selector is different: the spec was written for a multi-currency store, but the
49
+ * platform supports exactly one currency per store today. So its options are derived from the
50
+ * store (`useMoney().currency`, `app/storefront/money.ts`), not from a constant list, and there is
51
+ * at most one of them — `currencyLabel()` names it "ISK kr" style (code + the narrow sign
52
+ * `@eldrajs/ui` writes the store's prices with in the content locale, falling back to the code
53
+ * alone when the locale has no sign distinct from it). With exactly one option
54
+ * there is nothing to select, so it renders as plain text with the same leading icon and a visually
55
+ * hidden "Currency" label, not a `Select` — a native-looking control a visitor could try to open
56
+ * with nothing inside it would be worse than no control at all. With no currency published, the
57
+ * slot renders nothing. The `Select` branch stays for the day the derived list carries two or more
58
+ * entries; which branch renders is driven by that list's length, not by a separate flag.
59
+ *
60
+ * The newsletter zone posts through `useStorefront().forms.subscribe`. Email format is validated
61
+ * locally (empty/malformed never reaches the storefront); a backend `{ ok: false }` shows the same
62
+ * error slot. Both failure paths return focus to the email field — `FormLayout`'s own submit
63
+ * handler only refuses a *second* submit while a field is already marked invalid, so the first
64
+ * invalid attempt's error + refocus is this block's own job.
65
+ *
66
+ * A backend failure (`{ ok: false }` for a reason other than the address itself) marks the field
67
+ * invalid the same way a malformed address does, but nothing about the *value* is wrong — the
68
+ * visitor's natural next move is pressing Subscribe again, unchanged. `FormLayout`'s own submit
69
+ * handler refuses to emit `submit` at all while any field still carries `aria-invalid="true"` (see
70
+ * that component's own doc comment), so an unchanged resubmit after a backend failure would
71
+ * otherwise be silently swallowed forever — the exact gap `blocks/newsletter/Block.vue` fixed
72
+ * first (`retryable` + `@invalid`, ported here verbatim): `retryable` remembers that the current
73
+ * error came from the service, not the address, and `onNewsletterInvalid` (wired to `FormLayout`'s
74
+ * `@invalid`) clears the stale mark and re-dispatches the same submit once, the moment the gate
75
+ * actually fires.
76
+ */
77
+ import { computed, nextTick, ref, watch } from 'vue';
78
+ import { useEldraLink, useEldraLocale } from '@eldrajs/theme-vue';
79
+ import type { ResolvedLink } from '@eldrajs/theme-vue';
80
+ import {
81
+ Button,
82
+ Container,
83
+ EditorPlaceholder,
84
+ FieldWrapper,
85
+ FormLayout,
86
+ Input,
87
+ Link,
88
+ Section,
89
+ Select,
90
+ useEldraUiLocale,
91
+ VisuallyHidden,
92
+ type FormLayoutSubmitPayload,
93
+ type SelectOption,
94
+ } from '@eldrajs/ui';
95
+ import { useBlockData } from '../../app/composables/useBlockData';
96
+ import { useEditing } from '../../app/composables/useEditing';
97
+ import { useI18n } from 'vue-i18n';
98
+ import { useUiId } from '../../app/composables/useUiId';
99
+ import { useStorefront } from '../../app/composables/useStorefront';
100
+ import EldraIcon from '../../app/components/EldraIcon.vue';
101
+ import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
102
+ import type { ThemeIconName } from '../../app/icons';
103
+ import { currencyLabel, useMoney } from '../../app/storefront/money';
104
+ import { isInternalHref, safeHref } from '../../app/utils/links';
105
+
106
+ type FooterLink = {
107
+ label: string;
108
+ href: string | undefined;
109
+ as: typeof EldraRouterLink | undefined;
110
+ };
111
+
112
+ const props = defineProps<{ entry: EldraBlockEntry<'footer'> }>();
113
+ const { data } = useBlockData(props, 'footer');
114
+ const { t } = useI18n();
115
+ /**
116
+ * The spec's three Footer "States" hints (`eldra-starter-spec/02-blocks.md`): a freshly inserted
117
+ * footer has no description, no link groups and — on a page that already carries a Newsletter
118
+ * block — no newsletter form, so on the live site that band renders almost empty and in the editor
119
+ * there was nothing at all telling an editor what goes where, while all 32 sibling blocks show
120
+ * dashed placeholders. Editor-only, like every other hint in the theme: `useEditing()` is true
121
+ * only in Studio's edit mode, never on the live site and never in read-only preview.
122
+ *
123
+ * Only on the `default` variant — `minimal` has no description, groups or newsletter zone at all,
124
+ * so a hint there would point at fields that variant ignores.
125
+ */
126
+ const editing = useEditing();
127
+ const storefront = useStorefront();
128
+ const money = useMoney();
129
+ const uiLocale = useEldraUiLocale();
130
+
131
+ const headingId = `footer-heading-${useUiId()}`;
132
+
133
+ const variant = computed(() => data.value.variant ?? 'default');
134
+ const background = computed(() => data.value.background ?? 'surface-strong');
135
+
136
+ /** Section spacing (spec "Footer" → Container/spacing): the shared `sm`/`md`/`lg` scale doesn't
137
+ * carry these exact steps, so `spacing="none"` on `Section` and the padding is written here. */
138
+ const paddingClass = computed(() =>
139
+ variant.value === 'minimal' ? 'py-8' : 'pt-12 pb-6 @tablet:pt-16 @tablet:pb-8'
140
+ );
141
+
142
+ const resolveLink = useEldraLink();
143
+
144
+ /** Drops a row with nothing to show, and resolves a same-site destination through the router (see
145
+ * file doc). A row whose target no longer resolves keeps its label and loses its href. */
146
+ function resolveLinks(links: unknown[] | undefined): FooterLink[] {
147
+ return (links ?? []).flatMap((value) => {
148
+ const resolved = resolveLink(value);
149
+ return resolved === null ? [] : toRows([resolved]);
150
+ });
151
+ }
152
+
153
+ /** The same drop-and-route rule over links that are already resolved — a group's children. */
154
+ function toRows(resolved: readonly ResolvedLink[]): FooterLink[] {
155
+ return resolved.flatMap((link) => {
156
+ if (link.label === null) return [];
157
+ const href = link.href ?? undefined;
158
+ return [
159
+ {
160
+ label: link.label,
161
+ href,
162
+ as: href !== undefined && isInternalHref(href) ? EldraRouterLink : undefined,
163
+ },
164
+ ];
165
+ });
166
+ }
167
+
168
+ /**
169
+ * A link group is one link whose label is the column heading and whose children are the column's
170
+ * links — the same shape the header's mega-menu uses. A group's own destination is never rendered,
171
+ * for the same reason the header's is not: the row that heads a column is a heading, not a link.
172
+ */
173
+ const groups = computed(() =>
174
+ (data.value.groups ?? []).flatMap((value) => {
175
+ const resolved = resolveLink(value);
176
+ if (resolved === null || resolved.label === null) return [];
177
+ return [{ title: resolved.label, links: toRows(resolved.children) }];
178
+ })
179
+ );
180
+ const minimalLinks = computed(() => resolveLinks(data.value.links));
181
+ const legalLinks = computed(() => resolveLinks(data.value.legalLinks));
182
+
183
+ /** Typed against the theme's own icon set, so a name it does not bundle is a type error. */
184
+ const SOCIAL_ICON_NAMES: Record<string, ThemeIconName> = {
185
+ instagram: 'brand-instagram',
186
+ facebook: 'brand-facebook',
187
+ pinterest: 'brand-pinterest',
188
+ tiktok: 'brand-tiktok',
189
+ youtube: 'brand-youtube',
190
+ };
191
+
192
+ const SOCIAL_NAME_KEYS: Record<string, MessageKey> = {
193
+ instagram: 'footer.social.instagram',
194
+ facebook: 'footer.social.facebook',
195
+ pinterest: 'footer.social.pinterest',
196
+ tiktok: 'footer.social.tiktok',
197
+ youtube: 'footer.social.youtube',
198
+ };
199
+
200
+ const socialLinks = computed(() =>
201
+ (data.value.social ?? []).flatMap((item) => {
202
+ const href = safeHref(item.href);
203
+ if (href === null) return [];
204
+ return [
205
+ {
206
+ network: item.network,
207
+ href,
208
+ as: isInternalHref(href) ? EldraRouterLink : undefined,
209
+ icon: SOCIAL_ICON_NAMES[item.network] ?? 'link',
210
+ },
211
+ ];
212
+ })
213
+ );
214
+
215
+ function socialLinkName(network: string): string {
216
+ const key = SOCIAL_NAME_KEYS[network] ?? 'footer.social.instagram';
217
+ return t('footer.socialLinkName', { brand: data.value.brandText, network: t(key) });
218
+ }
219
+
220
+ /**
221
+ * The site's own locales, and which one this page is in.
222
+ *
223
+ * `supported` is empty on a store that has configured none and on every render outside a Nuxt site
224
+ * (a story, a unit mount), which is the same thing as far as this block is concerned: nothing to
225
+ * switch between.
226
+ */
227
+ const activeLocale = useEldraLocale();
228
+
229
+ /**
230
+ * Each option is labelled with the locale's **own** name — "íslenska (Ísland)", not "Icelandic" —
231
+ * which `useEldraLocale().name` answers from `Intl.DisplayNames` with the tag as the fallback.
232
+ *
233
+ * The lookup is not done here, and that is the whole point: it is ICU data, and the renderer and
234
+ * the browser do not always have the same of it (Node answers "íslenska (Ísland)" for `is-IS` where
235
+ * a reduced-ICU browser build answers "Icelandic (Iceland)"), so a block that computed its own
236
+ * labels shipped a prerendered footer that hydrated into a mismatch and repainted — on every page
237
+ * of the site. The adapter resolves them once, on the server, and carries them to the browser.
238
+ */
239
+ const localeOptions = computed<SelectOption[]>(() =>
240
+ activeLocale.supported.map((tag) => ({ value: tag, label: activeLocale.name(tag) }))
241
+ );
242
+
243
+ /**
244
+ * The switcher renders only when there is a choice to make. A single-locale store — which is most
245
+ * of them, and every Storybook story — gets no control at all rather than a combobox a visitor can
246
+ * open onto one option, exactly as the currency slot does.
247
+ */
248
+ const showLocale = computed(
249
+ () => (data.value.showLocale ?? true) && localeOptions.value.length > 1
250
+ );
251
+ const showCurrency = computed(() => data.value.showCurrency ?? true);
252
+
253
+ /**
254
+ * The currency selector's option list, derived from the store rather than the spec's hard-coded
255
+ * USD/CAD/EUR demo list: the platform supports exactly one currency per store today, so this is
256
+ * either empty (the store publishes none) or a single entry — the store's currency, named "ISK
257
+ * kr" style by `currencyLabel()` (code + the same narrow sign every price on the page is written
258
+ * with). Kept as a list, not a single value, so the day the platform supports more than one
259
+ * currency, this grows to match and the template's `Select` branch (below) is already there.
260
+ */
261
+ const currencyOptions = computed<SelectOption[]>(() => {
262
+ const code = money.currency.value;
263
+ return code === undefined ? [] : [{ value: code, label: currencyLabel(code, uiLocale.value) }];
264
+ });
265
+
266
+ /** Whether the currency slot renders anything: `showCurrency` on *and* a currency to show it. */
267
+ const showCurrencySelector = computed(() => showCurrency.value && currencyOptions.value.length > 0);
268
+
269
+ const hasSelectors = computed(() => showLocale.value || showCurrencySelector.value);
270
+
271
+ /**
272
+ * The legal row carries the rule that separates it from the zone above, so a row with nothing in it
273
+ * is a hairline across the footer under empty space. A footer with no legal line, no legal links and
274
+ * both selectors off has exactly that, which is a shape an author can reach from the panel — and the
275
+ * shape a store that has not written its policy pages yet starts from — so the row goes when there is
276
+ * nothing to rule off.
277
+ */
278
+ const hasLegalRow = computed(
279
+ () => Boolean(data.value.legalText) || legalLinks.value.length > 0 || hasSelectors.value
280
+ );
281
+
282
+ /**
283
+ * The selector's value is the page's own locale, and setting it is a navigation — there is no local
284
+ * state to keep. The page the visitor lands on is this same page under the chosen locale's prefix,
285
+ * which is what re-renders this footer with the new value; a `ref` of its own would have shown the
286
+ * choice immediately and then disagreed with the page if the navigation was refused or slow.
287
+ */
288
+ const locale = computed<string>({
289
+ get: () => activeLocale.active ?? '',
290
+ set: (value) => {
291
+ if (value !== '' && value !== activeLocale.active) activeLocale.select(value);
292
+ },
293
+ });
294
+ /** Only reached once `currencyOptions` carries two or more entries — see the template. */
295
+ const currency = ref<string>(currencyOptions.value[0]?.value ?? '');
296
+
297
+ /* ---------------------------------------------------------------------- */
298
+ /* Newsletter */
299
+ /* ---------------------------------------------------------------------- */
300
+
301
+ const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
302
+
303
+ const email = ref('');
304
+ const emailError = ref<string | null>(null);
305
+ const newsletterState = ref<'idle' | 'submitting' | 'success'>('idle');
306
+ const emailFieldRoot = ref<HTMLElement | null>(null);
307
+
308
+ const showNewsletter = computed(
309
+ () => variant.value === 'default' && (data.value.showNewsletter ?? true)
310
+ );
311
+
312
+ /** Mirrors `blocks/newsletter/Block.vue`'s own comment: an error has to clear itself the moment
313
+ * its own condition is fixed (the visitor edits the address), not only inside a later successful
314
+ * `onNewsletterSubmit` — otherwise a corrected but still-marked field wedges every future submit
315
+ * behind `FormLayout`'s own invalid gate before this handler ever runs. */
316
+ watch(email, () => {
317
+ emailError.value = null;
318
+ retryable.value = false;
319
+ });
320
+
321
+ /** See the module doc comment: a sign-up-service failure is retryable — nothing about the value
322
+ * itself is wrong — so the field is remembered as such and, when `FormLayout`'s invalid gate
323
+ * fires on the unchanged resubmit, the stale mark is cleared and the same submit is re-dispatched. */
324
+ const retryable = ref(false);
325
+
326
+ function onNewsletterInvalid(): void {
327
+ if (!retryable.value) return;
328
+ retryable.value = false;
329
+ emailError.value = null;
330
+ const form = emailFieldRoot.value?.closest('form');
331
+ if (!form) return;
332
+ void nextTick(() => {
333
+ form.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }));
334
+ });
335
+ }
336
+
337
+ async function focusEmailField(): Promise<void> {
338
+ await nextTick();
339
+ emailFieldRoot.value?.querySelector<HTMLInputElement>('input')?.focus();
340
+ }
341
+
342
+ async function onNewsletterSubmit(payload: FormLayoutSubmitPayload): Promise<void> {
343
+ payload.event.preventDefault();
344
+ // Spec "Newsletter submitting": repeat submits are ignored while one is already in flight (the
345
+ // submit Button stays clickable while loading — see `Button.vue`'s own comment on that).
346
+ if (newsletterState.value === 'submitting') return;
347
+
348
+ const value = String(payload.data.get('email') ?? '').trim();
349
+
350
+ if (!EMAIL_PATTERN.test(value)) {
351
+ emailError.value = t('footer.emailInvalid');
352
+ await focusEmailField();
353
+ return;
354
+ }
355
+
356
+ emailError.value = null;
357
+ newsletterState.value = 'submitting';
358
+ const result = await storefront.forms.subscribe({ email: value, list: 'footer-newsletter' });
359
+
360
+ if (result.ok) {
361
+ newsletterState.value = 'success';
362
+ return;
363
+ }
364
+
365
+ newsletterState.value = 'idle';
366
+ const serviceFailed = result.reason !== 'invalid';
367
+ retryable.value = serviceFailed;
368
+ emailError.value = serviceFailed ? t('footer.emailError') : t('footer.emailInvalid');
369
+ await focusEmailField();
370
+ }
371
+ </script>
372
+
373
+ <template>
374
+ <Section
375
+ as="footer"
376
+ :background="background"
377
+ spacing="none"
378
+ :labelled-by="variant === 'default' ? headingId : undefined"
379
+ :aria-label="variant === 'minimal' ? t('footer.title') : undefined"
380
+ :classes="{ root: paddingClass }"
381
+ >
382
+ <Container width="wide">
383
+ <VisuallyHidden v-if="variant === 'default'" :id="headingId" as="h2">{{
384
+ t('footer.title')
385
+ }}</VisuallyHidden>
386
+
387
+ <!-- Default variant: brand · link groups · newsletter -->
388
+ <div
389
+ v-if="variant === 'default'"
390
+ class="@tablet:grid-cols-2 @content:grid-cols-[minmax(0,4fr)_minmax(0,5fr)_minmax(0,3.5fr)] @content:gap-12 grid gap-10"
391
+ >
392
+ <div class="max-w-[22rem]">
393
+ <Link
394
+ href="/"
395
+ :as="EldraRouterLink"
396
+ variant="standalone"
397
+ :underline="false"
398
+ :classes="{
399
+ root: 'inline-flex items-center hover:no-underline active:no-underline',
400
+ label: 'font-heading text-text text-xl leading-[1.2] font-bold tracking-[-0.015em]',
401
+ }"
402
+ >
403
+ <img
404
+ v-if="data.brandLogo"
405
+ :src="data.brandLogo.url"
406
+ :alt="data.brandText"
407
+ class="h-10 w-auto max-w-none"
408
+ loading="eager"
409
+ decoding="async"
410
+ />
411
+ <template v-else>{{ data.brandText }}</template>
412
+ </Link>
413
+ <p v-if="data.description" class="text-muted mt-4 text-base leading-relaxed">
414
+ {{ data.description }}
415
+ </p>
416
+ <EditorPlaceholder
417
+ v-else-if="editing"
418
+ inline
419
+ class="mt-4"
420
+ :label="t('footer.descriptionHintLabel')"
421
+ />
422
+
423
+ <ul v-if="socialLinks.length > 0" class="mt-6 -ml-3 flex flex-wrap gap-1" role="list">
424
+ <li v-for="social in socialLinks" :key="social.network">
425
+ <Button
426
+ icon-only
427
+ variant="ghost"
428
+ :href="social.href"
429
+ :as="social.as"
430
+ target="_blank"
431
+ rel="noopener"
432
+ :label="socialLinkName(social.network)"
433
+ :classes="{ container: 'size-11' }"
434
+ >
435
+ <template #leadingIcon>
436
+ <EldraIcon :name="social.icon" size="md" />
437
+ </template>
438
+ </Button>
439
+ </li>
440
+ </ul>
441
+ </div>
442
+
443
+ <EditorPlaceholder
444
+ v-if="groups.length === 0 && editing"
445
+ class="@tablet:col-span-2 @content:col-span-1"
446
+ :label="t('footer.groupsHintLabel')"
447
+ :help="t('footer.groupsHintHelp')"
448
+ />
449
+ <nav
450
+ v-else-if="groups.length > 0"
451
+ :aria-label="t('footer.nav')"
452
+ class="@tablet:col-span-2 @content:col-span-1"
453
+ >
454
+ <div class="@content:grid-cols-3 grid grid-cols-2 gap-x-6 gap-y-8">
455
+ <div v-for="(group, index) in groups" :key="index">
456
+ <h3 class="text-text text-base font-semibold">{{ group.title }}</h3>
457
+ <ul class="mt-2 space-y-1">
458
+ <li v-for="(link, linkIndex) in group.links" :key="linkIndex">
459
+ <Link
460
+ v-if="link.href"
461
+ :href="link.href"
462
+ :as="link.as"
463
+ tone="muted"
464
+ :underline="false"
465
+ :classes="{ root: 'inline-flex min-h-9 items-center text-base' }"
466
+ >{{ link.label }}</Link
467
+ >
468
+ <span v-else class="text-muted inline-flex min-h-9 items-center text-base">{{
469
+ link.label
470
+ }}</span>
471
+ </li>
472
+ </ul>
473
+ </div>
474
+ </div>
475
+ </nav>
476
+
477
+ <EditorPlaceholder
478
+ v-if="!showNewsletter && editing"
479
+ class="@tablet:col-span-2 @content:col-span-1"
480
+ :label="t('footer.newsletterHintLabel')"
481
+ />
482
+ <div v-else-if="showNewsletter" class="@tablet:col-span-2 @content:col-span-1">
483
+ <template v-if="newsletterState !== 'success'">
484
+ <FormLayout
485
+ layout="inline"
486
+ :heading="data.newsletterTitle || undefined"
487
+ :heading-level="3"
488
+ :aria-label="data.newsletterTitle ? undefined : t('footer.newsletterAriaLabel')"
489
+ :submitting="newsletterState === 'submitting'"
490
+ @submit="onNewsletterSubmit"
491
+ @invalid="onNewsletterInvalid"
492
+ >
493
+ <p
494
+ v-if="data.newsletterText"
495
+ class="text-muted mb-1 w-full text-base leading-relaxed"
496
+ >
497
+ {{ data.newsletterText }}
498
+ </p>
499
+ <div ref="emailFieldRoot" class="contents">
500
+ <FieldWrapper
501
+ :label="t('footer.emailLabel')"
502
+ :error="emailError ?? undefined"
503
+ :classes="{ label: 'sr-only' }"
504
+ >
505
+ <Input
506
+ v-model="email"
507
+ type="email"
508
+ name="email"
509
+ autocomplete="email"
510
+ :placeholder="t('footer.emailLabel')"
511
+ />
512
+ </FieldWrapper>
513
+ </div>
514
+ <template #actions>
515
+ <Button type="submit" variant="primary" :label="t('footer.subscribing')">{{
516
+ t('footer.subscribe')
517
+ }}</Button>
518
+ </template>
519
+ </FormLayout>
520
+ </template>
521
+ <p v-else role="status" class="text-text flex items-center gap-2 text-base">
522
+ <EldraIcon name="circle-check" size="md" class="text-success" />
523
+ {{ t('footer.subscribed') }}
524
+ </p>
525
+ </div>
526
+ </div>
527
+
528
+ <!-- Minimal variant: brand · flat links · social -->
529
+ <div v-else class="flex flex-wrap items-center justify-between gap-x-8 gap-y-4">
530
+ <Link
531
+ href="/"
532
+ :as="EldraRouterLink"
533
+ variant="standalone"
534
+ :underline="false"
535
+ :classes="{
536
+ root: 'inline-flex items-center hover:no-underline active:no-underline',
537
+ label: 'font-heading text-text text-xl leading-[1.2] font-bold tracking-[-0.015em]',
538
+ }"
539
+ >
540
+ <img
541
+ v-if="data.brandLogo"
542
+ :src="data.brandLogo.url"
543
+ :alt="data.brandText"
544
+ class="h-10 w-auto max-w-none"
545
+ loading="eager"
546
+ decoding="async"
547
+ />
548
+ <template v-else>{{ data.brandText }}</template>
549
+ </Link>
550
+
551
+ <nav v-if="minimalLinks.length > 0" :aria-label="t('footer.nav')">
552
+ <ul class="flex flex-wrap items-center gap-x-6 gap-y-2" role="list">
553
+ <li v-for="(link, index) in minimalLinks" :key="index">
554
+ <Link
555
+ v-if="link.href"
556
+ :href="link.href"
557
+ :as="link.as"
558
+ tone="muted"
559
+ :underline="false"
560
+ :classes="{ root: 'inline-flex min-h-9 items-center text-base' }"
561
+ >{{ link.label }}</Link
562
+ >
563
+ <span v-else class="text-muted inline-flex min-h-9 items-center text-base">{{
564
+ link.label
565
+ }}</span>
566
+ </li>
567
+ </ul>
568
+ </nav>
569
+
570
+ <ul v-if="socialLinks.length > 0" class="flex flex-wrap gap-1" role="list">
571
+ <li v-for="social in socialLinks" :key="social.network">
572
+ <Button
573
+ icon-only
574
+ variant="ghost"
575
+ :href="social.href"
576
+ :as="social.as"
577
+ target="_blank"
578
+ rel="noopener"
579
+ :label="socialLinkName(social.network)"
580
+ :classes="{ container: 'size-11' }"
581
+ >
582
+ <template #leadingIcon>
583
+ <EldraIcon :name="social.icon" size="md" />
584
+ </template>
585
+ </Button>
586
+ </li>
587
+ </ul>
588
+ </div>
589
+
590
+ <!-- Legal row -->
591
+ <div
592
+ v-if="hasLegalRow"
593
+ class="border-border text-muted @tablet:flex-row @tablet:items-center @tablet:justify-between mt-12 flex flex-col gap-4 border-t pt-6 text-[0.8125rem] leading-[1.4]"
594
+ >
595
+ <div class="flex flex-wrap items-center gap-x-4 gap-y-2">
596
+ <p v-if="data.legalText">{{ data.legalText }}</p>
597
+ <ul v-if="legalLinks.length > 0" class="flex flex-wrap gap-x-4 gap-y-2" role="list">
598
+ <li v-for="(link, index) in legalLinks" :key="index">
599
+ <Link
600
+ v-if="link.href"
601
+ :href="link.href"
602
+ :as="link.as"
603
+ tone="muted"
604
+ :classes="{ root: 'inline-flex min-h-6 items-center' }"
605
+ >{{ link.label }}</Link
606
+ >
607
+ <span v-else class="inline-flex min-h-6 items-center">{{ link.label }}</span>
608
+ </li>
609
+ </ul>
610
+ </div>
611
+
612
+ <div v-if="hasSelectors" class="@tablet:flex-row @tablet:items-center flex flex-col gap-2">
613
+ <FieldWrapper
614
+ v-if="showLocale"
615
+ :label="t('footer.localeLabel')"
616
+ :classes="{ root: 'w-full @tablet:w-auto', label: 'sr-only' }"
617
+ >
618
+ <!-- Not `searchable`: a store has a handful of content locales, and a search field
619
+ over three options is one more thing between a visitor and their language. -->
620
+ <Select v-model="locale" :options="localeOptions" placement="above" />
621
+ </FieldWrapper>
622
+ <!--
623
+ With exactly one currency there is nothing to select — see the file doc comment — so
624
+ this renders the currency as plain text (same leading icon, a visually hidden
625
+ "Currency" label) rather than a `Select` a visitor could open onto an empty list. The
626
+ `Select` branch stays for the day `currencyOptions` carries two or more entries.
627
+ -->
628
+ <p
629
+ v-if="showCurrencySelector && currencyOptions.length === 1"
630
+ class="text-text @tablet:w-auto flex w-full items-center gap-1.5 text-[0.8125rem] font-medium"
631
+ >
632
+ <EldraIcon name="credit-card" size="sm" class="text-muted shrink-0" />
633
+ <VisuallyHidden>{{ t('footer.currencyLabel') }}</VisuallyHidden>
634
+ {{ currencyOptions[0]!.label }}
635
+ </p>
636
+ <FieldWrapper
637
+ v-else-if="showCurrencySelector"
638
+ :label="t('footer.currencyLabel')"
639
+ :classes="{ root: 'w-full @tablet:w-auto', label: 'sr-only' }"
640
+ >
641
+ <Select
642
+ v-model="currency"
643
+ :options="currencyOptions"
644
+ placement="above"
645
+ :searchable="false"
646
+ />
647
+ </FieldWrapper>
648
+ </div>
649
+ </div>
650
+ </Container>
651
+ </Section>
652
+ </template>