@eldrajs/theme-cli 0.2.9 → 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 +1 -0
- package/package.json +1 -1
- package/template/.eldra/previews.json +35 -35
- package/template/blocks/collection-header/Block.vue +17 -6
- package/template/blocks/collection-header/__tests__/Block.spec.ts +77 -1
- package/template/blocks/navigation/Block.vue +3 -2
- package/template/blocks/navigation/__tests__/Block.spec.ts +10 -0
- package/template/test/previewParity.browser.spec.ts +36 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,7 @@ Release-please writes the generated notes from commit messages and does not repl
|
|
|
5
5
|
|
|
6
6
|
## Unreleased
|
|
7
7
|
|
|
8
|
+
- The scaffolded starter's `collection-header` no longer shifts the page when it hydrates (WS-1451): the Read more row is reserved from the first server render and stays hidden, inert and out of the accessibility tree until the description is known to overflow its three-line clamp.
|
|
8
9
|
- The scaffolded starter is redesigned as Northwind Goods (WS-1277): a new palette and serif headings in `tokens.json`, 18 CC0 demo photos in `public/images/` (sources in `CREDITS.md`), and new optional fields and variants, so existing content keeps rendering. The header gains an info strip (`infoItems`), labelled tools, a square `brandMark` for small phones, an `account` link and a phone-menu `drawerLayout`, and its cards are now 4:5. The footer is dark by default and gains `address`, `phone`, `email` and `hours`. New variants: `hero` `card`, `trust-strip` `numbered`, `feature-grid` `arched` and `collection-grid` `filter-bar`. `product-carousel` gains filter chips, a grid layout and quick add; `split-content` gains a list of makers and a background; `newsletter` `split` gains a help panel. The product page has an image mosaic with Lightbox zoom and an accordion. The seeded pages drop the announcement bar, since the header's info strip replaces it. The starter README maps every page-builder feature to the file that shows it.
|
|
9
10
|
- The scaffolded starter's header declares menu sections and product/collection cards on its `links` field and draws them (WS-1362): a mega panel column of cards, each a picture, a title and a price. Its `navigation` block is version 5 with a `groupsToSections` migration, and its mock is sections; deploying it needs a cms-service that has `groupsToSections`, so deploy the platform first.
|
|
10
11
|
- The starter template builds its pages in the store's default currency (`commerce.defaultCurrency`), and never offers the store's own currency once the store turned it off; a cart left in that currency moves to the default, and a business customer's cart stays in ISK (`currency.keepOwnCurrency()` for a theme with business sign-in) (WS-1399).
|
package/package.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
{
|
|
2
|
-
"announcement-bar": "
|
|
3
|
-
"article": "
|
|
4
|
-
"article-list": "
|
|
5
|
-
"breadcrumbs": "
|
|
6
|
-
"cart": "
|
|
7
|
-
"collection-grid": "
|
|
8
|
-
"collection-header": "
|
|
9
|
-
"contact": "
|
|
10
|
-
"cta": "
|
|
11
|
-
"faq": "
|
|
12
|
-
"feature-grid": "
|
|
13
|
-
"footer": "
|
|
14
|
-
"form": "
|
|
15
|
-
"gallery": "
|
|
16
|
-
"hero": "
|
|
17
|
-
"image": "
|
|
18
|
-
"logo-cloud": "
|
|
19
|
-
"navigation": "
|
|
20
|
-
"newsletter": "
|
|
21
|
-
"order-status": "
|
|
22
|
-
"pricing-table": "
|
|
23
|
-
"product-carousel": "
|
|
24
|
-
"product-detail": "
|
|
25
|
-
"quote": "
|
|
26
|
-
"rich-text": "
|
|
27
|
-
"search": "
|
|
28
|
-
"split-content": "
|
|
29
|
-
"stats": "
|
|
30
|
-
"tabs": "
|
|
31
|
-
"team": "
|
|
32
|
-
"testimonials": "
|
|
33
|
-
"timeline": "
|
|
34
|
-
"trust-strip": "
|
|
35
|
-
"video-embed": "
|
|
36
|
-
"wishlist": "
|
|
2
|
+
"announcement-bar": "57585e73344f7f93e035e0ad2b4dd6bb78a637938748fe3e3cc3a5be03f9dd2e",
|
|
3
|
+
"article": "a1547a989ef3d10050746285d4ce1c24b16e2610e2bd050dafa5c488c67af89a",
|
|
4
|
+
"article-list": "d3f44dd64ee22d9a0601d09a83796630102908a1ec6382de920438b0abab5a18",
|
|
5
|
+
"breadcrumbs": "d4c6ced656b44bf949c4e4ea227d92d3890ca4cbc655aa07660d60d3121e7e18",
|
|
6
|
+
"cart": "36f3bc9cb2d5344d23e5cba32e02a7f4406b516f1f67bd048940b5277aa366af",
|
|
7
|
+
"collection-grid": "ca49c57711dfdce4360fb71b625c7e09352b0e5aa906e511108221198e6b8ca4",
|
|
8
|
+
"collection-header": "84ccdb7fec7818e26c7380c54109c6bef6fd4220bca2881a495fa6c37498ba11",
|
|
9
|
+
"contact": "a5a8e88a33a067924dee514db34fabc75a041571174543c1f20a726d7d9dea97",
|
|
10
|
+
"cta": "e1971283c825fb8151ea021adb8342291dce7d0fb131cd3c523b4a214d91e629",
|
|
11
|
+
"faq": "b7300c859d2fbe9df7a530f023ac31217e2ce903e73ecf97420eaf2f5e412e1c",
|
|
12
|
+
"feature-grid": "fd3843fd1ec77463f2ba1aac882071febeb4ab6ff3942b167f7cfc78b60a1f0c",
|
|
13
|
+
"footer": "36921634f057d3c242d8af500e1c02bb2b7d5cd2496333de343f582f5b9c8c33",
|
|
14
|
+
"form": "6a8a93e671d828b43823b0f59d774f582e89df4d89aaba6494a1841cbe7998da",
|
|
15
|
+
"gallery": "ed4b5a8bf44ef89c105555d95863227ce17434cb42226bbc7872ec24b863cf09",
|
|
16
|
+
"hero": "d8a215c971ff457a249de48195c5cd01145254779dedb2f46665fe22c1071af2",
|
|
17
|
+
"image": "2a02bc00b716a913973fcdffcb27a393055ccdd5d2cc02b43c25d59c391a04a9",
|
|
18
|
+
"logo-cloud": "879e21642dd6af00c38dab6677367d7813ba6297dfba96c76c83c858dbb13fd2",
|
|
19
|
+
"navigation": "f819d25dd803e67b89309caf8c45242d32aa3917cbf4aa6efcb2177f9d50cebe",
|
|
20
|
+
"newsletter": "72df60e514a4409ed38df928ef1a2c3ad4593ebaaa436e283c492a91be183769",
|
|
21
|
+
"order-status": "c171b7f74e618d7df6f30b5bbbd4c440489a4e0a3783637738c92598b1d681e9",
|
|
22
|
+
"pricing-table": "fb5bc12b2ec9e945ee2d0a89c75104a181d0d5b50cff23bf44f9126cbe37bed7",
|
|
23
|
+
"product-carousel": "4e79a2f991af8a61865b369669a8da5abb60ef59d356cd1ef69da39b721433de",
|
|
24
|
+
"product-detail": "433cd3a66afa9c12f70b85a32c60325fca25f389c0df9a5a5747d6608c56dcb6",
|
|
25
|
+
"quote": "5b759a46d13182767cb7ec7000c5522dffebffc7d15b5875b0e6ed10a5d15f2e",
|
|
26
|
+
"rich-text": "3335be168a9da49e74975a5d08cb2bc7611e5352ae084f67847978641172ca5e",
|
|
27
|
+
"search": "7b3a1246e7f1fde145586bae58727915457a96fc99bf32256ea79739831a1dd3",
|
|
28
|
+
"split-content": "0809f4b9293ed1923674e1980985fb036ecd225b8e8ec4daf475c4993f3abd68",
|
|
29
|
+
"stats": "a20899c1e2276a2ca9dd506a37509f3184c4c59cac7599638ca0f3d4b5015211",
|
|
30
|
+
"tabs": "e0673e483c57e6240488a7c6977daed94b3de3a02b144535e720ac55de6e5c7d",
|
|
31
|
+
"team": "d94f9148f05f4891439cf20d92682ec8531528fbdea78df388cd9a63646e3d60",
|
|
32
|
+
"testimonials": "941e03c9f08aff291be1819a0aa6ea691471d1482bb86632be0b3c8f3d0f039b",
|
|
33
|
+
"timeline": "f289d4b847e8784fb2fcc0c50fceef3438472c94bdb6c866c31a6070fb84765b",
|
|
34
|
+
"trust-strip": "ea8ff8d5cdf05e46334badbc818d67115b99cf534a1bea9cf4f8852df35f82fc",
|
|
35
|
+
"video-embed": "db48fd9b3442c0195afdfe7adf48b9c7b2a6bb8a824bff7bdf44807a39867fb6",
|
|
36
|
+
"wishlist": "b214be4a302e780cfbb2b04f23fa1cd4f6dc5ca5ac65a03ec7a802825a80dfcd"
|
|
37
37
|
}
|
|
@@ -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
|
|
@@ -479,14 +482,22 @@ const IMAGE_FRAME_CLASS = 'relative aspect-[21/9] w-full @min-[60rem]:aspect-[16
|
|
|
479
482
|
<p v-else>{{ storeDescription }}</p>
|
|
480
483
|
</div>
|
|
481
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. -->
|
|
482
491
|
<Button
|
|
483
|
-
v-if="isOverflowing"
|
|
484
492
|
:id="readMoreId"
|
|
485
493
|
variant="link"
|
|
486
494
|
size="sm"
|
|
487
|
-
:aria-expanded="expanded ? 'true' : 'false'"
|
|
488
|
-
:aria-controls="descriptionId"
|
|
489
|
-
|
|
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']"
|
|
490
501
|
@click="toggleExpanded"
|
|
491
502
|
@keydown="onReadMoreKeydown"
|
|
492
503
|
>
|
|
@@ -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);
|
|
@@ -954,8 +954,9 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
954
954
|
? 'h-full flex-nowrap justify-center gap-0.5'
|
|
955
955
|
: 'h-full flex-nowrap gap-0.5',
|
|
956
956
|
// The design's pill entries: 2.75rem tall, full radius, `surface` on hover and while open, the
|
|
957
|
-
// current page on `surface-strong`.
|
|
958
|
-
|
|
957
|
+
// current page on `surface-strong`. The pill marks the current page, so the package's underline
|
|
958
|
+
// for it is turned off here, as on `trigger`.
|
|
959
|
+
link: 'min-h-11 rounded-full px-3 text-base font-medium hover:bg-surface aria-[current=page]:no-underline aria-[current=page]:bg-surface-strong',
|
|
959
960
|
trigger:
|
|
960
961
|
'min-h-11 rounded-full px-3 text-base font-medium hover:bg-surface aria-expanded:bg-surface data-current:no-underline data-current:bg-surface-strong',
|
|
961
962
|
// The Menu tool: shown below 68.8125rem (the package hides it from `@content`), a labelled tool
|
|
@@ -1481,6 +1481,16 @@ describe('header block (navigation apiId)', () => {
|
|
|
1481
1481
|
expect(other.attributes('aria-current')).toBeUndefined();
|
|
1482
1482
|
});
|
|
1483
1483
|
|
|
1484
|
+
it("marks the current bar link with the pill alone, turning off the package's underline", () => {
|
|
1485
|
+
window.history.pushState({}, '', '/collections/kitchen');
|
|
1486
|
+
const wrapper = mountBlock(resolved.data);
|
|
1487
|
+
const current = wrapper
|
|
1488
|
+
.findAll('a')
|
|
1489
|
+
.find((a) => a.attributes('href') === '/collections/kitchen')!;
|
|
1490
|
+
expect(current.classes()).toContain('aria-[current=page]:bg-surface-strong');
|
|
1491
|
+
expect(current.classes()).toContain('aria-[current=page]:no-underline');
|
|
1492
|
+
});
|
|
1493
|
+
|
|
1484
1494
|
it('marks a current page inside a mega-menu on its link and on the trigger that holds it', async () => {
|
|
1485
1495
|
window.history.pushState({}, '', '/collections/womens-sweaters');
|
|
1486
1496
|
const wrapper = mountBlock(resolved.data, { attachTo: document.body });
|
|
@@ -567,7 +567,22 @@ function capture(origin: string, path: string, width: number, session: boolean):
|
|
|
567
567
|
});
|
|
568
568
|
}
|
|
569
569
|
|
|
570
|
-
/**
|
|
570
|
+
/**
|
|
571
|
+
* A full-page screenshot, after the same normalisation as the DOM.
|
|
572
|
+
*
|
|
573
|
+
* Captured beyond the viewport, as `fullPage: true` does, but only once the viewport already is the
|
|
574
|
+
* document's height and the page has settled at that size. A capture beyond the viewport draws the
|
|
575
|
+
* page afresh, which is what keeps a session's paint history (a block re-rendered from the draft)
|
|
576
|
+
* out of the pixels. But Playwright's `fullPage: true` grows the view in that same capture, and the
|
|
577
|
+
* taller view changes the layer tree: on `/` at 1280 the open search popover needed its own layer
|
|
578
|
+
* only because the page scrolled under it. The frame is drawn before or after that change lands, a
|
|
579
|
+
* race decided on every load, and the popover's suggestion chips sit on a fractional pixel, so
|
|
580
|
+
* their rounded borders came out a step of anti-aliasing apart, about 60 pixels, on whichever page
|
|
581
|
+
* lost the race (WS-1450). Grown first, the capture changes nothing about the page it draws.
|
|
582
|
+
*
|
|
583
|
+
* What `animations: 'disabled'` and `caret: 'hide'` did is done here: a finite animation is
|
|
584
|
+
* finished, an infinite one cancelled, and the caret made transparent, the same on both pages.
|
|
585
|
+
*/
|
|
571
586
|
function screenshot(
|
|
572
587
|
origin: string,
|
|
573
588
|
path: string,
|
|
@@ -577,7 +592,26 @@ function screenshot(
|
|
|
577
592
|
return open(origin, path, width, session, async (page) => {
|
|
578
593
|
await normalise(page, session);
|
|
579
594
|
await settle(page, true);
|
|
580
|
-
|
|
595
|
+
const height = await page.evaluate(() => document.documentElement.scrollHeight);
|
|
596
|
+
await page.setViewportSize({ width, height });
|
|
597
|
+
await settle(page, true);
|
|
598
|
+
await page.addStyleTag({
|
|
599
|
+
content: '*, *::before, *::after { caret-color: transparent !important; }',
|
|
600
|
+
});
|
|
601
|
+
await page.evaluate(async () => {
|
|
602
|
+
for (const animation of document.getAnimations()) {
|
|
603
|
+
if (animation.effect?.getComputedTiming().endTime === Infinity) animation.cancel();
|
|
604
|
+
else animation.finish();
|
|
605
|
+
}
|
|
606
|
+
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
607
|
+
});
|
|
608
|
+
const cdp = await page.context().newCDPSession(page);
|
|
609
|
+
const { data } = await cdp.send('Page.captureScreenshot', {
|
|
610
|
+
format: 'png',
|
|
611
|
+
clip: { x: 0, y: 0, width, height, scale: 1 },
|
|
612
|
+
captureBeyondViewport: true,
|
|
613
|
+
});
|
|
614
|
+
return Buffer.from(data, 'base64');
|
|
581
615
|
});
|
|
582
616
|
}
|
|
583
617
|
|