@eldrajs/theme-cli 0.2.8 → 0.2.10
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 +3 -1
- package/package.json +1 -1
- package/template/.eldra/block-types.d.ts +28 -7
- package/template/.eldra/manifest.json +1034 -355
- package/template/.eldra/previews.json +35 -35
- package/template/README.md +32 -0
- package/template/app/assets/main.css +23 -0
- package/template/app/plugins/eldra-storefront.ts +3 -0
- package/template/app/storefront/demo.ts +75 -24
- package/template/app/storefront/gateway.ts +16 -2
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/preview.json +4 -4
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/Block.vue +48 -19
- package/template/blocks/article-list/__tests__/Block.spec.ts +15 -0
- package/template/blocks/article-list/preview.json +43 -43
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +260 -9
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +202 -0
- package/template/blocks/collection-grid/block.json +3 -3
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +82 -58
- package/template/blocks/collection-header/__tests__/Block.spec.ts +77 -1
- package/template/blocks/collection-header/preview.json +4 -4
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/preview.json +4 -4
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/Block.vue +73 -4
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +43 -1
- package/template/blocks/feature-grid/block.json +2 -2
- package/template/blocks/feature-grid/preview.json +49 -24
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +186 -71
- package/template/blocks/footer/__tests__/Block.spec.ts +127 -32
- package/template/blocks/footer/block.json +42 -4
- package/template/blocks/footer/mock.json +31 -34
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/preview.json +24 -24
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +117 -19
- package/template/blocks/hero/__tests__/Block.spec.ts +46 -0
- package/template/blocks/hero/block.json +36 -1
- package/template/blocks/hero/preview.json +33 -25
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/preview.json +4 -4
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +623 -184
- package/template/blocks/navigation/__tests__/Block.spec.ts +416 -68
- package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
- package/template/blocks/navigation/block.json +102 -6
- package/template/blocks/navigation/mock.json +279 -52
- package/template/blocks/navigation/preview.json +311 -0
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/Block.vue +248 -144
- package/template/blocks/newsletter/__tests__/Block.spec.ts +42 -0
- package/template/blocks/newsletter/block.json +61 -2
- package/template/blocks/newsletter/preview.json +35 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +272 -26
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +90 -0
- package/template/blocks/product-carousel/block.json +61 -0
- package/template/blocks/product-carousel/preview.json +12 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +148 -96
- package/template/blocks/product-detail/__tests__/Block.spec.ts +98 -74
- package/template/blocks/product-detail/block.json +11 -4
- package/template/blocks/product-detail/mock.json +53 -22
- package/template/blocks/product-detail/parts/Gallery.vue +52 -103
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +1 -0
- package/template/blocks/search/TypeSection.vue +1 -0
- package/template/blocks/search/__tests__/Block.spec.ts +23 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/split-content/Block.vue +98 -20
- package/template/blocks/split-content/__tests__/Block.spec.ts +57 -18
- package/template/blocks/split-content/block.json +72 -6
- package/template/blocks/split-content/preview.json +34 -13
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/preview.json +16 -16
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +67 -1
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +30 -1
- package/template/blocks/trust-strip/block.json +4 -4
- package/template/blocks/trust-strip/preview.json +21 -0
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +16 -9
- package/template/i18n/is-IS.json +16 -9
- package/template/pages/article.page.json +19 -18
- package/template/pages/cart.page.json +3 -13
- package/template/pages/category.page.json +15 -7
- package/template/pages/collection.page.json +15 -14
- package/template/pages/home.page.json +217 -182
- package/template/pages/product.page.json +46 -36
- package/template/pages/products.page.json +3 -13
- package/template/pages/search.page.json +3 -13
- package/template/pages/wishlist.page.json +3 -13
- package/template/public/images/CREDITS.md +28 -0
- package/template/public/images/clay-hands.webp +0 -0
- package/template/public/images/coffee-table.webp +0 -0
- package/template/public/images/cup.webp +0 -0
- package/template/public/images/enamel-cups.webp +0 -0
- package/template/public/images/hero.webp +0 -0
- package/template/public/images/kitchen.webp +0 -0
- package/template/public/images/mug.webp +0 -0
- package/template/public/images/northwind-mark.svg +1 -0
- package/template/public/images/planters.webp +0 -0
- package/template/public/images/plates.webp +0 -0
- package/template/public/images/reading.webp +0 -0
- package/template/public/images/sweater.webp +0 -0
- package/template/public/images/terracotta.webp +0 -0
- package/template/public/images/throws.webp +0 -0
- package/template/public/images/vase.webp +0 -0
- package/template/public/images/wheel.webp +0 -0
- package/template/public/images/yarn-tools.webp +0 -0
- package/template/public/images/yarn.webp +0 -0
- package/template/stories/generated/collection-grid.stories.ts +6 -0
- package/template/stories/generated/feature-grid.stories.ts +6 -0
- package/template/stories/generated/footer.stories.ts +4 -4
- package/template/stories/generated/hero.stories.ts +6 -0
- package/template/stories/generated/navigation.stories.ts +14 -1
- package/template/stories/generated/newsletter.stories.ts +2 -1
- package/template/stories/generated/product-carousel.stories.ts +12 -0
- package/template/stories/generated/split-content.stories.ts +12 -0
- package/template/stories/generated/trust-strip.stories.ts +8 -1
- package/template/stories/pages/article.stories.ts +2 -1
- package/template/stories/pages/cart.stories.ts +2 -1
- package/template/stories/pages/category.stories.ts +2 -1
- package/template/stories/pages/collection.stories.ts +2 -1
- package/template/stories/pages/home.stories.ts +2 -1
- package/template/stories/pages/product.stories.ts +2 -1
- package/template/stories/pages/products.stories.ts +2 -1
- package/template/stories/pages/search.stories.ts +2 -1
- package/template/stories/pages/wishlist.stories.ts +2 -1
- package/template/stories/support/demoChrome.ts +32 -0
- package/template/stories/support/pageBlocks.ts +2 -4
- package/template/test/countPill.browser.spec.ts +21 -13
- package/template/test/localePrefix.spec.ts +11 -6
- package/template/test/pages/article.spec.ts +1 -1
- package/template/test/pages/category.spec.ts +34 -11
- package/template/test/pages/collection.spec.ts +182 -148
- package/template/test/pages/home.spec.ts +35 -40
- package/template/test/pages/hydration.spec.ts +4 -4
- package/template/test/pages/product.spec.ts +17 -14
- package/template/test/pages/seededPages.spec.ts +11 -6
- package/template/test/prerenderRefresh.browser.spec.ts +36 -15
- package/template/test/previewParity.browser.spec.ts +36 -2
- package/template/test/starter.spec.ts +31 -15
- package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
- package/template/tokens.json +13 -13
|
@@ -3161,3 +3161,205 @@ describe('collection-grid — card width on a phone', () => {
|
|
|
3161
3161
|
wrapper.unmount();
|
|
3162
3162
|
});
|
|
3163
3163
|
});
|
|
3164
|
+
|
|
3165
|
+
/**
|
|
3166
|
+
* **`filter-bar`**: the same filters as the sidebar, laid out as one row of chips above the grid —
|
|
3167
|
+
* a chip per group opening that group's own panel in a popover, a pressed chip per on/off value, the
|
|
3168
|
+
* sort at the far end, and the applied values as removable tags under it. Only the layout differs,
|
|
3169
|
+
* so every change here goes through the sidebar's own live path (and its debounce): the URL write,
|
|
3170
|
+
* the request and the focus rules are asserted against the same contract the sidebar tests use.
|
|
3171
|
+
*/
|
|
3172
|
+
describe('collection-grid — the filter-bar variant', () => {
|
|
3173
|
+
const barMock = { ...mock, variant: 'filter-bar' };
|
|
3174
|
+
const bar = (wrapper: VueWrapper) =>
|
|
3175
|
+
wrapper.get(`[role="group"][aria-label="${enUS.grid.filterAndSort}"]`);
|
|
3176
|
+
const barTrigger = (wrapper: VueWrapper, label: string) =>
|
|
3177
|
+
bar(wrapper)
|
|
3178
|
+
.findAll('button[aria-haspopup="dialog"]')
|
|
3179
|
+
.find((button) => button.text().startsWith(label))!;
|
|
3180
|
+
const panelOf = (trigger: Element) =>
|
|
3181
|
+
document.getElementById(`${trigger.getAttribute('aria-controls')!}`);
|
|
3182
|
+
|
|
3183
|
+
async function flush(): Promise<void> {
|
|
3184
|
+
for (let index = 0; index < 4; index += 1) {
|
|
3185
|
+
await nextTick();
|
|
3186
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
|
|
3190
|
+
/** What a browser does when `Enter` activates a focused `<button>`: keydown, then a `detail: 0`
|
|
3191
|
+
* click. */
|
|
3192
|
+
async function pressEnter(button: HTMLElement): Promise<void> {
|
|
3193
|
+
button.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
|
|
3194
|
+
button.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, detail: 0 }));
|
|
3195
|
+
await flush();
|
|
3196
|
+
}
|
|
3197
|
+
|
|
3198
|
+
afterEach(() => {
|
|
3199
|
+
document.body.innerHTML = '';
|
|
3200
|
+
});
|
|
3201
|
+
|
|
3202
|
+
it('draws a chip per group, a pressed chip per on/off value and the sort — no sidebar, no drawer', async () => {
|
|
3203
|
+
const wrapper = mountGrid(barMock);
|
|
3204
|
+
await wrapper.vm.$nextTick();
|
|
3205
|
+
|
|
3206
|
+
expect(wrapper.find('aside').exists()).toBe(false);
|
|
3207
|
+
expect(wrapper.find('dialog').exists()).toBe(false);
|
|
3208
|
+
const groups = bar(wrapper).findAll('button[aria-haspopup="dialog"]');
|
|
3209
|
+
// Category, Size, Colour, Price: every seeded group but the on/off Availability one.
|
|
3210
|
+
expect(groups.map((button) => button.text())).toEqual([
|
|
3211
|
+
enUS.grid.legendCategory,
|
|
3212
|
+
'Size',
|
|
3213
|
+
'Colour',
|
|
3214
|
+
PRICE_LEGEND,
|
|
3215
|
+
]);
|
|
3216
|
+
const pressed = bar(wrapper).get('button[aria-pressed]');
|
|
3217
|
+
expect(pressed.text()).toBe(enUS.grid.availabilityInStock);
|
|
3218
|
+
expect(pressed.attributes('aria-pressed')).toBe('false');
|
|
3219
|
+
expect(comboboxes(wrapper)).toHaveLength(2); // Sort, and Columns from 64rem
|
|
3220
|
+
expect(countLine(wrapper).text()).toBe('48 products');
|
|
3221
|
+
});
|
|
3222
|
+
|
|
3223
|
+
it('is axe-clean closed, with a group open, and with filters applied', async () => {
|
|
3224
|
+
const wrapper = mountGrid(barMock, { attachTo: document.body });
|
|
3225
|
+
await wrapper.vm.$nextTick();
|
|
3226
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
3227
|
+
|
|
3228
|
+
const colour = barTrigger(wrapper, 'Colour').element as HTMLElement;
|
|
3229
|
+
await pressEnter(colour);
|
|
3230
|
+
const panel = panelOf(colour)!;
|
|
3231
|
+
expect(panel).not.toBeNull();
|
|
3232
|
+
expect(panel.getAttribute('role')).toBe('dialog');
|
|
3233
|
+
expect(panel.getAttribute('aria-label')).toBe('Colour');
|
|
3234
|
+
expect(await axe(panel)).toHaveNoViolations();
|
|
3235
|
+
|
|
3236
|
+
(panel.querySelector('input[type="checkbox"]') as HTMLInputElement).click();
|
|
3237
|
+
await flush();
|
|
3238
|
+
await bar(wrapper).get('button[aria-pressed]').trigger('click');
|
|
3239
|
+
await flush();
|
|
3240
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
3241
|
+
});
|
|
3242
|
+
|
|
3243
|
+
describe('keyboard', () => {
|
|
3244
|
+
it('Enter opens a group, a ticked value applies at once, Escape closes and returns focus', async () => {
|
|
3245
|
+
const source = createDemoStorefront();
|
|
3246
|
+
const patches: Array<Record<string, unknown>> = [];
|
|
3247
|
+
const route = {
|
|
3248
|
+
...source.route,
|
|
3249
|
+
setQuery(patch: Record<string, string | string[] | null>) {
|
|
3250
|
+
patches.push(patch);
|
|
3251
|
+
},
|
|
3252
|
+
};
|
|
3253
|
+
const wrapper = mountGrid(barMock, {
|
|
3254
|
+
source: { ...source, route },
|
|
3255
|
+
attachTo: document.body,
|
|
3256
|
+
});
|
|
3257
|
+
await wrapper.vm.$nextTick();
|
|
3258
|
+
|
|
3259
|
+
const size = barTrigger(wrapper, 'Size').element as HTMLElement;
|
|
3260
|
+
size.focus();
|
|
3261
|
+
await pressEnter(size);
|
|
3262
|
+
expect(size.getAttribute('aria-expanded')).toBe('true');
|
|
3263
|
+
|
|
3264
|
+
const panel = panelOf(size)!;
|
|
3265
|
+
const box = panel.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')[2]!;
|
|
3266
|
+
box.focus();
|
|
3267
|
+
box.click();
|
|
3268
|
+
await flush();
|
|
3269
|
+
|
|
3270
|
+
// The sidebar's own live path: the URL moves on the tick, the trigger counts it.
|
|
3271
|
+
expect(patches.at(-1)).toMatchObject({ page: null, size: ['m'] });
|
|
3272
|
+
expect(barTrigger(wrapper, 'Size').text()).toContain('1');
|
|
3273
|
+
expect(wrapper.get(`ul[aria-label="${enUS.grid.activeFilters}"]`).text()).toContain('M');
|
|
3274
|
+
|
|
3275
|
+
box.dispatchEvent(
|
|
3276
|
+
new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true })
|
|
3277
|
+
);
|
|
3278
|
+
await flush();
|
|
3279
|
+
expect(panelOf(size)).toBeNull();
|
|
3280
|
+
expect(document.activeElement).toBe(size);
|
|
3281
|
+
});
|
|
3282
|
+
|
|
3283
|
+
it('Enter on an on/off chip presses it and adds its tag; removing the tag focuses the count', async () => {
|
|
3284
|
+
const wrapper = mountGrid(barMock, { attachTo: document.body });
|
|
3285
|
+
await wrapper.vm.$nextTick();
|
|
3286
|
+
|
|
3287
|
+
const chip = bar(wrapper).get('button[aria-pressed]');
|
|
3288
|
+
(chip.element as HTMLElement).focus();
|
|
3289
|
+
// A native button turns Enter into a click; jsdom does not, so the click is dispatched.
|
|
3290
|
+
await chip.trigger('click');
|
|
3291
|
+
await flush();
|
|
3292
|
+
expect(chip.attributes('aria-pressed')).toBe('true');
|
|
3293
|
+
|
|
3294
|
+
const tags = wrapper.get(`ul[aria-label="${enUS.grid.activeFilters}"]`);
|
|
3295
|
+
const remove = tags.get('[data-part="removeButton"]');
|
|
3296
|
+
expect(remove.attributes('aria-label')).toBe(
|
|
3297
|
+
`Remove filter ${enUS.grid.legendAvailability}: ${enUS.grid.availabilityInStock}`
|
|
3298
|
+
);
|
|
3299
|
+
await remove.trigger('click');
|
|
3300
|
+
await flush();
|
|
3301
|
+
|
|
3302
|
+
expect(chip.attributes('aria-pressed')).toBe('false');
|
|
3303
|
+
expect(wrapper.find(`ul[aria-label="${enUS.grid.activeFilters}"]`).exists()).toBe(false);
|
|
3304
|
+
expect(document.activeElement).toBe(countLine(wrapper).element);
|
|
3305
|
+
});
|
|
3306
|
+
|
|
3307
|
+
it('removing one of two tags moves focus to the next tag', async () => {
|
|
3308
|
+
const wrapper = mountGrid(barMock, { attachTo: document.body });
|
|
3309
|
+
await wrapper.vm.$nextTick();
|
|
3310
|
+
const size = barTrigger(wrapper, 'Size').element as HTMLElement;
|
|
3311
|
+
await pressEnter(size);
|
|
3312
|
+
const boxes = panelOf(size)!.querySelectorAll<HTMLInputElement>('input[type="checkbox"]');
|
|
3313
|
+
boxes[0]!.click();
|
|
3314
|
+
await flush();
|
|
3315
|
+
boxes[1]!.click();
|
|
3316
|
+
await flush();
|
|
3317
|
+
|
|
3318
|
+
const tags = () =>
|
|
3319
|
+
wrapper
|
|
3320
|
+
.get(`ul[aria-label="${enUS.grid.activeFilters}"]`)
|
|
3321
|
+
.findAll('[data-part="removeButton"]');
|
|
3322
|
+
expect(tags()).toHaveLength(2);
|
|
3323
|
+
await tags()[0]!.trigger('click');
|
|
3324
|
+
await flush();
|
|
3325
|
+
expect(tags()).toHaveLength(1);
|
|
3326
|
+
expect(document.activeElement).toBe(tags()[0]!.element);
|
|
3327
|
+
});
|
|
3328
|
+
|
|
3329
|
+
it('Clear all empties the selection and focuses the count', async () => {
|
|
3330
|
+
const wrapper = mountGrid(barMock, { attachTo: document.body });
|
|
3331
|
+
await wrapper.vm.$nextTick();
|
|
3332
|
+
await bar(wrapper).get('button[aria-pressed]').trigger('click');
|
|
3333
|
+
await flush();
|
|
3334
|
+
|
|
3335
|
+
const clearAll = wrapper
|
|
3336
|
+
.findAll('button')
|
|
3337
|
+
.find((button) => button.text() === enUS.grid.clearAll)!;
|
|
3338
|
+
(clearAll.element as HTMLElement).focus();
|
|
3339
|
+
await clearAll.trigger('click');
|
|
3340
|
+
await flush();
|
|
3341
|
+
|
|
3342
|
+
expect(bar(wrapper).get('button[aria-pressed]').attributes('aria-pressed')).toBe('false');
|
|
3343
|
+
expect(wrapper.find(`ul[aria-label="${enUS.grid.activeFilters}"]`).exists()).toBe(false);
|
|
3344
|
+
expect(document.activeElement).toBe(countLine(wrapper).element);
|
|
3345
|
+
});
|
|
3346
|
+
});
|
|
3347
|
+
|
|
3348
|
+
it('the bar’s requests are the sidebar’s: one debounced read for a run of changes', async () => {
|
|
3349
|
+
const stub = createStub(PRODUCTS, { filteredCount: 4 });
|
|
3350
|
+
const wrapper = mountGrid(barMock, { source: stub.source, attachTo: document.body });
|
|
3351
|
+
await wrapper.vm.$nextTick();
|
|
3352
|
+
const before = stub.requests.length;
|
|
3353
|
+
|
|
3354
|
+
useFilterTimers();
|
|
3355
|
+
await bar(wrapper).get('button[aria-pressed]').trigger('click');
|
|
3356
|
+
await bar(wrapper).get('button[aria-pressed]').trigger('click');
|
|
3357
|
+
await bar(wrapper).get('button[aria-pressed]').trigger('click');
|
|
3358
|
+
await settleFilterDebounce(wrapper);
|
|
3359
|
+
await flushPromises();
|
|
3360
|
+
|
|
3361
|
+
expect(stub.requests.length).toBe(before + 1);
|
|
3362
|
+
expect(stub.requests.at(-1)?.filters).toEqual({ availability: ['in_stock'] });
|
|
3363
|
+
expect(countLine(wrapper).text()).toBe('4 products');
|
|
3364
|
+
});
|
|
3365
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"apiId": "collection-grid",
|
|
3
3
|
"name": "Collection grid",
|
|
4
|
-
"description": "A collection's products as a filterable, sortable card grid, with a filter sidebar on wide layouts and a filter drawer on narrow ones.",
|
|
4
|
+
"description": "A collection's products as a filterable, sortable card grid, with a filter sidebar on wide layouts and a filter drawer on narrow ones, or a horizontal filter bar above the grid.",
|
|
5
5
|
"icon": "layout-grid",
|
|
6
6
|
"category": "commerce",
|
|
7
7
|
"version": 3,
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"fieldId": "variant",
|
|
25
25
|
"name": "Variant",
|
|
26
26
|
"type": "select",
|
|
27
|
-
"helpText": "sidebar is the default. drawer-only gives the grid the full width at every size.",
|
|
28
|
-
"metadata": { "options": ["sidebar", "drawer-only"] },
|
|
27
|
+
"helpText": "sidebar is the default. drawer-only gives the grid the full width at every size. filter-bar puts one row of filter chips above the grid, each opening its own group, with the applied filters as removable tags under it.",
|
|
28
|
+
"metadata": { "options": ["sidebar", "drawer-only", "filter-bar"] },
|
|
29
29
|
"validators": { "required": true }
|
|
30
30
|
},
|
|
31
31
|
{
|
|
Binary file
|
|
@@ -24,15 +24,19 @@
|
|
|
24
24
|
* categories carry no count, and a curated collection chip beside a category chip would be two
|
|
25
25
|
* different things in one strip.
|
|
26
26
|
*
|
|
27
|
-
* `variant: 'image'`
|
|
28
|
-
* vertically centred
|
|
29
|
-
*
|
|
27
|
+
* `variant: 'image'` is a banner: text left and a 26rem, 16:10 image right from 60rem of the
|
|
28
|
+
* block's width, vertically centred, and below that the text first with a wide 21:9 crop under it;
|
|
29
|
+
* `variant: 'text-only'` is a single column capped at 48rem. The chip strip (sub-collections, or a
|
|
30
|
+
* category's children) runs under either, full width, scrolling sideways on a narrow screen. Neither field nor collection image resolves the `image`
|
|
30
31
|
* variant silently becomes `text-only` — `effectiveVariant` below, never an empty frame (spec
|
|
31
32
|
* States, "No image"; Acceptance: "With no image and no collection image, the block renders as
|
|
32
33
|
* text-only").
|
|
33
34
|
*
|
|
34
|
-
* The description clamps to 3 lines; **Read more** (`@eldrajs/ui`'s `Button variant="link"`)
|
|
35
|
-
* 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)
|
|
36
40
|
* by comparing `scrollHeight` to `clientHeight` on the clamped element — the same
|
|
37
41
|
* `typeof ResizeObserver !== 'undefined'` guard `packages/ui`'s own `useCarousel` uses, since jsdom
|
|
38
42
|
* has no `ResizeObserver`. `Esc` — on the button itself, or from inside the expanded text — collapses
|
|
@@ -233,7 +237,7 @@ function onDescriptionKeydown(event: KeyboardEvent): void {
|
|
|
233
237
|
}
|
|
234
238
|
|
|
235
239
|
const descriptionClass = computed(() => [
|
|
236
|
-
'text-muted max-w-[
|
|
240
|
+
'text-muted max-w-[34rem] text-[1.125rem]',
|
|
237
241
|
!expanded.value ? 'line-clamp-3' : '',
|
|
238
242
|
]);
|
|
239
243
|
|
|
@@ -384,38 +388,44 @@ const pillsLabel = computed(() =>
|
|
|
384
388
|
categoryMode.value ? t('collection.subcategories') : t('collection.subcollections')
|
|
385
389
|
);
|
|
386
390
|
|
|
391
|
+
/**
|
|
392
|
+
* The Northwind chip: a 2.5rem outlined pill, the current one filled with `text` on `background`
|
|
393
|
+
* (marked by `aria-current` and a heavier weight as well, so it never rests on colour alone).
|
|
394
|
+
* Exclusive branches, never a base class a variant overrides.
|
|
395
|
+
*/
|
|
396
|
+
const PILL_BASE =
|
|
397
|
+
'inline-flex min-h-10 items-center justify-center whitespace-nowrap rounded-full border px-4 ' +
|
|
398
|
+
'text-[0.9375rem] motion-safe:transition-colors motion-safe:duration-fast';
|
|
387
399
|
function pillClass(pill: ResolvedPill): string {
|
|
388
|
-
const base =
|
|
389
|
-
'inline-flex h-11 items-center justify-center whitespace-nowrap rounded-full border px-4 ' +
|
|
390
|
-
'text-[0.875rem] font-medium @tablet:h-9 motion-safe:transition-colors motion-safe:duration-fast';
|
|
391
400
|
if (pill.current) {
|
|
392
|
-
return `${
|
|
401
|
+
return `${PILL_BASE} bg-text text-background border-text font-semibold`;
|
|
393
402
|
}
|
|
394
|
-
return `${
|
|
403
|
+
return `${PILL_BASE} border-border-strong text-text font-medium hover:bg-surface`;
|
|
395
404
|
}
|
|
396
405
|
|
|
397
406
|
// ---------------------------------------------------------------------------------------------
|
|
398
407
|
// Layout.
|
|
399
408
|
// ---------------------------------------------------------------------------------------------
|
|
400
409
|
|
|
401
|
-
/**
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
|
|
410
|
+
/**
|
|
411
|
+
* The banner: text beside a 26rem image from 60rem of the block's width (the design's own 960px
|
|
412
|
+
* edge, so a tablet gets the stacked layout), stacked below that with the text first and a wide
|
|
413
|
+
* 21:9 crop under it. The chip strip sits under the banner, full width, scrolling sideways rather
|
|
414
|
+
* than wrapping on a phone. `Section`'s shared spacing steps don't carry these asymmetric values,
|
|
415
|
+
* so `spacing="none"` and the padding is written here, the same pattern `footer` uses.
|
|
416
|
+
*/
|
|
405
417
|
const sectionClass = computed(() =>
|
|
406
|
-
isImageVariant.value ?
|
|
418
|
+
isImageVariant.value || hasPills.value ? 'pt-6 pb-6' : 'pt-6 pb-8 border-border border-b'
|
|
407
419
|
);
|
|
408
420
|
|
|
409
421
|
const rootClass = computed(() =>
|
|
410
422
|
isImageVariant.value
|
|
411
|
-
? 'grid grid-cols-1 gap-6 @
|
|
423
|
+
? 'grid grid-cols-1 gap-6 @min-[60rem]:grid-cols-[minmax(0,1fr)_26rem] @min-[60rem]:items-center @min-[60rem]:gap-12'
|
|
412
424
|
: 'flex max-w-[48rem] flex-col'
|
|
413
425
|
);
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
: 'flex flex-col gap-4'
|
|
418
|
-
);
|
|
426
|
+
/** The 21:9 → 16:10 crop is the wrapper's, so `UiImage` fills it (`fill`) rather than reserving a
|
|
427
|
+
* single fixed ratio of its own. */
|
|
428
|
+
const IMAGE_FRAME_CLASS = 'relative aspect-[21/9] w-full @min-[60rem]:aspect-[16/10]';
|
|
419
429
|
</script>
|
|
420
430
|
|
|
421
431
|
<template>
|
|
@@ -428,20 +438,7 @@ const textColumnClass = computed(() =>
|
|
|
428
438
|
>
|
|
429
439
|
<Container width="wide">
|
|
430
440
|
<div :class="rootClass">
|
|
431
|
-
<div
|
|
432
|
-
<UiImage
|
|
433
|
-
:src="resolvedImage!.src"
|
|
434
|
-
:alt="resolvedImage!.alt"
|
|
435
|
-
:framing="resolvedImage!.framing"
|
|
436
|
-
:entry-id="resolvedImage!.fromField ? entryId : undefined"
|
|
437
|
-
:field-path="resolvedImage!.fromField ? 'image' : undefined"
|
|
438
|
-
aspect="3/2"
|
|
439
|
-
rounded="xl"
|
|
440
|
-
class="w-full"
|
|
441
|
-
/>
|
|
442
|
-
</div>
|
|
443
|
-
|
|
444
|
-
<div :class="textColumnClass">
|
|
441
|
+
<div class="flex flex-col gap-4">
|
|
445
442
|
<Breadcrumb
|
|
446
443
|
v-if="showBreadcrumb && breadcrumbItems.length > 0"
|
|
447
444
|
:items="breadcrumbItems"
|
|
@@ -451,7 +448,7 @@ const textColumnClass = computed(() =>
|
|
|
451
448
|
<h1
|
|
452
449
|
v-if="hasTitle"
|
|
453
450
|
:id="headingId"
|
|
454
|
-
class="font-heading @
|
|
451
|
+
class="font-heading @tablet:text-[3.25rem] text-[2.25rem] leading-[1.05] font-medium tracking-[-0.015em] text-balance"
|
|
455
452
|
>
|
|
456
453
|
{{ resolvedTitle }}
|
|
457
454
|
</h1>
|
|
@@ -475,7 +472,7 @@ const textColumnClass = computed(() =>
|
|
|
475
472
|
collection page. A floor, never an offset: h2/h3 in the document stay put. -->
|
|
476
473
|
<EldraRichText
|
|
477
474
|
v-if="hasFieldDescription"
|
|
478
|
-
class="prose-eldra text-muted"
|
|
475
|
+
class="prose-eldra text-muted text-[1.125rem]"
|
|
479
476
|
:entry-id="entryId"
|
|
480
477
|
field="description"
|
|
481
478
|
api-id="collection-header"
|
|
@@ -485,14 +482,22 @@ const textColumnClass = computed(() =>
|
|
|
485
482
|
<p v-else>{{ storeDescription }}</p>
|
|
486
483
|
</div>
|
|
487
484
|
|
|
485
|
+
<!-- Always rendered (the description always clamps), so its row exists from the first
|
|
486
|
+
server render and nothing below it moves when the overflow measurement lands on
|
|
487
|
+
mount. Until the text is known to overflow it is `invisible` (visibility: hidden
|
|
488
|
+
keeps its box and removes it from the tab order and the accessibility tree),
|
|
489
|
+
`aria-hidden`, `inert` and `tabindex="-1"`, and it carries no aria-expanded or
|
|
490
|
+
aria-controls. -->
|
|
488
491
|
<Button
|
|
489
|
-
v-if="isOverflowing"
|
|
490
492
|
:id="readMoreId"
|
|
491
493
|
variant="link"
|
|
492
494
|
size="sm"
|
|
493
|
-
:aria-expanded="expanded ? 'true' : 'false'"
|
|
494
|
-
:aria-controls="descriptionId"
|
|
495
|
-
|
|
495
|
+
:aria-expanded="isOverflowing ? (expanded ? 'true' : 'false') : undefined"
|
|
496
|
+
:aria-controls="isOverflowing ? descriptionId : undefined"
|
|
497
|
+
:aria-hidden="isOverflowing ? undefined : 'true'"
|
|
498
|
+
:inert="isOverflowing ? undefined : true"
|
|
499
|
+
:tabindex="isOverflowing ? undefined : -1"
|
|
500
|
+
:class="['self-start', isOverflowing ? '' : 'invisible']"
|
|
496
501
|
@click="toggleExpanded"
|
|
497
502
|
@keydown="onReadMoreKeydown"
|
|
498
503
|
>
|
|
@@ -510,24 +515,43 @@ const textColumnClass = computed(() =>
|
|
|
510
515
|
</Button>
|
|
511
516
|
</div>
|
|
512
517
|
|
|
513
|
-
<
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
</ul>
|
|
528
|
-
</div>
|
|
518
|
+
<p v-if="hasCount" class="text-muted text-[0.875rem] tabular-nums">{{ countText }}</p>
|
|
519
|
+
</div>
|
|
520
|
+
|
|
521
|
+
<!-- Second in the DOM and on screen: beside the text from 60rem, under it below. -->
|
|
522
|
+
<div v-if="isImageVariant" :class="IMAGE_FRAME_CLASS">
|
|
523
|
+
<UiImage
|
|
524
|
+
:src="resolvedImage!.src"
|
|
525
|
+
:alt="resolvedImage!.alt"
|
|
526
|
+
:framing="resolvedImage!.framing"
|
|
527
|
+
:entry-id="resolvedImage!.fromField ? entryId : undefined"
|
|
528
|
+
:field-path="resolvedImage!.fromField ? 'image' : undefined"
|
|
529
|
+
fill
|
|
530
|
+
rounded="xl"
|
|
531
|
+
/>
|
|
529
532
|
</div>
|
|
530
533
|
</div>
|
|
534
|
+
|
|
535
|
+
<!-- The chip strip scrolls sideways on a narrow screen rather than wrapping into a block of
|
|
536
|
+
pills; `py-1`/`px-1` with the matching negative margin keeps each link's focus ring
|
|
537
|
+
inside the scroll container, which would otherwise clip it. -->
|
|
538
|
+
<ul
|
|
539
|
+
v-if="hasPills"
|
|
540
|
+
:aria-label="pillsLabel"
|
|
541
|
+
class="scrollbar-hidden -mx-1 mt-4 flex gap-2 overflow-x-auto px-1 py-1"
|
|
542
|
+
>
|
|
543
|
+
<li v-for="pill in pills" :key="pill.href" class="shrink-0">
|
|
544
|
+
<Link
|
|
545
|
+
:href="pill.href"
|
|
546
|
+
:as="pill.as"
|
|
547
|
+
:underline="false"
|
|
548
|
+
:aria-current="pill.current ? 'page' : undefined"
|
|
549
|
+
:class="pillClass(pill)"
|
|
550
|
+
>
|
|
551
|
+
{{ pill.label }}
|
|
552
|
+
</Link>
|
|
553
|
+
</li>
|
|
554
|
+
</ul>
|
|
531
555
|
</Container>
|
|
532
556
|
</Section>
|
|
533
557
|
</template>
|
|
@@ -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);
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
},
|
|
7
7
|
"image": {
|
|
8
8
|
"assetId": "demo-collection-1",
|
|
9
|
-
"url": "/
|
|
10
|
-
"altText": "
|
|
11
|
-
"width":
|
|
12
|
-
"height":
|
|
9
|
+
"url": "/images/sweater.webp",
|
|
10
|
+
"altText": "A folded knitted sweater",
|
|
11
|
+
"width": 1400,
|
|
12
|
+
"height": 933
|
|
13
13
|
}
|
|
14
14
|
}
|
|
Binary file
|
|
Binary file
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"image": {
|
|
3
3
|
"assetId": "demo-cta-split",
|
|
4
|
-
"url": "/
|
|
5
|
-
"altText": "
|
|
6
|
-
"width":
|
|
7
|
-
"height":
|
|
4
|
+
"url": "/images/planters.webp",
|
|
5
|
+
"altText": "Ceramic planters with green plants",
|
|
6
|
+
"width": 932,
|
|
7
|
+
"height": 1400
|
|
8
8
|
}
|
|
9
9
|
}
|
|
Binary file
|
|
Binary file
|