@eldrajs/theme-cli 0.2.9 → 0.2.11
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 +12 -1
- package/package.json +3 -3
- package/template/.eldra/block-types.d.ts +4 -6
- package/template/.eldra/manifest.json +228 -246
- package/template/.eldra/previews.json +35 -35
- package/template/.storybook/eldra.ts +7 -2
- package/template/app/assets/main.css +5 -0
- package/template/app/composables/useBlockData.ts +9 -2
- package/template/app/composables/usePriceTokens.ts +150 -0
- package/template/app/composables/useQuickAdd.ts +95 -0
- package/template/app/composables/useRegionalFormat.ts +94 -0
- package/template/app/icons.ts +4 -0
- package/template/app/plugins/eldra-storefront.ts +2 -0
- package/template/app/plugins/eldra-ui-messages.ts +22 -8
- package/template/app/storefront/demo.ts +188 -16
- package/template/app/storefront/gateway.ts +19 -0
- package/template/app/storefront/productCardLook.ts +76 -0
- package/template/app/storefront/productReference.ts +17 -0
- package/template/app/storefront/toProductCard.ts +12 -8
- package/template/app/storefront/types.ts +17 -0
- package/template/blocks/announcement-bar/__tests__/Block.spec.ts +19 -7
- package/template/blocks/announcement-bar/block.json +2 -1
- package/template/blocks/announcement-bar/mock.json +1 -1
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/Block.vue +8 -18
- package/template/blocks/article/block.json +3 -1
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/block.json +10 -1
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/Block.vue +15 -3
- package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +13 -0
- package/template/blocks/breadcrumbs/block.json +1 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/Block.vue +15 -5
- package/template/blocks/cart/__tests__/Block.spec.ts +53 -10
- package/template/blocks/cart/__tests__/ShippingBar.spec.ts +10 -8
- package/template/blocks/cart/block.json +8 -5
- package/template/blocks/cart/mock.json +2 -2
- package/template/blocks/cart/parts/ShippingBar.vue +24 -30
- package/template/blocks/cart/parts/notSold.ts +4 -3
- package/template/blocks/collection-grid/Block.vue +168 -85
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +101 -23
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +51 -17
- package/template/blocks/collection-header/__tests__/Block.spec.ts +80 -4
- package/template/blocks/collection-header/block.json +2 -0
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/block.json +4 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/block.json +2 -0
- package/template/blocks/faq/Block.vue +5 -10
- package/template/blocks/faq/block.json +2 -1
- package/template/blocks/faq/mock.json +12 -1
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +30 -7
- package/template/blocks/feature-grid/block.json +3 -2
- package/template/blocks/feature-grid/mock.json +1 -1
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +64 -21
- package/template/blocks/footer/__tests__/Block.spec.ts +97 -1
- package/template/blocks/footer/block.json +5 -2
- package/template/blocks/footer/mock.json +1 -1
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/block.json +1 -0
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +38 -9
- package/template/blocks/hero/__tests__/Block.spec.ts +71 -19
- package/template/blocks/hero/block.json +16 -22
- package/template/blocks/hero/preview.json +1 -3
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/block.json +2 -1
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/block.json +1 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +405 -159
- package/template/blocks/navigation/__tests__/Block.spec.ts +816 -172
- package/template/blocks/navigation/__tests__/currentItem.spec.ts +90 -0
- package/template/blocks/navigation/block.json +2 -11
- package/template/blocks/navigation/mock.json +3 -3
- package/template/blocks/navigation/parts/LocalePicker.vue +103 -0
- package/template/blocks/navigation/parts/currentItem.ts +82 -0
- package/template/blocks/navigation/preview.json +7 -1
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/Block.vue +6 -2
- package/template/blocks/newsletter/block.json +2 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/Block.vue +8 -17
- package/template/blocks/order-status/block.json +3 -0
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/__tests__/Block.spec.ts +12 -4
- package/template/blocks/pricing-table/block.json +2 -0
- package/template/blocks/pricing-table/mock.json +6 -6
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +36 -126
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +88 -0
- package/template/blocks/product-carousel/block.json +1 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +84 -31
- package/template/blocks/product-detail/__tests__/Block.spec.ts +86 -0
- package/template/blocks/product-detail/__tests__/specs.spec.ts +79 -0
- package/template/blocks/product-detail/block.json +3 -1
- package/template/blocks/product-detail/mock.json +54 -4
- package/template/blocks/product-detail/parts/Gallery.vue +8 -2
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/product-detail/specs.ts +75 -0
- package/template/blocks/quote/block.json +1 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +6 -1
- package/template/blocks/search/TypeSection.vue +8 -1
- package/template/blocks/search/__tests__/Block.spec.ts +24 -1
- package/template/blocks/search/block.json +1 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/split-content/Block.vue +12 -5
- package/template/blocks/split-content/__tests__/Block.spec.ts +13 -0
- package/template/blocks/split-content/block.json +4 -2
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/Block.vue +3 -4
- package/template/blocks/tabs/block.json +1 -1
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/block.json +3 -1
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/block.json +2 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/block.json +2 -1
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +2 -2
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +38 -9
- package/template/blocks/trust-strip/block.json +1 -1
- package/template/blocks/trust-strip/mock.json +1 -1
- package/template/blocks/trust-strip/preview.json +1 -1
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/block.json +2 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/Block.vue +2 -2
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +13 -5
- package/template/i18n/is-IS.json +12 -4
- package/template/pages/article.page.json +1 -3
- package/template/pages/cart.page.json +1 -3
- package/template/pages/category.page.json +2 -4
- package/template/pages/collection.page.json +1 -3
- package/template/pages/home.page.json +7 -18
- package/template/pages/product.page.json +62 -131
- package/template/pages/products.page.json +1 -3
- package/template/pages/search.page.json +1 -3
- package/template/pages/wishlist.page.json +1 -3
- package/template/stories/generated/footer.stories.ts +6 -0
- package/template/stories/generated/navigation.stories.ts +0 -18
- package/template/test/inlineEditable.spec.ts +10 -2
- package/template/test/localePrefix.spec.ts +2 -19
- package/template/test/pages/article.spec.ts +0 -2
- package/template/test/pages/category.spec.ts +35 -13
- package/template/test/pages/home.spec.ts +33 -17
- package/template/test/pages/product.spec.ts +64 -44
- package/template/test/pages/ssr.spec.ts +3 -1
- package/template/test/prerenderRefresh.browser.spec.ts +30 -25
- package/template/test/previewParity.browser.spec.ts +36 -2
- package/template/test/priceTokens.spec.ts +309 -0
- package/template/test/regionalFormat.spec.ts +80 -0
- package/template/test/starter.spec.ts +23 -7
- package/template/test/storefront/demo.spec.ts +19 -18
- package/template/test/storefront/toProductCard.spec.ts +17 -2
- package/template/test/structuredData.generate.spec.ts +4 -2
- package/template/test/support/mockGateway.ts +21 -1
- package/template/test/support/mountBlock.ts +25 -4
- package/template/test/support/priceTokens.ts +20 -0
- package/template/test/uiMessagesPlugin.spec.ts +34 -1
- package/template/tokens.json +8 -8
|
@@ -103,9 +103,9 @@ interface Stub {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
* A storefront whose catalogue actually answers the request: the
|
|
106
|
+
* A storefront whose catalogue actually answers the request: the sixteen Northwind products when
|
|
107
107
|
* nothing is filtered, and nothing at all as soon as any filter is applied. That is what makes
|
|
108
|
-
* "the count reads
|
|
108
|
+
* "the count reads 16 products, then 0 products", "the empty state names the active filters" and
|
|
109
109
|
* "the drawer changes nothing until Show N products" real assertions rather than restatements of a
|
|
110
110
|
* fixture — the demo source (`app/storefront/demo.ts`) ignores `filters` by design.
|
|
111
111
|
*/
|
|
@@ -375,6 +375,25 @@ describe('collection-grid block', () => {
|
|
|
375
375
|
});
|
|
376
376
|
});
|
|
377
377
|
|
|
378
|
+
describe('"+ Add" on a card', () => {
|
|
379
|
+
it('reads the product and puts one of its variant in the cart', async () => {
|
|
380
|
+
const source = createDemoStorefront();
|
|
381
|
+
const add = vi.spyOn(source.cart, 'add');
|
|
382
|
+
const wrapper = mountGrid(mock, { source });
|
|
383
|
+
await flushPromises();
|
|
384
|
+
const first = wrapper.findAllComponents(ProductCard)[0]!;
|
|
385
|
+
const button = first.get('button[data-part="quickAdd"]');
|
|
386
|
+
const title = (first.props('product') as { title: string }).title;
|
|
387
|
+
expect(button.attributes('aria-label')).toContain(title);
|
|
388
|
+
await button.trigger('click');
|
|
389
|
+
await flushPromises();
|
|
390
|
+
expect(add).toHaveBeenCalledTimes(1);
|
|
391
|
+
expect(add.mock.calls[0]![0].quantity).toBe(1);
|
|
392
|
+
expect(add.mock.calls[0]![0].variantId).not.toBe('');
|
|
393
|
+
expect(source.cart.lines.value.length).toBe(1);
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
|
|
378
397
|
describe('structure', () => {
|
|
379
398
|
it('names the section with the collection and puts the grid under a hidden h2 with h3 titles', async () => {
|
|
380
399
|
const wrapper = mountGrid(mock);
|
|
@@ -402,6 +421,44 @@ describe('collection-grid block', () => {
|
|
|
402
421
|
expect(aside.classes().join(' ')).toContain('var(--eldra-header-height,0px)');
|
|
403
422
|
});
|
|
404
423
|
|
|
424
|
+
/**
|
|
425
|
+
* WS-1277: the sticky rail was as tall as its groups, so on a viewport shorter than the panel the
|
|
426
|
+
* lower groups were unreachable until the grid beside it had scrolled away. It is capped at the
|
|
427
|
+
* viewport less its offsets and scrolls itself.
|
|
428
|
+
*/
|
|
429
|
+
/**
|
|
430
|
+
* WS-1277: a card's "+ Add" and badges are `z-10`, the same as the sticky filter bar, and come
|
|
431
|
+
* later in the page, so they drew over the bar as the grid scrolled under it. The grid is its
|
|
432
|
+
* own stacking context, which keeps everything a card lifts below the bar.
|
|
433
|
+
*/
|
|
434
|
+
/** WS-1277: two cards side by side on a phone under 372px wide are too narrow to read. */
|
|
435
|
+
it('shows one column below 23.25rem (372px) and two from there', async () => {
|
|
436
|
+
const wrapper = mountGrid(mock);
|
|
437
|
+
await flushPromises();
|
|
438
|
+
const list = wrapper.findAll('ul[role="list"]').find((ul) => ul.find('li h3').exists())!;
|
|
439
|
+
expect(list.classes()).toContain('grid-cols-1');
|
|
440
|
+
expect(list.classes()).toContain('@min-[23.25rem]:grid-cols-2');
|
|
441
|
+
expect(list.classes()).not.toContain('grid-cols-2');
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
it('keeps what a card lifts inside the grid, below the sticky filter bar', async () => {
|
|
445
|
+
const wrapper = mountGrid(mock);
|
|
446
|
+
await flushPromises();
|
|
447
|
+
const list = wrapper.findAll('ul[role="list"]').find((ul) => ul.find('li h3').exists())!;
|
|
448
|
+
expect(list.classes()).toContain('isolate');
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
it('caps the sticky rail at the viewport under the header and lets it scroll its own groups', async () => {
|
|
452
|
+
const wrapper = mountGrid(mock);
|
|
453
|
+
await wrapper.vm.$nextTick();
|
|
454
|
+
const classes = wrapper.get('aside').classes();
|
|
455
|
+
expect(classes).toContain(
|
|
456
|
+
'@content:max-h-[calc(100dvh_-_3rem_-_var(--eldra-header-height,0px))]'
|
|
457
|
+
);
|
|
458
|
+
expect(classes).toContain('@content:overflow-y-auto');
|
|
459
|
+
expect(classes).toContain('@content:overscroll-contain');
|
|
460
|
+
});
|
|
461
|
+
|
|
405
462
|
/**
|
|
406
463
|
* `mock.json` ships four rows for five groups: `options` is one row standing for every variant
|
|
407
464
|
* option the store has, which in the demo catalogue is Size and Colour.
|
|
@@ -539,12 +596,12 @@ describe('collection-grid block', () => {
|
|
|
539
596
|
});
|
|
540
597
|
|
|
541
598
|
describe('the result count', () => {
|
|
542
|
-
it('is a polite status that reads "
|
|
599
|
+
it('is a polite status that reads "16 products" and "0 products" after a filter change', async () => {
|
|
543
600
|
useFilterTimers();
|
|
544
601
|
const stub = createStub();
|
|
545
602
|
const wrapper = mountGrid(mock, { source: stub.source });
|
|
546
603
|
await wrapper.vm.$nextTick();
|
|
547
|
-
expect(countLine(wrapper).text()).toBe('
|
|
604
|
+
expect(countLine(wrapper).text()).toBe('16 products');
|
|
548
605
|
|
|
549
606
|
const { panel } = panelFor(wrapper, enUS.grid.legendCategory);
|
|
550
607
|
await panel.get('input[type="checkbox"]').setValue(true);
|
|
@@ -646,7 +703,7 @@ describe('collection-grid block', () => {
|
|
|
646
703
|
const html = await renderBlockHtml(Block, entry, {
|
|
647
704
|
[STOREFRONT_KEY]: createStub().source,
|
|
648
705
|
});
|
|
649
|
-
expect(html).toContain('data-part="
|
|
706
|
+
expect(html).toContain('data-part="swatches"'); // the cards really are in the server's markup
|
|
650
707
|
expect(html).not.toContain('animate-eldra-pulse-soft');
|
|
651
708
|
expect(html).not.toContain(enUS.grid.updating);
|
|
652
709
|
|
|
@@ -948,7 +1005,7 @@ describe('collection-grid block', () => {
|
|
|
948
1005
|
|
|
949
1006
|
expect(countReads()).toBe(before + 1);
|
|
950
1007
|
// And the page itself is untouched until "Show N products" is pressed.
|
|
951
|
-
expect(countLine(wrapper).text()).toBe('
|
|
1008
|
+
expect(countLine(wrapper).text()).toBe('16 products');
|
|
952
1009
|
});
|
|
953
1010
|
});
|
|
954
1011
|
|
|
@@ -1223,7 +1280,7 @@ describe('collection-grid block', () => {
|
|
|
1223
1280
|
await wrapper.vm.$nextTick();
|
|
1224
1281
|
|
|
1225
1282
|
expect(cards(wrapper).length).toBeGreaterThan(0);
|
|
1226
|
-
expect(countLine(wrapper).text()).toBe('
|
|
1283
|
+
expect(countLine(wrapper).text()).toBe('16 products');
|
|
1227
1284
|
});
|
|
1228
1285
|
});
|
|
1229
1286
|
|
|
@@ -1363,7 +1420,7 @@ describe('collection-grid block', () => {
|
|
|
1363
1420
|
const stub = createStub();
|
|
1364
1421
|
const wrapper = mountGrid(mock, { source: stub.source, attachTo: document.body });
|
|
1365
1422
|
await wrapper.vm.$nextTick();
|
|
1366
|
-
expect(cards(wrapper)).toHaveLength(
|
|
1423
|
+
expect(cards(wrapper)).toHaveLength(16);
|
|
1367
1424
|
|
|
1368
1425
|
await filterButton(wrapper).trigger('click');
|
|
1369
1426
|
const dialog = wrapper.get('dialog');
|
|
@@ -1375,8 +1432,8 @@ describe('collection-grid block', () => {
|
|
|
1375
1432
|
// Nothing on the page has moved: same cards, same count, and the sidebar's own (applied)
|
|
1376
1433
|
// panel shows no chip — the drawer's own pending copy shows the tick it is still holding,
|
|
1377
1434
|
// which is exactly the "changes nothing until applied" contract for the page, not the drawer.
|
|
1378
|
-
expect(cards(wrapper)).toHaveLength(
|
|
1379
|
-
expect(countLine(wrapper).text()).toBe('
|
|
1435
|
+
expect(cards(wrapper)).toHaveLength(16);
|
|
1436
|
+
expect(countLine(wrapper).text()).toBe('16 products');
|
|
1380
1437
|
expect(
|
|
1381
1438
|
wrapper.get('aside').find(`ul[aria-label="${enUS.grid.activeFilters}"]`).exists()
|
|
1382
1439
|
).toBe(false);
|
|
@@ -1466,9 +1523,9 @@ describe('collection-grid block', () => {
|
|
|
1466
1523
|
it('puts the panel’s own Clear all and chips before its group triggers, then the toolbar, then the cards', async () => {
|
|
1467
1524
|
const wrapper = mountGrid(mock, { attachTo: document.body });
|
|
1468
1525
|
await wrapper.vm.$nextTick();
|
|
1469
|
-
// Availability → In stock, not Size → M: the demo source honours `filters` now, and
|
|
1526
|
+
// Availability → In stock, not Size → M: the demo source honours `filters` now, and 42 of the
|
|
1470
1527
|
// 48 demo items are in stock, so this leaves more than one page and keeps a real Load more
|
|
1471
|
-
// button in the tab order (Size → M leaves
|
|
1528
|
+
// button in the tab order (Size → M leaves 9, i.e. everything already shown).
|
|
1472
1529
|
const availability = panelFor(wrapper, enUS.grid.legendAvailability).panel;
|
|
1473
1530
|
await availability.get('[role="switch"]').trigger('click');
|
|
1474
1531
|
await flushPromises();
|
|
@@ -1779,13 +1836,13 @@ describe('collection-grid block', () => {
|
|
|
1779
1836
|
// A package string the block never writes itself: `LoadMore`'s own "Showing N of M" line.
|
|
1780
1837
|
const loadMoreLine = () => wrapper.get('[data-part="status"]').text();
|
|
1781
1838
|
|
|
1782
|
-
//
|
|
1783
|
-
// appearing
|
|
1839
|
+
// 9 of the demo collection's 48 items are made in size M (the three apparel products, each
|
|
1840
|
+
// appearing three times — `app/storefront/demo.ts`), and the demo source honours `filters`
|
|
1784
1841
|
// now, so both the package's "Showing N of M" line and the block's own count read the
|
|
1785
1842
|
// *filtered* set. Before that, ticking a filter left these at 24 of 48 / 48 products.
|
|
1786
1843
|
expect(removeLabel()).toBe('Remove filter Size: M');
|
|
1787
|
-
expect(loadMoreLine()).toContain('Showing
|
|
1788
|
-
expect(countLine(wrapper).text()).toBe('
|
|
1844
|
+
expect(loadMoreLine()).toContain('Showing 9 of 9');
|
|
1845
|
+
expect(countLine(wrapper).text()).toBe('9 products');
|
|
1789
1846
|
|
|
1790
1847
|
context.preview.locale = 'is-IS';
|
|
1791
1848
|
await wrapper.vm.$nextTick();
|
|
@@ -1797,8 +1854,8 @@ describe('collection-grid block', () => {
|
|
|
1797
1854
|
// into an explicit `option:size` row gets that label in both locales, since a string a
|
|
1798
1855
|
// merchant wrote is not the theme's to translate.)
|
|
1799
1856
|
expect(removeLabel()).toBe(`Fjarlægja síu ${isIS.grid.legendSize}: M`);
|
|
1800
|
-
expect(loadMoreLine()).toContain('
|
|
1801
|
-
expect(countLine(wrapper).text()).toBe(isIS.grid.nProducts.replace('{count}', '
|
|
1857
|
+
expect(loadMoreLine()).toContain('9 af 9');
|
|
1858
|
+
expect(countLine(wrapper).text()).toBe(isIS.grid.nProducts.replace('{count}', '9'));
|
|
1802
1859
|
});
|
|
1803
1860
|
});
|
|
1804
1861
|
|
|
@@ -1952,7 +2009,7 @@ describe('collection-grid block', () => {
|
|
|
1952
2009
|
|
|
1953
2010
|
expect(wrapper.find(`ul[aria-label="${enUS.grid.activeFilters}"]`).exists()).toBe(false);
|
|
1954
2011
|
expect(filterButton(wrapper).find('[data-part="hiddenSuffix"]').exists()).toBe(false);
|
|
1955
|
-
// Still sent — this stub answers a filtered request with four of the
|
|
2012
|
+
// Still sent — this stub answers a filtered request with four of the sixteen — because the
|
|
1956
2013
|
// storefront that declared the source unfilterable is the one already ignoring it, and the
|
|
1957
2014
|
// key is meaningful in a scope that can honour it.
|
|
1958
2015
|
expect(cards(wrapper)).toHaveLength(4);
|
|
@@ -2404,7 +2461,7 @@ describe('collection-grid block', () => {
|
|
|
2404
2461
|
await wrapper.vm.$nextTick();
|
|
2405
2462
|
|
|
2406
2463
|
expect(wrapper.find(`ul[aria-label="${enUS.grid.activeFilters}"]`).exists()).toBe(false);
|
|
2407
|
-
expect(countLine(wrapper).text()).toBe('
|
|
2464
|
+
expect(countLine(wrapper).text()).toBe('16 products');
|
|
2408
2465
|
expect(stub.requests.at(-1)?.filters).toBeUndefined();
|
|
2409
2466
|
});
|
|
2410
2467
|
|
|
@@ -2426,7 +2483,7 @@ describe('collection-grid block', () => {
|
|
|
2426
2483
|
await wrapper.vm.$nextTick();
|
|
2427
2484
|
|
|
2428
2485
|
expect(wrapper.find(`ul[aria-label="${enUS.grid.activeFilters}"]`).exists()).toBe(false);
|
|
2429
|
-
expect(countLine(wrapper).text()).toBe('
|
|
2486
|
+
expect(countLine(wrapper).text()).toBe('16 products');
|
|
2430
2487
|
// Clear all moves focus to the panel's own title (see "focuses the panel's own title" above).
|
|
2431
2488
|
expect(document.activeElement).toBe(wrapper.get('aside [data-part="title"]').element);
|
|
2432
2489
|
});
|
|
@@ -2993,7 +3050,9 @@ describe('collection-grid block', () => {
|
|
|
2993
3050
|
expect(chips).not.toContain('$50');
|
|
2994
3051
|
|
|
2995
3052
|
// And the grid itself is filtered — the demo source applies the same pass the gateway does.
|
|
2996
|
-
|
|
3053
|
+
// Knitwear in Oat, in stock, between $50 and $150 is the merino crew sweater ($96) alone,
|
|
3054
|
+
// once per pass of the 48-item collection through the sixteen products: three.
|
|
3055
|
+
expect(countLine(wrapper).text()).toBe('3 products');
|
|
2997
3056
|
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
2998
3057
|
});
|
|
2999
3058
|
});
|
|
@@ -3091,7 +3150,7 @@ describe('collection-grid block', () => {
|
|
|
3091
3150
|
const stub = createStub(PRODUCTS, { filteredCount: 4 });
|
|
3092
3151
|
const wrapper = mountGrid(mock, { source: stub.source });
|
|
3093
3152
|
await wrapper.vm.$nextTick();
|
|
3094
|
-
expect(countLine(wrapper).text()).toBe('
|
|
3153
|
+
expect(countLine(wrapper).text()).toBe('16 products');
|
|
3095
3154
|
expect(stub.requests.at(-1)?.filters).toBeUndefined();
|
|
3096
3155
|
|
|
3097
3156
|
stub.source.route.filters = { price: ['50-150'] };
|
|
@@ -3199,6 +3258,23 @@ describe('collection-grid — the filter-bar variant', () => {
|
|
|
3199
3258
|
document.body.innerHTML = '';
|
|
3200
3259
|
});
|
|
3201
3260
|
|
|
3261
|
+
it('keeps the chips on one scrolling line below 64rem, the sort pinned after them as a chip', () => {
|
|
3262
|
+
const wrapper = mountGrid(barMock);
|
|
3263
|
+
const chips = bar(wrapper).get('[data-eldra-filter-bar-chips]');
|
|
3264
|
+
// One line that scrolls, not a wrapping stack, until 64rem; it wraps from there.
|
|
3265
|
+
expect(chips.classes()).toContain('@max-content:overflow-x-auto');
|
|
3266
|
+
expect(chips.classes()).toContain('@content:flex-wrap');
|
|
3267
|
+
expect(chips.classes()).not.toContain('flex-wrap');
|
|
3268
|
+
// The sort sits outside the scroller, so it never scrolls out of reach.
|
|
3269
|
+
const sort = bar(wrapper).get('[data-eldra-filter-bar-sort]');
|
|
3270
|
+
expect(chips.element.contains(sort.element)).toBe(false);
|
|
3271
|
+
expect(sort.find('[role="combobox"]').exists()).toBe(true);
|
|
3272
|
+
// A chip's pill shape below 64rem, with its label read but not shown there.
|
|
3273
|
+
expect(sort.get('[role="combobox"]').classes()).toContain('@max-content:rounded-full');
|
|
3274
|
+
expect(sort.get('label').classes()).toContain('@max-content:sr-only');
|
|
3275
|
+
wrapper.unmount();
|
|
3276
|
+
});
|
|
3277
|
+
|
|
3202
3278
|
it('draws a chip per group, a pressed chip per on/off value and the sort — no sidebar, no drawer', async () => {
|
|
3203
3279
|
const wrapper = mountGrid(barMock);
|
|
3204
3280
|
await wrapper.vm.$nextTick();
|
|
@@ -3218,6 +3294,8 @@ describe('collection-grid — the filter-bar variant', () => {
|
|
|
3218
3294
|
expect(pressed.attributes('aria-pressed')).toBe('false');
|
|
3219
3295
|
expect(comboboxes(wrapper)).toHaveLength(2); // Sort, and Columns from 64rem
|
|
3220
3296
|
expect(countLine(wrapper).text()).toBe('48 products');
|
|
3297
|
+
// The design's "**48** products": the number alone in a `strong`, the words around it plain.
|
|
3298
|
+
expect(countLine(wrapper).get('strong').text()).toBe('48');
|
|
3221
3299
|
});
|
|
3222
3300
|
|
|
3223
3301
|
it('is axe-clean closed, with a group open, and with filters applied', async () => {
|
|
Binary file
|
|
@@ -32,8 +32,11 @@
|
|
|
32
32
|
* States, "No image"; Acceptance: "With no image and no collection image, the block renders as
|
|
33
33
|
* text-only").
|
|
34
34
|
*
|
|
35
|
-
* The description clamps to 3 lines; **Read more** (`@eldrajs/ui`'s `Button variant="link"`)
|
|
36
|
-
* only when the clamped box actually overflows,
|
|
35
|
+
* The description clamps to 3 lines; **Read more** (`@eldrajs/ui`'s `Button variant="link"`) is
|
|
36
|
+
* *usable* only when the clamped box actually overflows, but its row is **reserved from the first
|
|
37
|
+
* server render** whenever there is a description (it always clamps), as an invisible, inert,
|
|
38
|
+
* `aria-hidden` button, so measuring on mount never shifts the content below (CLS, WS-1451).
|
|
39
|
+
* Overflow is measured on mount (and on resize, while collapsed)
|
|
37
40
|
* by comparing `scrollHeight` to `clientHeight` on the clamped element — the same
|
|
38
41
|
* `typeof ResizeObserver !== 'undefined'` guard `packages/ui`'s own `useCarousel` uses, since jsdom
|
|
39
42
|
* has no `ResizeObserver`. `Esc` — on the button itself, or from inside the expanded text — collapses
|
|
@@ -77,7 +80,7 @@ interface Subcollection {
|
|
|
77
80
|
const props = defineProps<{ entry: EldraBlockEntry<'collection-header'> }>();
|
|
78
81
|
const { data, entryId } = useBlockData(props, 'collection-header');
|
|
79
82
|
const editing = useEditing();
|
|
80
|
-
const { t } = useI18n();
|
|
83
|
+
const { t, locale } = useI18n();
|
|
81
84
|
const storefront = useStorefront();
|
|
82
85
|
|
|
83
86
|
const uid = useUiId();
|
|
@@ -344,15 +347,19 @@ interface ResolvedPill {
|
|
|
344
347
|
* The two are different lists with different meanings — curated collections against levels of the
|
|
345
348
|
* catalogue's own tree — so the category strip is the tree's and the authored list is ignored there
|
|
346
349
|
* rather than merged into it: a merged strip would put a collection chip beside a category chip with
|
|
347
|
-
* nothing to tell them apart.
|
|
348
|
-
* the
|
|
350
|
+
* nothing to tell them apart. The category strip leads with an **All <title>** chip linking to the
|
|
351
|
+
* page itself — the one `current` chip, filled, exactly as the design's "All ceramics" — so the
|
|
352
|
+
* strip reads as a choice between the whole category and one of its parts rather than as a list of
|
|
353
|
+
* elsewheres; every child after it is somewhere else and never current.
|
|
349
354
|
*
|
|
350
355
|
* It renders only when there are children, which is the whole of the rule: a leaf category shows no
|
|
351
|
-
* strip at all rather than an empty row (the `v-if="hasPills"` the
|
|
356
|
+
* strip at all rather than an empty row, and no lone "All" chip either (the `v-if="hasPills"` the
|
|
357
|
+
* authored list already had).
|
|
352
358
|
*/
|
|
353
359
|
const pills = computed<ResolvedPill[]>(() => {
|
|
354
360
|
if (categoryMode.value) {
|
|
355
|
-
|
|
361
|
+
const info = categoryInfo.value;
|
|
362
|
+
const children = (info?.children ?? []).flatMap((child) => {
|
|
356
363
|
const href = safeHref(categoryHref(child.path));
|
|
357
364
|
if (href === null) return [];
|
|
358
365
|
return [
|
|
@@ -364,6 +371,19 @@ const pills = computed<ResolvedPill[]>(() => {
|
|
|
364
371
|
},
|
|
365
372
|
];
|
|
366
373
|
});
|
|
374
|
+
const selfHref = info ? safeHref(categoryHref(info.path)) : null;
|
|
375
|
+
if (children.length === 0 || selfHref === null || resolvedTitle.value === '') return children;
|
|
376
|
+
return [
|
|
377
|
+
{
|
|
378
|
+
label: t('collection.allInCategory', {
|
|
379
|
+
category: resolvedTitle.value.toLocaleLowerCase(locale.value),
|
|
380
|
+
}),
|
|
381
|
+
href: selfHref,
|
|
382
|
+
current: true,
|
|
383
|
+
as: isInternalHref(selfHref) ? EldraRouterLink : undefined,
|
|
384
|
+
},
|
|
385
|
+
...children,
|
|
386
|
+
];
|
|
367
387
|
}
|
|
368
388
|
return (data.value.subcollections ?? []).flatMap((item: Subcollection) => {
|
|
369
389
|
const href = safeHref(item.href);
|
|
@@ -387,15 +407,16 @@ const pillsLabel = computed(() =>
|
|
|
387
407
|
|
|
388
408
|
/**
|
|
389
409
|
* The Northwind chip: a 2.5rem outlined pill, the current one filled with `text` on `background`
|
|
390
|
-
* (marked by `aria-current`
|
|
391
|
-
* Exclusive branches, never a base class a
|
|
410
|
+
* (marked by `aria-current` too; the fill is a full light/dark inversion, never a hue alone).
|
|
411
|
+
* The same 500 weight on both, as the design draws them. Exclusive branches, never a base class a
|
|
412
|
+
* variant overrides.
|
|
392
413
|
*/
|
|
393
414
|
const PILL_BASE =
|
|
394
415
|
'inline-flex min-h-10 items-center justify-center whitespace-nowrap rounded-full border px-4 ' +
|
|
395
416
|
'text-[0.9375rem] motion-safe:transition-colors motion-safe:duration-fast';
|
|
396
417
|
function pillClass(pill: ResolvedPill): string {
|
|
397
418
|
if (pill.current) {
|
|
398
|
-
return `${PILL_BASE} bg-text text-background border-text font-
|
|
419
|
+
return `${PILL_BASE} bg-text text-background border-text font-medium`;
|
|
399
420
|
}
|
|
400
421
|
return `${PILL_BASE} border-border-strong text-text font-medium hover:bg-surface`;
|
|
401
422
|
}
|
|
@@ -412,7 +433,11 @@ function pillClass(pill: ResolvedPill): string {
|
|
|
412
433
|
* so `spacing="none"` and the padding is written here, the same pattern `footer` uses.
|
|
413
434
|
*/
|
|
414
435
|
const sectionClass = computed(() =>
|
|
415
|
-
|
|
436
|
+
hasPills.value
|
|
437
|
+
? 'pt-6 pb-5'
|
|
438
|
+
: isImageVariant.value
|
|
439
|
+
? 'pt-6 pb-6'
|
|
440
|
+
: 'pt-6 pb-8 border-border border-b'
|
|
416
441
|
);
|
|
417
442
|
|
|
418
443
|
const rootClass = computed(() =>
|
|
@@ -479,14 +504,22 @@ const IMAGE_FRAME_CLASS = 'relative aspect-[21/9] w-full @min-[60rem]:aspect-[16
|
|
|
479
504
|
<p v-else>{{ storeDescription }}</p>
|
|
480
505
|
</div>
|
|
481
506
|
|
|
507
|
+
<!-- Always rendered (the description always clamps), so its row exists from the first
|
|
508
|
+
server render and nothing below it moves when the overflow measurement lands on
|
|
509
|
+
mount. Until the text is known to overflow it is `invisible` (visibility: hidden
|
|
510
|
+
keeps its box and removes it from the tab order and the accessibility tree),
|
|
511
|
+
`aria-hidden`, `inert` and `tabindex="-1"`, and it carries no aria-expanded or
|
|
512
|
+
aria-controls. -->
|
|
482
513
|
<Button
|
|
483
|
-
v-if="isOverflowing"
|
|
484
514
|
:id="readMoreId"
|
|
485
515
|
variant="link"
|
|
486
516
|
size="sm"
|
|
487
|
-
:aria-expanded="expanded ? 'true' : 'false'"
|
|
488
|
-
:aria-controls="descriptionId"
|
|
489
|
-
|
|
517
|
+
:aria-expanded="isOverflowing ? (expanded ? 'true' : 'false') : undefined"
|
|
518
|
+
:aria-controls="isOverflowing ? descriptionId : undefined"
|
|
519
|
+
:aria-hidden="isOverflowing ? undefined : 'true'"
|
|
520
|
+
:inert="isOverflowing ? undefined : true"
|
|
521
|
+
:tabindex="isOverflowing ? undefined : -1"
|
|
522
|
+
:class="['self-start', isOverflowing ? '' : 'invisible']"
|
|
490
523
|
@click="toggleExpanded"
|
|
491
524
|
@keydown="onReadMoreKeydown"
|
|
492
525
|
>
|
|
@@ -523,11 +556,12 @@ const IMAGE_FRAME_CLASS = 'relative aspect-[21/9] w-full @min-[60rem]:aspect-[16
|
|
|
523
556
|
|
|
524
557
|
<!-- The chip strip scrolls sideways on a narrow screen rather than wrapping into a block of
|
|
525
558
|
pills; `py-1`/`px-1` with the matching negative margin keeps each link's focus ring
|
|
526
|
-
inside the scroll container, which would otherwise clip it.
|
|
559
|
+
inside the scroll container, which would otherwise clip it. With that 0.25rem, `mt-7`
|
|
560
|
+
and the section's `pb-5` are the design's 2rem above the strip and 1.5rem below. -->
|
|
527
561
|
<ul
|
|
528
562
|
v-if="hasPills"
|
|
529
563
|
:aria-label="pillsLabel"
|
|
530
|
-
class="scrollbar-hidden -mx-1 mt-
|
|
564
|
+
class="scrollbar-hidden -mx-1 mt-7 flex gap-2 overflow-x-auto px-1 py-1"
|
|
531
565
|
>
|
|
532
566
|
<li v-for="pill in pills" :key="pill.href" class="shrink-0">
|
|
533
567
|
<Link
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils';
|
|
3
3
|
import { afterEach, describe, expect, it } from 'vitest';
|
|
4
|
-
import { ref, type Ref } from 'vue';
|
|
4
|
+
import { createSSRApp, h, ref, type Ref } from 'vue';
|
|
5
|
+
import { renderToString } from 'vue/server-renderer';
|
|
5
6
|
import { axe } from '../../../test/support/axe';
|
|
6
7
|
import Block from '../Block.vue';
|
|
7
8
|
import mock from '../mock.json';
|
|
@@ -213,6 +214,81 @@ describe('collection-header block', () => {
|
|
|
213
214
|
});
|
|
214
215
|
});
|
|
215
216
|
|
|
217
|
+
describe('layout shift (WS-1451)', () => {
|
|
218
|
+
/** The server-rendered markup of the header, as a detached DOM. jsdom has no layout, so the
|
|
219
|
+
* box is compared by what decides it: the reserved row's element, its tag, and every class
|
|
220
|
+
* except `invisible` (visibility never changes a box). */
|
|
221
|
+
async function serverMarkup(data: Record<string, unknown>): Promise<HTMLElement> {
|
|
222
|
+
const base = mountOptions({ entry: { id: 'e1', data } });
|
|
223
|
+
const app = createSSRApp({ render: () => h(Block, base.props) });
|
|
224
|
+
for (const plugin of base.global.plugins) app.use(plugin as never);
|
|
225
|
+
for (const key of Object.getOwnPropertySymbols(base.global.provide)) {
|
|
226
|
+
app.provide(key, base.global.provide[key as unknown as symbol]);
|
|
227
|
+
}
|
|
228
|
+
for (const [name, component] of Object.entries(base.global.components)) {
|
|
229
|
+
app.component(name, component as never);
|
|
230
|
+
}
|
|
231
|
+
const host = document.createElement('div');
|
|
232
|
+
host.innerHTML = await renderToString(app);
|
|
233
|
+
return host;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function readMoreBox(root: Element) {
|
|
237
|
+
const button = root.querySelector('button[id^="collection-header-readmore-"]')!;
|
|
238
|
+
return {
|
|
239
|
+
tag: button.tagName,
|
|
240
|
+
classes: button
|
|
241
|
+
.getAttribute('class')!
|
|
242
|
+
.split(/\s+/)
|
|
243
|
+
.filter((c) => c !== 'invisible')
|
|
244
|
+
.sort(),
|
|
245
|
+
text: button.textContent!.trim(),
|
|
246
|
+
// Every sibling the button has in its row, so a collapse or an insert would show here.
|
|
247
|
+
siblings: button.parentElement!.children.length,
|
|
248
|
+
descriptionClass: root.querySelector('[id^="collection-header-description-"]')!.className,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
it.each([
|
|
253
|
+
['a long description (overflows)', true],
|
|
254
|
+
['a short description (does not overflow)', false],
|
|
255
|
+
])('keeps the same layout box from server render to mounted with %s', async (_label, long) => {
|
|
256
|
+
if (long) stubOverflow(200, 60);
|
|
257
|
+
const server = await serverMarkup(mock);
|
|
258
|
+
const before = readMoreBox(server);
|
|
259
|
+
const serverButton = server.querySelector('button[id^="collection-header-readmore-"]')!;
|
|
260
|
+
// Reserved on the server, whether or not it will ever show.
|
|
261
|
+
expect(serverButton.classList.contains('invisible')).toBe(true);
|
|
262
|
+
|
|
263
|
+
const wrapper = await mountHeader(mock);
|
|
264
|
+
const after = readMoreBox(wrapper.element);
|
|
265
|
+
expect(after).toEqual(before);
|
|
266
|
+
|
|
267
|
+
const button = wrapper.get('button[id^="collection-header-readmore-"]');
|
|
268
|
+
expect(button.classes('invisible')).toBe(!long);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it('hides the reserved button from keyboard and assistive tech until the text overflows', async () => {
|
|
272
|
+
const wrapper = await mountHeader(mock);
|
|
273
|
+
const button = wrapper.get('button[id^="collection-header-readmore-"]');
|
|
274
|
+
expect(button.attributes('aria-hidden')).toBe('true');
|
|
275
|
+
expect(button.attributes('tabindex')).toBe('-1');
|
|
276
|
+
expect(button.attributes('inert')).toBeDefined();
|
|
277
|
+
expect(button.attributes('aria-expanded')).toBeUndefined();
|
|
278
|
+
expect(button.attributes('aria-controls')).toBeUndefined();
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('shows the button as a normal, named, focusable button once the text overflows', async () => {
|
|
282
|
+
stubOverflow(200, 60);
|
|
283
|
+
const wrapper = await mountHeader(mock);
|
|
284
|
+
const button = wrapper.get('button[id^="collection-header-readmore-"]');
|
|
285
|
+
expect(button.attributes('aria-hidden')).toBeUndefined();
|
|
286
|
+
expect(button.attributes('tabindex')).toBeUndefined();
|
|
287
|
+
expect(button.attributes('inert')).toBeUndefined();
|
|
288
|
+
expect(button.text()).toContain(enUS.collection.readMore);
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
216
292
|
describe('count', () => {
|
|
217
293
|
it("always comes from the storefront (the demo collection's 48), never a field", async () => {
|
|
218
294
|
const wrapper = await mountHeader(mock);
|
|
@@ -226,7 +302,7 @@ describe('collection-header block', () => {
|
|
|
226
302
|
});
|
|
227
303
|
|
|
228
304
|
describe('sub-collection pills', () => {
|
|
229
|
-
it('renders each as a link, marking the current one with aria-current and the
|
|
305
|
+
it('renders each as a link, marking the current one with aria-current and the filled pill', async () => {
|
|
230
306
|
const wrapper = await mountHeader(mock);
|
|
231
307
|
const list = wrapper.get(`ul[aria-label="${enUS.collection.subcollections}"]`);
|
|
232
308
|
const links = list.findAll('a');
|
|
@@ -234,11 +310,11 @@ describe('collection-header block', () => {
|
|
|
234
310
|
|
|
235
311
|
const current = links.find((link) => link.attributes('aria-current') === 'page')!;
|
|
236
312
|
expect(current.text()).toBe('All');
|
|
237
|
-
expect(current.classes()).toContain('
|
|
313
|
+
expect(current.classes()).toContain('bg-text');
|
|
238
314
|
|
|
239
315
|
const notCurrent = links.find((link) => link.text() === 'Sweaters')!;
|
|
240
316
|
expect(notCurrent.attributes('aria-current')).toBeUndefined();
|
|
241
|
-
expect(notCurrent.classes()).not.toContain('
|
|
317
|
+
expect(notCurrent.classes()).not.toContain('bg-text');
|
|
242
318
|
});
|
|
243
319
|
});
|
|
244
320
|
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"fieldId": "href",
|
|
93
93
|
"name": "Link",
|
|
94
94
|
"type": "string",
|
|
95
|
+
"allowPrices": false,
|
|
95
96
|
"validators": { "required": true }
|
|
96
97
|
}
|
|
97
98
|
]
|
|
@@ -122,6 +123,7 @@
|
|
|
122
123
|
"fieldId": "href",
|
|
123
124
|
"name": "Link",
|
|
124
125
|
"type": "string",
|
|
126
|
+
"allowPrices": false,
|
|
125
127
|
"validators": { "required": true }
|
|
126
128
|
},
|
|
127
129
|
{
|
|
Binary file
|
|
@@ -78,12 +78,14 @@
|
|
|
78
78
|
"fieldId": "phone",
|
|
79
79
|
"name": "Phone",
|
|
80
80
|
"type": "string",
|
|
81
|
+
"allowPrices": false,
|
|
81
82
|
"helpText": "Rendered as a tel: link."
|
|
82
83
|
},
|
|
83
84
|
{
|
|
84
85
|
"fieldId": "email",
|
|
85
86
|
"name": "Email",
|
|
86
87
|
"type": "string",
|
|
88
|
+
"allowPrices": false,
|
|
87
89
|
"helpText": "Rendered as a mailto: link."
|
|
88
90
|
},
|
|
89
91
|
{
|
|
@@ -97,12 +99,14 @@
|
|
|
97
99
|
"fieldId": "mapLinkHref",
|
|
98
100
|
"name": "Map link",
|
|
99
101
|
"type": "string",
|
|
102
|
+
"allowPrices": false,
|
|
100
103
|
"helpText": "Google, Apple or OpenStreetMap URL."
|
|
101
104
|
},
|
|
102
105
|
{
|
|
103
106
|
"fieldId": "mapEmbed",
|
|
104
107
|
"name": "Map embed",
|
|
105
108
|
"type": "string",
|
|
109
|
+
"allowPrices": false,
|
|
106
110
|
"helpText": "An embed URL, not HTML."
|
|
107
111
|
},
|
|
108
112
|
{
|
|
Binary file
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"fieldId": "primaryCtaHref",
|
|
49
49
|
"name": "Primary button link",
|
|
50
50
|
"type": "string",
|
|
51
|
+
"allowPrices": false,
|
|
51
52
|
"validators": { "required": true }
|
|
52
53
|
},
|
|
53
54
|
{
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"fieldId": "secondaryCtaHref",
|
|
62
63
|
"name": "Secondary button link",
|
|
63
64
|
"type": "string",
|
|
65
|
+
"allowPrices": false,
|
|
64
66
|
"helpText": "Not shown in banner."
|
|
65
67
|
},
|
|
66
68
|
{
|
|
@@ -21,16 +21,9 @@
|
|
|
21
21
|
* is genuinely unset (`??`, not `||`), so an editor who explicitly sets every item's `open` to
|
|
22
22
|
* `false` really does get every item closed.
|
|
23
23
|
*
|
|
24
|
-
* Each answer is rich text
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* flat `fieldId` against the block's *top-level* registered fields only — there is no nested-path
|
|
28
|
-
* addressing for a list item's own fields. Passing `api-id="faq"` here would silently resolve
|
|
29
|
-
* `localized: false` for every answer regardless of the manifest (a wrong answer, not a missing
|
|
30
|
-
* feature), so `EldraRichText` renders each answer through the same component (and gets the same
|
|
31
|
-
* real markup) but with no `api-id` — read rendering only, no editing/localization binding
|
|
32
|
-
* pretending to know a field path the bindings do not actually support (see `split-content`'s own
|
|
33
|
-
* `rows[].text` for the identical reasoning).
|
|
24
|
+
* Each answer is rich text one level inside a `list` item (`items.0.answer`). `api-id="faq"` lets
|
|
25
|
+
* `EldraRichText` read the answer's `localized` flag by that path, so the canvas edits the locale
|
|
26
|
+
* on show.
|
|
34
27
|
*
|
|
35
28
|
* Answers cap at 65ch: that comes for free from `AccordionItem`'s own panel class
|
|
36
29
|
* (`eldra:max-w-[65ch]`, see that component's source) — nothing here repeats it.
|
|
@@ -175,6 +168,7 @@ useRichTextScrollRegions(accordionRoot, (caption) => caption ?? t('faq.richTextT
|
|
|
175
168
|
class="prose-eldra"
|
|
176
169
|
:entry-id="entryId"
|
|
177
170
|
:field="`items.${index}.answer`"
|
|
171
|
+
api-id="faq"
|
|
178
172
|
:doc="item.answer"
|
|
179
173
|
:min-heading-level="3"
|
|
180
174
|
/>
|
|
@@ -219,6 +213,7 @@ useRichTextScrollRegions(accordionRoot, (caption) => caption ?? t('faq.richTextT
|
|
|
219
213
|
class="prose-eldra"
|
|
220
214
|
:entry-id="entryId"
|
|
221
215
|
:field="`items.${index}.answer`"
|
|
216
|
+
api-id="faq"
|
|
222
217
|
:doc="item.answer"
|
|
223
218
|
:min-heading-level="3"
|
|
224
219
|
/>
|
|
@@ -100,7 +100,18 @@
|
|
|
100
100
|
"content": [
|
|
101
101
|
{
|
|
102
102
|
"type": "text",
|
|
103
|
-
"text": "Every order ships in recycled tissue and a plain kraft box. Add a handwritten card at checkout for
|
|
103
|
+
"text": "Every order ships in recycled tissue and a plain kraft box. Add a handwritten card at checkout for "
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"type": "price",
|
|
107
|
+
"attrs": {
|
|
108
|
+
"id": "card",
|
|
109
|
+
"amounts": { "EUR": 400, "ISK": 600, "USD": 400 }
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"type": "text",
|
|
114
|
+
"text": ", and we leave prices off the packing slip."
|
|
104
115
|
}
|
|
105
116
|
]
|
|
106
117
|
}
|