@eldrajs/theme-cli 0.2.7 → 0.2.8

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 (50) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/package.json +3 -3
  3. package/template/.eldra/manifest.json +160 -132
  4. package/template/.eldra/previews.json +35 -35
  5. package/template/blocks/announcement-bar/preview.png +0 -0
  6. package/template/blocks/article/preview.png +0 -0
  7. package/template/blocks/article-list/preview.png +0 -0
  8. package/template/blocks/breadcrumbs/preview.png +0 -0
  9. package/template/blocks/cart/preview.png +0 -0
  10. package/template/blocks/collection-grid/preview.png +0 -0
  11. package/template/blocks/collection-header/preview.png +0 -0
  12. package/template/blocks/contact/preview.png +0 -0
  13. package/template/blocks/cta/preview.png +0 -0
  14. package/template/blocks/faq/preview.png +0 -0
  15. package/template/blocks/feature-grid/preview.png +0 -0
  16. package/template/blocks/footer/preview.png +0 -0
  17. package/template/blocks/form/preview.png +0 -0
  18. package/template/blocks/gallery/preview.png +0 -0
  19. package/template/blocks/hero/preview.png +0 -0
  20. package/template/blocks/image/preview.png +0 -0
  21. package/template/blocks/logo-cloud/preview.png +0 -0
  22. package/template/blocks/navigation/Block.vue +54 -11
  23. package/template/blocks/navigation/__tests__/Block.spec.ts +91 -8
  24. package/template/blocks/navigation/block.json +11 -3
  25. package/template/blocks/navigation/mock.json +134 -129
  26. package/template/blocks/navigation/preview.png +0 -0
  27. package/template/blocks/newsletter/preview.png +0 -0
  28. package/template/blocks/order-status/preview.png +0 -0
  29. package/template/blocks/pricing-table/preview.png +0 -0
  30. package/template/blocks/product-carousel/preview.png +0 -0
  31. package/template/blocks/product-detail/preview.png +0 -0
  32. package/template/blocks/quote/preview.png +0 -0
  33. package/template/blocks/rich-text/preview.png +0 -0
  34. package/template/blocks/search/preview.png +0 -0
  35. package/template/blocks/split-content/preview.png +0 -0
  36. package/template/blocks/stats/preview.png +0 -0
  37. package/template/blocks/tabs/preview.png +0 -0
  38. package/template/blocks/team/preview.png +0 -0
  39. package/template/blocks/testimonials/preview.png +0 -0
  40. package/template/blocks/timeline/preview.png +0 -0
  41. package/template/blocks/trust-strip/preview.png +0 -0
  42. package/template/blocks/video-embed/preview.png +0 -0
  43. package/template/blocks/wishlist/preview.png +0 -0
  44. package/template/package.json +1 -1
  45. package/template/public/images/bowl.webp +0 -0
  46. package/template/test/prerenderFailure.spec.ts +4 -3
  47. package/template/test/previewParity.browser.spec.ts +1152 -0
  48. package/template/test/starter.spec.ts +6 -1
  49. package/template/test/support/previewParity.ts +302 -0
  50. package/template/test/support/previewParityContent.ts +726 -0
@@ -35,7 +35,14 @@ interface SeedTarget {
35
35
  slug?: string;
36
36
  id?: string;
37
37
  }
38
+ interface SeedSection {
39
+ heading?: string;
40
+ links?: SeedLink[];
41
+ seeAll?: SeedLink;
42
+ headingLink?: SeedLink;
43
+ }
38
44
  interface SeedLink {
45
+ sections?: SeedSection[];
39
46
  kind: string;
40
47
  target?: SeedTarget;
41
48
  url?: string;
@@ -53,16 +60,22 @@ function resolveTargets<T extends Record<string, unknown>>(
53
60
  const targets = new Map<string, unknown>();
54
61
  const rewrite = (link: SeedLink): SeedLink => {
55
62
  const slug = link.target?.slug;
56
- if (link.target === undefined || slug === undefined) {
57
- return { ...link, ...(link.children ? { children: link.children.map(rewrite) } : {}) };
58
- }
59
- const id = `id-${slug}`;
60
- targets.set(`${link.target._type}:${id}`, { slug, title: link.label });
61
- return {
62
- ...link,
63
- target: { _type: link.target._type, id },
63
+ const nested = {
64
64
  ...(link.children ? { children: link.children.map(rewrite) } : {}),
65
+ ...(link.sections
66
+ ? {
67
+ sections: link.sections.map((section) => ({
68
+ ...section,
69
+ ...(section.links ? { links: section.links.map(rewrite) } : {}),
70
+ ...(section.seeAll ? { seeAll: rewrite(section.seeAll) } : {}),
71
+ })),
72
+ }
73
+ : {}),
65
74
  };
75
+ if (link.target === undefined || slug === undefined) return { ...link, ...nested };
76
+ const id = `id-${slug}`;
77
+ targets.set(`${link.target._type}:${id}`, { slug, title: link.label });
78
+ return { ...link, target: { _type: link.target._type, id }, ...nested };
66
79
  };
67
80
  const next = { ...data } as Record<string, unknown>;
68
81
  if (Array.isArray(next.links)) next.links = (next.links as SeedLink[]).map(rewrite);
@@ -277,6 +290,76 @@ describe('header block (navigation apiId)', () => {
277
290
  wrapper.unmount();
278
291
  });
279
292
 
293
+ it('draws a menu card with its picture at the declared aspect, its title and its price, axe-clean', async () => {
294
+ const targets = new Map(resolved.links.targets);
295
+ targets.set('product:p-1', {
296
+ slug: 'ash-mug',
297
+ title: 'Ash glaze mug',
298
+ image: 'https://media.test/mug-md.jpg',
299
+ price: 28,
300
+ });
301
+ targets.set('collection:c-1', {
302
+ slug: 'winter-knits',
303
+ title: 'Winter knits',
304
+ image: 'https://media.test/winter-md.jpg',
305
+ });
306
+ const wrapper = mount(Block, {
307
+ ...mountOptions(
308
+ {
309
+ entry: {
310
+ id: 'e1',
311
+ data: {
312
+ ...resolved.data,
313
+ links: [
314
+ {
315
+ kind: 'none',
316
+ label: 'Shop',
317
+ sections: [
318
+ {
319
+ heading: 'Featured',
320
+ display: 'card',
321
+ links: [
322
+ { kind: 'product', target: { _type: 'product', id: 'p-1' } },
323
+ { kind: 'collection', target: { _type: 'collection', id: 'c-1' } },
324
+ ],
325
+ },
326
+ {
327
+ heading: 'Care',
328
+ links: [{ kind: 'url', url: '/care', label: 'Care guides' }],
329
+ },
330
+ ],
331
+ },
332
+ ],
333
+ },
334
+ },
335
+ },
336
+ { links: { ...resolved.links, targets } }
337
+ ),
338
+ attachTo: document.body,
339
+ });
340
+ const trigger = wrapper.findAll('button').find((b) => b.text().includes('Shop'))!;
341
+ await trigger.trigger('click');
342
+ const panel = wrapper.get(`#${trigger.attributes('aria-controls')}`);
343
+ const cards = panel.findAll('[data-part="card"]');
344
+ expect(cards).toHaveLength(2);
345
+ const image = cards[0]!.get('img');
346
+ expect(image.attributes('src')).toBe('https://media.test/mug-md.jpg');
347
+ expect((image.element as HTMLImageElement).style.aspectRatio).toBe('4 / 3');
348
+ expect(cards[0]!.get('[data-part="cardTitle"]').text()).toBe('Ash glaze mug');
349
+ expect(cards[0]!.get('[data-part="cardPrice"]').text()).toMatch(/28/);
350
+ expect(cards[1]!.get('img').attributes('src')).toBe('https://media.test/winter-md.jpg');
351
+ expect(cards[1]!.find('[data-part="cardPrice"]').exists()).toBe(false);
352
+ // The cards column is the wide one; the link column is one track.
353
+ const columns = panel.findAll('[data-part="group"]');
354
+ expect(columns[0]!.attributes('data-cards')).toBeDefined();
355
+ expect(columns[0]!.classes()).toContain('[[data-cards]>&[data-cards]]:col-span-2');
356
+ expect(columns[1]!.attributes('data-cards')).toBeUndefined();
357
+ // A plain link beside the cards is still a link.
358
+ expect(panel.findAll('a').some((a) => a.text() === 'Care guides')).toBe(true);
359
+ expect(await axe(wrapper.element)).toHaveNoViolations();
360
+ wrapper.unmount();
361
+ });
362
+
280
363
  it('renders a heading-only mega-menu parent as a disclosure with no destination', async () => {
281
364
  // `kind: "none"`: the trigger has a label and children and goes nowhere,
282
365
  // which is what a mega-menu parent without its own page is.
@@ -4,7 +4,7 @@
4
4
  "description": "The store's top bar: brand, primary links with optional mega-menus, search, cart and one call to action.",
5
5
  "icon": "layout-navbar",
6
6
  "category": "structure",
7
- "version": 4,
7
+ "version": 5,
8
8
  "groups": [
9
9
  {
10
10
  "groupId": "brand",
@@ -55,6 +55,10 @@
55
55
  "label": "ctaLabel"
56
56
  }
57
57
  ]
58
+ },
59
+ {
60
+ "version": 5,
61
+ "groupsToSections": [{ "field": "links" }]
58
62
  }
59
63
  ],
60
64
  "fields": [
@@ -99,7 +103,7 @@
99
103
  "name": "Links",
100
104
  "type": "list",
101
105
  "groupId": "navigation",
102
- "helpText": "Primary links. 3 to 6 recommended; more than 6 may overflow at 64–80rem. Give a link children to turn it into a mega-menu: consecutive children sharing the same Group form one column, in order — up to 4 groups × 8 links.",
106
+ "helpText": "Primary links. 3 to 6 recommended; more than 6 may overflow at 64–80rem. Give a link a panel to turn it into a mega-menu: up to 4 columns, each with a heading, its links and a See all link. A column can hold up to 2 product or collection cards, a picture with a title and a price.",
103
107
  "metadata": {
104
108
  "item": {
105
109
  "fieldId": "link",
@@ -107,7 +111,11 @@
107
111
  "type": "link",
108
112
  "localized": true,
109
113
  "metadata": {
110
- "tree": true,
114
+ "tree": {
115
+ "depth": 2,
116
+ "sections": { "max": 4, "headingLink": true, "seeAll": true },
117
+ "cards": { "kinds": ["product", "collection"], "max": 2, "aspect": "4:3" }
118
+ },
111
119
  "kinds": ["product", "collection", "category", "page", "entry", "url", "none"]
112
120
  }
113
121
  }
@@ -9,114 +9,117 @@
9
9
  "slug": "knitwear"
10
10
  },
11
11
  "label": "Knitwear",
12
- "children": [
12
+ "sections": [
13
13
  {
14
- "kind": "collection",
15
- "target": {
16
- "_type": "collection",
17
- "slug": "womens-sweaters"
18
- },
19
- "group": "Women",
20
- "label": "Sweaters"
14
+ "heading": "Women",
15
+ "links": [
16
+ {
17
+ "kind": "collection",
18
+ "target": {
19
+ "_type": "collection",
20
+ "slug": "womens-sweaters"
21
+ },
22
+ "label": "Sweaters"
23
+ },
24
+ {
25
+ "kind": "collection",
26
+ "target": {
27
+ "_type": "collection",
28
+ "slug": "womens-cardigans"
29
+ },
30
+ "label": "Cardigans"
31
+ },
32
+ {
33
+ "kind": "collection",
34
+ "target": {
35
+ "_type": "collection",
36
+ "slug": "scarves-wraps"
37
+ },
38
+ "label": "Scarves & wraps"
39
+ },
40
+ {
41
+ "kind": "collection",
42
+ "target": {
43
+ "_type": "collection",
44
+ "slug": "hats-gloves"
45
+ },
46
+ "label": "Hats & gloves"
47
+ }
48
+ ]
21
49
  },
22
50
  {
23
- "kind": "collection",
24
- "target": {
25
- "_type": "collection",
26
- "slug": "womens-cardigans"
27
- },
28
- "group": "Women",
29
- "label": "Cardigans"
51
+ "heading": "Men",
52
+ "links": [
53
+ {
54
+ "kind": "collection",
55
+ "target": {
56
+ "_type": "collection",
57
+ "slug": "mens-sweaters"
58
+ },
59
+ "label": "Sweaters"
60
+ },
61
+ {
62
+ "kind": "collection",
63
+ "target": {
64
+ "_type": "collection",
65
+ "slug": "mens-cardigans"
66
+ },
67
+ "label": "Cardigans"
68
+ },
69
+ {
70
+ "kind": "collection",
71
+ "target": {
72
+ "_type": "collection",
73
+ "slug": "mens-scarves"
74
+ },
75
+ "label": "Scarves"
76
+ },
77
+ {
78
+ "kind": "collection",
79
+ "target": {
80
+ "_type": "collection",
81
+ "slug": "socks"
82
+ },
83
+ "label": "Socks"
84
+ }
85
+ ]
30
86
  },
31
87
  {
32
- "kind": "collection",
33
- "target": {
34
- "_type": "collection",
35
- "slug": "scarves-wraps"
36
- },
37
- "group": "Women",
38
- "label": "Scarves & wraps"
39
- },
40
- {
41
- "kind": "collection",
42
- "target": {
43
- "_type": "collection",
44
- "slug": "hats-gloves"
45
- },
46
- "group": "Women",
47
- "label": "Hats & gloves"
48
- },
49
- {
50
- "kind": "collection",
51
- "target": {
52
- "_type": "collection",
53
- "slug": "mens-sweaters"
54
- },
55
- "group": "Men",
56
- "label": "Sweaters"
57
- },
58
- {
59
- "kind": "collection",
60
- "target": {
61
- "_type": "collection",
62
- "slug": "mens-cardigans"
63
- },
64
- "group": "Men",
65
- "label": "Cardigans"
66
- },
67
- {
68
- "kind": "collection",
69
- "target": {
70
- "_type": "collection",
71
- "slug": "mens-scarves"
72
- },
73
- "group": "Men",
74
- "label": "Scarves"
75
- },
76
- {
77
- "kind": "collection",
78
- "target": {
79
- "_type": "collection",
80
- "slug": "socks"
81
- },
82
- "group": "Men",
83
- "label": "Socks"
84
- },
85
- {
86
- "kind": "collection",
87
- "target": {
88
- "_type": "collection",
89
- "slug": "merino-essentials"
90
- },
91
- "group": "Collections",
92
- "label": "Merino essentials"
93
- },
94
- {
95
- "kind": "collection",
96
- "target": {
97
- "_type": "collection",
98
- "slug": "heavy-winter-knits"
99
- },
100
- "group": "Collections",
101
- "label": "Heavy winter knits"
102
- },
103
- {
104
- "kind": "collection",
105
- "target": {
106
- "_type": "collection",
107
- "slug": "undyed-wool"
108
- },
109
- "group": "Collections",
110
- "label": "Undyed wool"
111
- },
112
- {
113
- "kind": "collection",
114
- "target": {
115
- "_type": "collection",
116
- "slug": "knitwear"
117
- },
118
- "group": "Collections",
119
- "label": "Shop all knitwear"
88
+ "heading": "Collections",
89
+ "links": [
90
+ {
91
+ "kind": "collection",
92
+ "target": {
93
+ "_type": "collection",
94
+ "slug": "merino-essentials"
95
+ },
96
+ "label": "Merino essentials"
97
+ },
98
+ {
99
+ "kind": "collection",
100
+ "target": {
101
+ "_type": "collection",
102
+ "slug": "heavy-winter-knits"
103
+ },
104
+ "label": "Heavy winter knits"
105
+ },
106
+ {
107
+ "kind": "collection",
108
+ "target": {
109
+ "_type": "collection",
110
+ "slug": "undyed-wool"
111
+ },
112
+ "label": "Undyed wool"
113
+ },
114
+ {
115
+ "kind": "collection",
116
+ "target": {
117
+ "_type": "collection",
118
+ "slug": "knitwear"
119
+ },
120
+ "label": "Shop all knitwear"
121
+ }
122
+ ]
120
123
  }
121
124
  ]
122
125
  },
@@ -127,33 +130,35 @@
127
130
  "slug": "ceramics"
128
131
  },
129
132
  "label": "Ceramics",
130
- "children": [
131
- {
132
- "kind": "collection",
133
- "target": {
134
- "_type": "collection",
135
- "slug": "plates"
136
- },
137
- "group": "Tableware",
138
- "label": "Plates"
139
- },
140
- {
141
- "kind": "collection",
142
- "target": {
143
- "_type": "collection",
144
- "slug": "bowls"
145
- },
146
- "group": "Tableware",
147
- "label": "Bowls"
148
- },
133
+ "sections": [
149
134
  {
150
- "kind": "collection",
151
- "target": {
152
- "_type": "collection",
153
- "slug": "mugs-cups"
154
- },
155
- "group": "Tableware",
156
- "label": "Mugs & cups"
135
+ "heading": "Tableware",
136
+ "links": [
137
+ {
138
+ "kind": "collection",
139
+ "target": {
140
+ "_type": "collection",
141
+ "slug": "plates"
142
+ },
143
+ "label": "Plates"
144
+ },
145
+ {
146
+ "kind": "collection",
147
+ "target": {
148
+ "_type": "collection",
149
+ "slug": "bowls"
150
+ },
151
+ "label": "Bowls"
152
+ },
153
+ {
154
+ "kind": "collection",
155
+ "target": {
156
+ "_type": "collection",
157
+ "slug": "mugs-cups"
158
+ },
159
+ "label": "Mugs & cups"
160
+ }
161
+ ]
157
162
  }
158
163
  ]
159
164
  },
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -22,7 +22,7 @@
22
22
  "@eldrajs/theme-vue": "workspace:*",
23
23
  "@eldrajs/ui": "workspace:*",
24
24
  "@tabler/icons": "^3.34.0",
25
- "nuxt": "^4.0.0",
25
+ "nuxt": "^4.7.0",
26
26
  "tailwind-merge": "^3.0.0",
27
27
  "vue-i18n": "11.4.16"
28
28
  },
Binary file
@@ -111,10 +111,11 @@ describe('a prerendered route whose resolution failed', () => {
111
111
  it('fails the build over it, rather than exiting 0 with the page missing', () => {
112
112
  // `nitro.prerender.failOnError` (`nuxt.config.ts`) is the half that makes the *absence* loud:
113
113
  // without it the generate still exits 0 and an artifact with a hole in its catalogue is
114
- // deployable. The route itself is named in the prerender list Nitro prints, which is on the
115
- // build's console rather than in what `nuxi generate` hands back here.
114
+ // deployable. Nitro 2.14 (Nuxt 4.7) names each failed route in the output, with its status.
116
115
  expect(generated.exitCode).not.toBe(0);
117
- expect(`${generated.stdout}\n${generated.stderr}`).toContain('prerender errors');
116
+ const printed = `${generated.stdout}\n${generated.stderr}`;
117
+ expect(printed).toMatch(/Failed to prerender \d+ routes?/);
118
+ expect(printed).toContain('/collections/the-winter-edit (500 Eldra route resolution failed)');
118
119
  });
119
120
 
120
121
  it('still writes every route the gateway could answer', () => {