@monster-orange/den-ui 0.7.0 → 0.7.4
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/README.md +125 -12
- package/bin/den-ui-parity.mjs +2 -0
- package/inventory/nav-inventory.d.ts +44 -1
- package/inventory/nav-inventory.js +295 -3
- package/inventory/reference/den-chromium-1280.json +338 -110
- package/inventory/reference/den-chromium-390.json +271 -39
- package/inventory/reference/den-webkit-1280.json +338 -110
- package/inventory/reference/den-webkit-390.json +271 -39
- package/package.json +1 -1
- package/src/busy.d.ts +1 -0
- package/src/busy.js +23 -14
- package/src/kit.d.ts +2 -0
- package/src/kit.js +2 -0
- package/src/shell-client.js +48 -0
- package/src/shell-html.d.ts +93 -10
- package/src/shell-html.js +292 -41
- package/src/shell.css +310 -16
- package/src/strings.js +44 -0
- package/src/version.js +5 -1
package/README.md
CHANGED
|
@@ -83,6 +83,36 @@ data and HTML slots; it keeps no copy of the kit's markup, CSS or code.
|
|
|
83
83
|
Also `topBarHtml`, `railHtml`, `navItemHtml`, `versionChipHtml`,
|
|
84
84
|
`reportButtonHtml`, `icon(name)` (`src/icons.js`) and `esc`.
|
|
85
85
|
|
|
86
|
+
- **Kind tags (0.7.3).** A pin or a link into another product sets
|
|
87
|
+
`kind` on its nav item: `"project"`, `"den"`, `"service"`, `"hub"`, or
|
|
88
|
+
`{ artifact: "Mock" }` (an artifact pin's own word, in the host's
|
|
89
|
+
language). The kit draws a small uppercase tag at the row's end in the
|
|
90
|
+
scope labels' look, and the tooltip and name are always the kit's:
|
|
91
|
+
"North · Project"; a label that is its kind word reads once ("Hub").
|
|
92
|
+
A badge says what it counts with `what` (`"open"`, `"waiting"`,
|
|
93
|
+
`"down"`, `"running"`) and the kit words it: "North · Den, 3 waiting".
|
|
94
|
+
Hosts pass data, never display text: a `tip`, `title` or `aria-label`
|
|
95
|
+
on an entry with a kind is not used. Any other kind is dropped: the tag
|
|
96
|
+
never names a machine. A project pin may set `icon: { initial: "North" }`
|
|
97
|
+
for its initial in a disc. A pin row gets `aria-keyshortcuts="Delete"`
|
|
98
|
+
from the kit. The nav inventory records each entry's kind and
|
|
99
|
+
`compareNav` reports a `kind` difference. Host text in any rail entry
|
|
100
|
+
(`title`, `aria-label`, `aria-labelledby` or `aria-description` in
|
|
101
|
+
`attrs`, or a badge's `label`) is stamped `data-nav-host-text`:
|
|
102
|
+
`navWarnings` lists it and `compareNav` fails on it (`hostText`).
|
|
103
|
+
`data-*` attrs stay allowed.
|
|
104
|
+
|
|
105
|
+
- **Off entries (0.7.4).** An entry that can't be opened sets `off` to
|
|
106
|
+
why, as data: `"connect"` (not connected yet), `"reconnect"` (its
|
|
107
|
+
sign-in is no longer accepted), `"forbidden"` (not allowed; an admin
|
|
108
|
+
decides), `"unreachable"` (can't be reached right now) or `"config"`
|
|
109
|
+
(its settings have a problem). The kit greys the entry (`.den-off`)
|
|
110
|
+
and words why, in en, es and ja, after the name in the tooltip and
|
|
111
|
+
the accessible name: "Acme Co · Hub, reconnect in Settings"; an entry
|
|
112
|
+
without a kind reads "Docs, can't be reached right now". Any other
|
|
113
|
+
value is dropped (not greyed, no words). The nav inventory records
|
|
114
|
+
each entry's `off` and `compareNav` reports an `off` difference.
|
|
115
|
+
|
|
86
116
|
- **Slots.** The top bar reads: ☰, the brand, `start` (a search, a scope
|
|
87
117
|
menu), then the right group: `end` (status chips), Report, `bell`, the
|
|
88
118
|
version chip, `account`. Report · bell · account keep their place
|
|
@@ -201,8 +231,8 @@ browsers to it through `DEN_PW_WS`:
|
|
|
201
231
|
DEN_PW_WS=ws://localhost:3921/
|
|
202
232
|
|
|
203
233
|
import { chromium } from "playwright"; // 1.61.1, as the image
|
|
204
|
-
import { collectNav, compareNav, formatNavDiffs,
|
|
205
|
-
NAV_THEME } from "@monster-orange/den-ui/inventory";
|
|
234
|
+
import { collectNav, compareNav, formatNavDiffs, navWarnings,
|
|
235
|
+
NAV_BROWSER_IMAGE, NAV_THEME } from "@monster-orange/den-ui/inventory";
|
|
206
236
|
import { readFileSync } from "node:fs";
|
|
207
237
|
import { createRequire } from "node:module";
|
|
208
238
|
|
|
@@ -216,12 +246,17 @@ browsers to it through `DEN_PW_WS`:
|
|
|
216
246
|
const ref = JSON.parse(readFileSync(createRequire(import.meta.url)
|
|
217
247
|
.resolve("@monster-orange/den-ui/inventory/reference/den-chromium-1280.json"),
|
|
218
248
|
"utf-8"));
|
|
249
|
+
const snap = await collectNav(page, { image: NAV_BROWSER_IMAGE,
|
|
250
|
+
theme: NAV_THEME });
|
|
219
251
|
const diffs = compareNav(
|
|
220
|
-
|
|
252
|
+
snap,
|
|
221
253
|
ref,
|
|
222
254
|
{ hostSlots: ["#my-status"] }, // what the host fills itself
|
|
223
255
|
);
|
|
224
256
|
expect(formatNavDiffs(diffs)).toBe(""); // one line per difference
|
|
257
|
+
// 0.7.1: host HTML where the kit's account or search should be.
|
|
258
|
+
// Listed, not failed, until 0.7.2 gives every slot a data path.
|
|
259
|
+
for (const w of navWarnings(snap)) console.warn(w);
|
|
225
260
|
|
|
226
261
|
Pass `theme` as the theme the page really draws in (Den reads it from
|
|
227
262
|
`/api/themes`). On another browser build (a different fingerprint: user
|
|
@@ -258,11 +293,11 @@ env, elements, tokens }`. `env`: `userAgent`, `faces` (the
|
|
|
258
293
|
that much, never by anything else.
|
|
259
294
|
- Host content: the kit stamps `data-nav-role` on what each host fills
|
|
260
295
|
with its own words: each scope crumb (`crumb`) and the separator after
|
|
261
|
-
it (`crumb-sep`), the brand's title (`brand-title`),
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
296
|
+
it (`crumb-sep`), the brand's title (`brand-title`), each rail group
|
|
297
|
+
(`rail-group`), its heading (`group`) and its pages (`page`), and the
|
|
298
|
+
account entry's words (`account-name`). An element with
|
|
299
|
+
`data-nav-name="host"` holds a name that is the host's (not compared).
|
|
300
|
+
The search's placeholder and name are the kit's, and compared. Their count, keys, ids, text and
|
|
266
301
|
width are never compared, on either side. The first of each role is
|
|
267
302
|
compared with the other side's first, and what it holds by key, on
|
|
268
303
|
every computed style and on height. Their size may move what follows by
|
|
@@ -345,6 +380,83 @@ browser test, on the image (Den's real server on the demo distribution,
|
|
|
345
380
|
is `src/kit.d.ts`. A test compiles a consumer against them with
|
|
346
381
|
`--strict`.
|
|
347
382
|
|
|
383
|
+
## 0.7.1
|
|
384
|
+
|
|
385
|
+
The top bar's search sits in the same place in every product (issue 303).
|
|
386
|
+
|
|
387
|
+
- **The account is data.** `accountHtml` and `accountMenuHtml` take
|
|
388
|
+
`{ name?, login, role? }`. The rail's entry is the name over `@login`,
|
|
389
|
+
or `@login` alone when no name is known; never the role. The account
|
|
390
|
+
menu's header is the same, then the role on its own line. The kit adds the `@`. The old `{ label, detail }`
|
|
391
|
+
(and the menu's `{ name, detail }`) still work for this release, drawn
|
|
392
|
+
as given, and the nav inventory fails a host that uses them
|
|
393
|
+
(`legacy`). `accountWho(a)` gives the lines and the shape.
|
|
394
|
+
- **The search never moves.** Its x is a function of the viewport only:
|
|
395
|
+
`searchSlot(width)` gives `{ x, w }` (464 / 304 at 1280, 396 at 1100,
|
|
396
|
+
256 at 960, 82 / 54 on a phone), the same in any host. The left part is
|
|
397
|
+
the smaller of `--den-top-left` (444px) and what the search and the
|
|
398
|
+
right group's reserve (`--den-top-right`, 380px) leave.
|
|
399
|
+
- **The right group is anchored from the right edge.** ◐ at the bar's
|
|
400
|
+
padding, then the version in a fixed slot (`--den-top-version` 96px;
|
|
401
|
+
`--den-top-version-md` 64px up to 1100px; its text ends in "…", the
|
|
402
|
+
whole version in its title), the bell and Report, 4px apart: the same
|
|
403
|
+
x in any host. Report, the bell and ◐ never shrink; the kit sets their
|
|
404
|
+
font and box. The host's chips (`div.den-end`, always drawn, empty
|
|
405
|
+
without chips) take the room left: a chip gives way down to its dot
|
|
406
|
+
and "…", and the kit puts its whole words in its title and name (a
|
|
407
|
+
name or title the host set itself is kept).
|
|
408
|
+
- **Crumbs.** A crumb's label gives way first, then its value ends in
|
|
409
|
+
"…"; before the last crumb a value keeps about 4ch and its ▾.
|
|
410
|
+
- **Checks.** `topSlotDiffs(snap)` checks the search's slot and the
|
|
411
|
+
right group's places at any width (no reference needed); `compareNav`
|
|
412
|
+
runs it too, and fails a crumb whose label shows while its value is
|
|
413
|
+
hidden.
|
|
414
|
+
- **Shape, not only style.** The inventory compares what a kit slot
|
|
415
|
+
draws: the account entry's shape is one of the kit's (`name,login` on
|
|
416
|
+
two lines, `login` or `local` on one: `ACCOUNT_SHAPES`), the old fields
|
|
417
|
+
fail (`legacy`), and the search's box is pinned. `navWarnings(snap)` lists host HTML where the kit's account
|
|
418
|
+
or search should be: a warning in 0.7.1, a failure in 0.7.2.
|
|
419
|
+
|
|
420
|
+
- **Three parts.** The bar is a grid: the left part (`div.den-left`: ☰,
|
|
421
|
+
the brand, and what `start` holds before the search, the crumbs), the
|
|
422
|
+
search, then the chips (the host's `end` in `div.den-end`, then Report,
|
|
423
|
+
the bell, the version and ◐ ▾, pinned to the right edge). The kit finds
|
|
424
|
+
its search in `start` and puts it in its slot; a host's markup is
|
|
425
|
+
unchanged.
|
|
426
|
+
- **Settings** (custom properties on `.den-top`, with their defaults):
|
|
427
|
+
`--den-top-left` (444px), `--den-top-search` (304px), and under 720px
|
|
428
|
+
`--den-top-left-md`
|
|
429
|
+
(200px) and, under 480px, `--den-top-left-sm` (62px: ☰ and the mark).
|
|
430
|
+
At 1280px the search is at x 464, 304 wide; on a phone at x 82.
|
|
431
|
+
- **Giving way.** Long words never move the search. The crumbs give way
|
|
432
|
+
first: each crumb gets an equal share until it is whole, so a short one
|
|
433
|
+
keeps its words and a long one ends in "…"; the last crumb is kept
|
|
434
|
+
whole. Then the install name ends in "…". Under about 1100px the
|
|
435
|
+
host's chips give way (their words end in "…"; the kit's buttons keep
|
|
436
|
+
their size). The chips' column is never narrower than the kit's own
|
|
437
|
+
buttons, so the chips never run under the search: when the bar is too
|
|
438
|
+
narrow for all three parts, the left part gives way and the search
|
|
439
|
+
moves left. A host chip is width 0 growing to its own width
|
|
440
|
+
(`max-width: max-content`): put its words in its last child, a span,
|
|
441
|
+
which ends in "…".
|
|
442
|
+
- **A gap after ⌕**: 8px between the search and the chips, and 8px more
|
|
443
|
+
before the first chip.
|
|
444
|
+
- **The search's words** are the kit's ("Search…", named "Search"; es,
|
|
445
|
+
ja): `searchHtml()` takes no placeholder or label.
|
|
446
|
+
- **Touch** (`pointer: coarse`): every control in the bar takes a 44×44px
|
|
447
|
+
tap (an `::after` hit area, centred; the look is the same), and the
|
|
448
|
+
key hints (⌘K, ⌘⇧F, any `.den-kbd`) hide.
|
|
449
|
+
- **`.den-hit`**: the same 44×44px tap for a host's own buttons and tabs.
|
|
450
|
+
On a touch screen it is `position: relative` plus a transparent,
|
|
451
|
+
centred `::after` at least 44×44px; without touch it does nothing. Its
|
|
452
|
+
look and layout never change. It sits beside `.den-kbd`, the one
|
|
453
|
+
key-cap rule, which hides on a touch screen wherever it is (a palette,
|
|
454
|
+
a button). `den-ui-parity` knows both: a host keeps no copy.
|
|
455
|
+
- **Nav inventory**: the search, Report, the bell, the version chip and ◐
|
|
456
|
+
▾ (`PINNED_CLASSES`) are compared at the reference's x and width: no
|
|
457
|
+
host-content shift excuses moving them. Den's references, and the
|
|
458
|
+
parity fixture and PNGs, were re-taken for this layout.
|
|
459
|
+
|
|
348
460
|
## 0.7.0
|
|
349
461
|
|
|
350
462
|
No new file. One import changes, for hosts that serve a fixed list of kit files:
|
|
@@ -388,8 +500,8 @@ button)`. A crumb left out of the list draws nothing, and no separator
|
|
|
388
500
|
opens on the field. Typing hides the links that don't hold the text, and
|
|
389
501
|
"No match" shows when none do. ↓ goes to the links, Enter takes the first
|
|
390
502
|
one shown, and Esc clears the text, then closes the menu.
|
|
391
|
-
- **Search field**: `searchHtml({
|
|
392
|
-
|
|
503
|
+
- **Search field**: `searchHtml({ id?, shortcut? })`, for the `start`
|
|
504
|
+
slot. It is the kit's placeholder ("Search…") with ⌘K inside the field. A
|
|
393
505
|
click, Enter, ⌘K or Ctrl-K calls `onActivate(via)` (`"click"` or
|
|
394
506
|
`"key"`) and fires `den-ui:search` on the field. The kit owns no
|
|
395
507
|
palette.
|
|
@@ -458,8 +570,9 @@ selected }`, a line under them, the languages `{ id, name, current }`,
|
|
|
458
570
|
32px each way (`shell.css`).
|
|
459
571
|
- **The brand on a phone**: below 480px the brand (its mark alone) never
|
|
460
572
|
shrinks; the host's chips give way.
|
|
461
|
-
- **Search
|
|
462
|
-
the kit's
|
|
573
|
+
- **Search words**: the placeholder ("Search…") and the field's name
|
|
574
|
+
("Search") are the kit's, in en, es and ja. A host can't set them: one
|
|
575
|
+
search in every product.
|
|
463
576
|
- **Filtered menus**: a menu with the filter field is a pop-up holding the
|
|
464
577
|
field, then the `role="menu"` list (`.den-mlist`, id `<menu>-list`),
|
|
465
578
|
then "No match": a menu owns only its items. The field has
|
package/bin/den-ui-parity.mjs
CHANGED
|
@@ -82,6 +82,8 @@ export const COMPONENTS = {
|
|
|
82
82
|
"den-collapse-btn",
|
|
83
83
|
"den-pin-row",
|
|
84
84
|
"den-scrim",
|
|
85
|
+
// 0.7.1: the 44px tap on touch, for any control.
|
|
86
|
+
"den-hit",
|
|
85
87
|
// Not here: den-has-shell, den-rail-collapsed and den-rail-open are
|
|
86
88
|
// the body's state classes, for a page to lay its own content out by.
|
|
87
89
|
],
|
|
@@ -35,6 +35,24 @@ export interface NavElement {
|
|
|
35
35
|
};
|
|
36
36
|
/** Its accessible name is the host's words (data-nav-name="host"). */
|
|
37
37
|
hostName?: boolean;
|
|
38
|
+
/** 0.7.1: a kit-owned slot's content shape (data-nav-shape: its fields). */
|
|
39
|
+
shape?: string;
|
|
40
|
+
/** 0.7.1: drawn from the old free-text fields (data-nav-legacy). */
|
|
41
|
+
legacy?: boolean;
|
|
42
|
+
/** The rail's account entry (data-den-account). */
|
|
43
|
+
account?: boolean;
|
|
44
|
+
/** The account entry's drawn lines. */
|
|
45
|
+
lines?: number;
|
|
46
|
+
/** A crumb whose label shows while its value is hidden. */
|
|
47
|
+
labelOnly?: boolean;
|
|
48
|
+
/** The kit's stamp on what it draws (data-nav-kit). */
|
|
49
|
+
kit?: string;
|
|
50
|
+
/** 0.7.3: a rail entry's kind tag (data-nav-kind): project, den, service, hub, artifact. */
|
|
51
|
+
kind?: string;
|
|
52
|
+
/** 0.7.4: why a rail entry is off (data-nav-off): connect, reconnect, forbidden, unreachable, config. */
|
|
53
|
+
off?: string;
|
|
54
|
+
/** 0.7.3: host text in an entry of the rail (data-nav-host-text): compareNav fails on it. */
|
|
55
|
+
hostText?: string;
|
|
38
56
|
}
|
|
39
57
|
export interface NavTheme {
|
|
40
58
|
id: string;
|
|
@@ -72,7 +90,7 @@ export interface NavCompareOptions {
|
|
|
72
90
|
export interface NavDiff {
|
|
73
91
|
key: string;
|
|
74
92
|
slot: NavSlot | "";
|
|
75
|
-
/** "env" (another browser build), "theme" (another theme), "element", "order", "slot", "role", "tag", "name", "classes", "box.<edge>", "style.<prop>", "version". */
|
|
93
|
+
/** "env" (another browser build), "theme" (another theme), "element", "order", "slot", "role", "tag", "name", "classes", "kind", "off", "hostText", "box.<edge>", "style.<prop>", "version". */
|
|
76
94
|
property: string;
|
|
77
95
|
reference: string | number;
|
|
78
96
|
actual: string | number;
|
|
@@ -87,6 +105,31 @@ export declare const NAV_BROWSER_IMAGE: string;
|
|
|
87
105
|
export declare const FINGERPRINT_TEXT: string;
|
|
88
106
|
/** The theme the reference was taken in ("den" 2.0.1): every parity run uses it. */
|
|
89
107
|
export declare const NAV_THEME: NavTheme;
|
|
108
|
+
/**
|
|
109
|
+
* issue 303: classes of the top bar's pinned elements (the search, Report,
|
|
110
|
+
* the bell, the version chip, ◐ ▾): compared at the reference's x and
|
|
111
|
+
* width, with no host-content allowance.
|
|
112
|
+
*/
|
|
113
|
+
export declare const PINNED_CLASSES: readonly string[];
|
|
114
|
+
/** The search's x and width for a viewport width, the same in any host. */
|
|
115
|
+
export declare function searchSlot(viewportW: number): { x: number; w: number };
|
|
116
|
+
export declare const TOP_RIGHT_MIN: number;
|
|
117
|
+
/** The search away from searchSlot (slot.x, slot.w), at any width. */
|
|
118
|
+
export declare function searchSlotDiffs(
|
|
119
|
+
snap: NavSnapshot,
|
|
120
|
+
tolerance?: number,
|
|
121
|
+
): NavDiff[];
|
|
122
|
+
/** The account entry's shapes the kit draws → their line counts. */
|
|
123
|
+
export declare const ACCOUNT_SHAPES: Record<string, number>;
|
|
124
|
+
/** The version's fixed slot width for a viewport width (0 on a phone). */
|
|
125
|
+
export declare function versionSlotW(viewportW: number): number;
|
|
126
|
+
/** searchSlotDiffs plus Report, bell, version and ◐ anchored from the right. */
|
|
127
|
+
export declare function topSlotDiffs(
|
|
128
|
+
snap: NavSnapshot,
|
|
129
|
+
tolerance?: number,
|
|
130
|
+
): NavDiff[];
|
|
131
|
+
/** 0.7.1: host HTML in the kit's account and search slots; 0.7.3: host text in an entry of the rail. */
|
|
132
|
+
export declare function navWarnings(snap: NavSnapshot): string[];
|
|
90
133
|
export declare function collectNav(
|
|
91
134
|
page: NavPage,
|
|
92
135
|
opts?: { image?: string; theme?: NavTheme },
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* entries after its spacer, .den-rail-grow: Settings, the collapse
|
|
22
22
|
* toggle). For each: its key (below), its parent's key, slot, role, tag,
|
|
23
23
|
* accessible name, classes, box { x, y, w, h } and computed styles
|
|
24
|
-
* (STYLE_PROPS).
|
|
24
|
+
* (STYLE_PROPS), and a rail entry's kind tag (0.7.3: `kind`, compared on
|
|
25
|
+
* every entry both sides draw) and why it is off (0.7.4: `off`, compared
|
|
26
|
+
* the same way).
|
|
25
27
|
*
|
|
26
28
|
* The key names an element the same way on every run: `#id` when it has
|
|
27
29
|
* an id; `[data-nav="x"]` for a rail entry; else its parent's key, " > ",
|
|
@@ -266,6 +268,54 @@ export async function collectNav(page, opts = {}) {
|
|
|
266
268
|
...(el.getAttribute("data-nav-name") === "host"
|
|
267
269
|
? { hostName: true }
|
|
268
270
|
: {}),
|
|
271
|
+
// 0.7.1: a kit-owned slot's content shape (which fields it
|
|
272
|
+
// draws), the old free-text path, and the kit's own stamp.
|
|
273
|
+
// A crumb showing its label with its value hidden (the
|
|
274
|
+
// value must outlast the label).
|
|
275
|
+
...(el.getAttribute("data-nav-role") === "crumb" &&
|
|
276
|
+
(() => {
|
|
277
|
+
const k = el.querySelector(":scope > .den-k");
|
|
278
|
+
const v = el.lastElementChild;
|
|
279
|
+
if (!k || !v || v === k) return false;
|
|
280
|
+
const kw = k.getClientRects().length
|
|
281
|
+
? k.getBoundingClientRect().width
|
|
282
|
+
: 0;
|
|
283
|
+
const vw = v.getClientRects().length
|
|
284
|
+
? v.getBoundingClientRect().width
|
|
285
|
+
: 0;
|
|
286
|
+
return kw > 1 && vw < 8;
|
|
287
|
+
})()
|
|
288
|
+
? { labelOnly: true }
|
|
289
|
+
: {}),
|
|
290
|
+
...(el.hasAttribute("data-nav-shape")
|
|
291
|
+
? { shape: el.getAttribute("data-nav-shape") }
|
|
292
|
+
: {}),
|
|
293
|
+
...(el.hasAttribute("data-nav-legacy") ? { legacy: true } : {}),
|
|
294
|
+
...(el.hasAttribute("data-den-account")
|
|
295
|
+
? {
|
|
296
|
+
account: true,
|
|
297
|
+
lines: el.querySelectorAll(
|
|
298
|
+
".den-acct-n, .den-acct-l, .den-acct-r",
|
|
299
|
+
).length,
|
|
300
|
+
}
|
|
301
|
+
: {}),
|
|
302
|
+
...(el.hasAttribute("data-nav-kit")
|
|
303
|
+
? { kit: el.getAttribute("data-nav-kit") }
|
|
304
|
+
: {}),
|
|
305
|
+
// Issue 307: a rail entry's kind tag (project, den, service,
|
|
306
|
+
// hub, artifact), compared across products.
|
|
307
|
+
...(el.hasAttribute("data-nav-kind")
|
|
308
|
+
? { kind: el.getAttribute("data-nav-kind") }
|
|
309
|
+
: {}),
|
|
310
|
+
// Issue 326: why an entry is off (greyed), compared across
|
|
311
|
+
// products.
|
|
312
|
+
...(el.hasAttribute("data-nav-off")
|
|
313
|
+
? { off: el.getAttribute("data-nav-off") }
|
|
314
|
+
: {}),
|
|
315
|
+
// 0.7.3: host text in an entry of the rail (the kit stamps it).
|
|
316
|
+
...(el.hasAttribute("data-nav-host-text")
|
|
317
|
+
? { hostText: el.getAttribute("data-nav-host-text") }
|
|
318
|
+
: {}),
|
|
269
319
|
});
|
|
270
320
|
}
|
|
271
321
|
if (el.tagName.toLowerCase() === "svg") return mySlot;
|
|
@@ -526,6 +576,148 @@ function lcs(a, b) {
|
|
|
526
576
|
/** The rail's column: its slots stack top to bottom. */
|
|
527
577
|
const COLUMN = ["rail", "foot"];
|
|
528
578
|
|
|
579
|
+
/**
|
|
580
|
+
* issue 303: the top bar's search and the kit's right-side items (Report,
|
|
581
|
+
* the bell, the version chip, ◐ ▾) sit at the reference's x and width,
|
|
582
|
+
* whatever the host's words: a host's crumbs, title or chips never excuse
|
|
583
|
+
* moving them.
|
|
584
|
+
*/
|
|
585
|
+
/**
|
|
586
|
+
* The search's slot for a viewport width (issue 303, "the search never
|
|
587
|
+
* moves"): its x and width are a function of the viewport only, the same
|
|
588
|
+
* in any host. Above 720px: the left part is 444px, less what the bar
|
|
589
|
+
* needs for the search and the kit's right group (TOP_RIGHT_MIN);
|
|
590
|
+
* 481–720px: 200px; up to 480px: 62px. The bar's padding is 12px and
|
|
591
|
+
* its column gap 8px. Mirrors shell.css's .den-top columns (defaults).
|
|
592
|
+
*/
|
|
593
|
+
export const TOP_RIGHT_MIN = 380;
|
|
594
|
+
export function searchSlot(viewportW) {
|
|
595
|
+
const pad = 12;
|
|
596
|
+
const gap = 8;
|
|
597
|
+
if (viewportW > 720) {
|
|
598
|
+
const left = Math.max(
|
|
599
|
+
0,
|
|
600
|
+
Math.min(444, viewportW - 2 * pad - 304 - 2 * gap - TOP_RIGHT_MIN),
|
|
601
|
+
);
|
|
602
|
+
return { x: pad + left + gap, w: 304 };
|
|
603
|
+
}
|
|
604
|
+
return { x: pad + (viewportW < 480 ? 62 : 200) + gap, w: 54 };
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* The search away from its slot (searchSlot for the snapshot's viewport):
|
|
609
|
+
* a difference per edge, at any width, with no reference box needed.
|
|
610
|
+
*/
|
|
611
|
+
export function searchSlotDiffs(snap, tolerance = 2) {
|
|
612
|
+
const out = [];
|
|
613
|
+
const slot = searchSlot(snap.viewport.w);
|
|
614
|
+
for (const e of snap.elements) {
|
|
615
|
+
if (e.slot !== "top" || !e.classes.includes("den-search") || !e.box)
|
|
616
|
+
continue;
|
|
617
|
+
const near = (a, b) => Math.abs(a - b) <= tolerance;
|
|
618
|
+
if (!near(e.box.x, slot.x))
|
|
619
|
+
out.push({
|
|
620
|
+
key: e.key,
|
|
621
|
+
slot: e.slot,
|
|
622
|
+
property: "slot.x",
|
|
623
|
+
reference: String(slot.x),
|
|
624
|
+
actual: String(e.box.x),
|
|
625
|
+
});
|
|
626
|
+
if (!near(e.box.w, slot.w))
|
|
627
|
+
out.push({
|
|
628
|
+
key: e.key,
|
|
629
|
+
slot: e.slot,
|
|
630
|
+
property: "slot.w",
|
|
631
|
+
reference: String(slot.w),
|
|
632
|
+
actual: String(e.box.w),
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
return out;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/** The account entry's shapes the kit draws, and their line counts. */
|
|
639
|
+
export const ACCOUNT_SHAPES = { "name,login": 2, login: 1, local: 1 };
|
|
640
|
+
|
|
641
|
+
/** The version's fixed slot for a viewport width (none on a phone). */
|
|
642
|
+
export function versionSlotW(viewportW) {
|
|
643
|
+
return viewportW > 1100 ? 96 : viewportW > 720 ? 64 : 0;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* The top bar's kit slots at any width: the search (searchSlot), and the
|
|
648
|
+
* right group anchored from the right edge: ◐ at the bar's padding, then
|
|
649
|
+
* the version's fixed slot, the bell and Report, 4px apart. Widths that
|
|
650
|
+
* depend on the engine (Report's words, ◐'s glyph) are taken as drawn;
|
|
651
|
+
* their places follow, the same in any host.
|
|
652
|
+
*/
|
|
653
|
+
export function topSlotDiffs(snap, tolerance = 2) {
|
|
654
|
+
const out = searchSlotDiffs(snap, tolerance);
|
|
655
|
+
const vw = snap.viewport.w;
|
|
656
|
+
if (vw <= 720) return out;
|
|
657
|
+
const near = (a, b) => Math.abs(a - b) <= tolerance;
|
|
658
|
+
const find = (pred) =>
|
|
659
|
+
snap.elements.find((e) => e.slot === "top" && e.box && pred(e));
|
|
660
|
+
const ap = find((e) => e.key === "#appearance-btn");
|
|
661
|
+
const ver = find((e) => e.key === "#version-pill");
|
|
662
|
+
const bell = find((e) => e.key === "#den-bell");
|
|
663
|
+
const rb = find((e) => e.classes.includes("den-rb-top"));
|
|
664
|
+
const push = (e, property, want, got) =>
|
|
665
|
+
out.push({
|
|
666
|
+
key: e.key,
|
|
667
|
+
slot: e.slot,
|
|
668
|
+
property,
|
|
669
|
+
reference: String(Math.round(want * 100) / 100),
|
|
670
|
+
actual: String(Math.round(got * 100) / 100),
|
|
671
|
+
});
|
|
672
|
+
let right = vw - 12;
|
|
673
|
+
for (const e of [ap, ver, bell, rb]) {
|
|
674
|
+
if (!e) continue;
|
|
675
|
+
if (e === ver && !near(e.box.w, versionSlotW(vw)))
|
|
676
|
+
push(e, "slot.w", versionSlotW(vw), e.box.w);
|
|
677
|
+
const wantX = right - e.box.w;
|
|
678
|
+
if (!near(e.box.x, wantX)) push(e, "slot.x", wantX, e.box.x);
|
|
679
|
+
right = e.box.x - 4;
|
|
680
|
+
}
|
|
681
|
+
return out;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* 0.7.1: host HTML in the kit's account and search slots, listed (a
|
|
686
|
+
* warning: 0.7.2 makes every slot data, and then it fails). The kit
|
|
687
|
+
* stamps what it draws: the account entry's data-nav-shape, the search's
|
|
688
|
+
* data-nav-kit.
|
|
689
|
+
*/
|
|
690
|
+
export function navWarnings(snap) {
|
|
691
|
+
const out = [];
|
|
692
|
+
for (const e of snap.elements) {
|
|
693
|
+
if (e.account && e.shape == null)
|
|
694
|
+
out.push(
|
|
695
|
+
`account: ${e.key} is not the kit's (host HTML; draw it with accountHtml)`,
|
|
696
|
+
);
|
|
697
|
+
if (e.hostText)
|
|
698
|
+
out.push(
|
|
699
|
+
`rail entry: ${e.key} has the host's ${e.hostText} (pass data: the kit owns its words)`,
|
|
700
|
+
);
|
|
701
|
+
if (
|
|
702
|
+
e.slot === "top" &&
|
|
703
|
+
e.classes.includes("den-search") &&
|
|
704
|
+
e.kit !== "search"
|
|
705
|
+
)
|
|
706
|
+
out.push(
|
|
707
|
+
`search: ${e.key} is not the kit's (host HTML; draw it with searchHtml)`,
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
return out;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
export const PINNED_CLASSES = [
|
|
714
|
+
"den-search",
|
|
715
|
+
"den-rb-top",
|
|
716
|
+
"den-bell",
|
|
717
|
+
"v-pill",
|
|
718
|
+
"appearance-btn",
|
|
719
|
+
];
|
|
720
|
+
|
|
529
721
|
/**
|
|
530
722
|
* Host content's size, by role: for each role, the sum of its roots'
|
|
531
723
|
* widths (in a row) or heights (in the rail's column), each with its
|
|
@@ -654,6 +846,20 @@ export function compareNav(actual, reference, opts = {}) {
|
|
|
654
846
|
return out;
|
|
655
847
|
};
|
|
656
848
|
const holdsHost = new Set([...holders(reference), ...holders(actual)]);
|
|
849
|
+
// issue 303: the kit's pinned elements, and all they hold, by the
|
|
850
|
+
// reference's tree.
|
|
851
|
+
const pinnedKeys = new Set();
|
|
852
|
+
{
|
|
853
|
+
const isRoot = (e) =>
|
|
854
|
+
e.slot === "top" && e.classes.some((c) => PINNED_CLASSES.includes(c));
|
|
855
|
+
const byKey = new Map(reference.elements.map((e) => [e.key, e]));
|
|
856
|
+
for (const e of reference.elements)
|
|
857
|
+
for (let x = e; x; x = x.parent && byKey.get(x.parent))
|
|
858
|
+
if (isRoot(x)) {
|
|
859
|
+
pinnedKeys.add(e.key);
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
657
863
|
const wantBy = new Map(want.map((e) => [e.key, e]));
|
|
658
864
|
const gotBy = new Map(got.map((e) => [e.key, e]));
|
|
659
865
|
for (const e of want)
|
|
@@ -693,6 +899,47 @@ export function compareNav(actual, reference, opts = {}) {
|
|
|
693
899
|
(k) => (ea.column[k] || 0) - (er.column[k] || 0),
|
|
694
900
|
),
|
|
695
901
|
);
|
|
902
|
+
// Issue 303: the search's slot, from the viewport alone.
|
|
903
|
+
diffs.push(...topSlotDiffs(actual, tol));
|
|
904
|
+
// Issue 307: an entry both sides draw (host content too: its key is its
|
|
905
|
+
// data-nav id) has the same kind tag, or none on both. The tag's look is
|
|
906
|
+
// the "kind" role's, compared below with the first of each role.
|
|
907
|
+
{
|
|
908
|
+
const wantKind = new Map(allWant.map((e) => [e.key, e]));
|
|
909
|
+
for (const g of allGot) {
|
|
910
|
+
const w = wantKind.get(g.key);
|
|
911
|
+
if (w && (w.kind ?? "") !== (g.kind ?? ""))
|
|
912
|
+
add(w, "kind", w.kind ?? "(none)", g.kind ?? "(none)");
|
|
913
|
+
// Issue 326: an entry off on one side is off, for the same reason,
|
|
914
|
+
// on the other.
|
|
915
|
+
if (w && (w.off ?? "") !== (g.off ?? ""))
|
|
916
|
+
add(w, "off", w.off ?? "(none)", g.off ?? "(none)");
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
// A crumb's value outlasts its label: one whose label shows while its
|
|
920
|
+
// value is hidden fails, whatever the reference drew (crumbs are host
|
|
921
|
+
// content, so this is checked on every element drawn).
|
|
922
|
+
// 0.7.3: hosts pass data; the kit owns a rail entry's words. Host text
|
|
923
|
+
// on an entry (a title, aria-label, aria-labelledby, aria-description,
|
|
924
|
+
// a badge's label) fails, whatever the reference drew.
|
|
925
|
+
for (const g of actual.elements)
|
|
926
|
+
if (g.hostText)
|
|
927
|
+
diffs.push({
|
|
928
|
+
key: g.key,
|
|
929
|
+
slot: g.slot,
|
|
930
|
+
property: "hostText",
|
|
931
|
+
reference: "none",
|
|
932
|
+
actual: g.hostText,
|
|
933
|
+
});
|
|
934
|
+
for (const g of actual.elements)
|
|
935
|
+
if (g.labelOnly)
|
|
936
|
+
diffs.push({
|
|
937
|
+
key: g.key,
|
|
938
|
+
slot: g.slot,
|
|
939
|
+
property: "crumb.value",
|
|
940
|
+
reference: "shown",
|
|
941
|
+
actual: "hidden while its label shows",
|
|
942
|
+
});
|
|
696
943
|
for (const w of want) {
|
|
697
944
|
const g = gotBy.get(w.key);
|
|
698
945
|
if (!g) continue;
|
|
@@ -702,6 +949,25 @@ export function compareNav(actual, reference, opts = {}) {
|
|
|
702
949
|
!(p === "name" && (holdsHost.has(w.key) || w.hostName || g.hostName))
|
|
703
950
|
)
|
|
704
951
|
add(w, p, w[p], g[p]);
|
|
952
|
+
// 0.7.1: what a kit-owned slot draws (its fields, its lines), and
|
|
953
|
+
// the old free-text path, flagged.
|
|
954
|
+
// The account entry's shape is the kit's: name over @login (two
|
|
955
|
+
// lines), or @login alone, or the kit's local word; never a role
|
|
956
|
+
// or other fields. Checked on what is drawn, not against the
|
|
957
|
+
// reference's data.
|
|
958
|
+
if (g.account && g.shape != null) {
|
|
959
|
+
const want = ACCOUNT_SHAPES[g.shape];
|
|
960
|
+
if (want == null || (g.lines != null && g.lines !== want))
|
|
961
|
+
add(
|
|
962
|
+
w,
|
|
963
|
+
"shape",
|
|
964
|
+
"name,login | login | local",
|
|
965
|
+
`${g.shape} (${g.lines} lines)`,
|
|
966
|
+
);
|
|
967
|
+
} else if ((w.shape ?? "") !== (g.shape ?? ""))
|
|
968
|
+
add(w, "shape", w.shape, g.shape);
|
|
969
|
+
if (g.legacy && !w.legacy)
|
|
970
|
+
add(w, "legacy", "data", "label/detail (deprecated)");
|
|
705
971
|
const wc = w.classes.join(" ");
|
|
706
972
|
const gc = g.classes.join(" ");
|
|
707
973
|
if (wc !== gc) add(w, "classes", wc, gc);
|
|
@@ -713,7 +979,9 @@ export function compareNav(actual, reference, opts = {}) {
|
|
|
713
979
|
});
|
|
714
980
|
const we = edges(w);
|
|
715
981
|
const ge = edges(g);
|
|
716
|
-
|
|
982
|
+
// The search and the kit's right-side items are pinned (issue 303):
|
|
983
|
+
// nothing the host draws may move them.
|
|
984
|
+
const moves = pinnedKeys.has(w.key) ? [0] : shifts[w.slot] || [0];
|
|
717
985
|
for (const edge of ["left", "top", "right", "bottom"]) {
|
|
718
986
|
const d = ge[edge] - we[edge];
|
|
719
987
|
const ok =
|
|
@@ -746,7 +1014,31 @@ export function compareNav(actual, reference, opts = {}) {
|
|
|
746
1014
|
add(w, "box.height", w.box.h, g.box.h);
|
|
747
1015
|
styles(w, g, []);
|
|
748
1016
|
}
|
|
749
|
-
|
|
1017
|
+
// Name over @login is taller than @login alone: an entry with another
|
|
1018
|
+
// line count than the reference's (both the kit's shapes) moves nothing
|
|
1019
|
+
// else's place; its own height and what it centres are its data.
|
|
1020
|
+
const tall = /^(box\.(height|top|bottom)|style\.height)$/;
|
|
1021
|
+
const acct = actual.elements.find((e) => e.account);
|
|
1022
|
+
const acctRef = acct && reference.elements.find((e) => e.key === acct.key);
|
|
1023
|
+
const acctOwn =
|
|
1024
|
+
acct && acctRef && (acct.lines ?? 0) !== (acctRef.lines ?? 0)
|
|
1025
|
+
? (k) => k === acct.key || k.startsWith(acct.key + " >")
|
|
1026
|
+
: () => false;
|
|
1027
|
+
// Issue 313: a container empty on one side and holding something on
|
|
1028
|
+
// the other is as tall as what it holds; its top, bottom and height are
|
|
1029
|
+
// not compared (its x and width are). Children by the recorded parent.
|
|
1030
|
+
const kids = (snap) => {
|
|
1031
|
+
const n = new Map();
|
|
1032
|
+
for (const e of snap.elements)
|
|
1033
|
+
if (e.parent) n.set(e.parent, (n.get(e.parent) || 0) + 1);
|
|
1034
|
+
return n;
|
|
1035
|
+
};
|
|
1036
|
+
const ka = kids(actual);
|
|
1037
|
+
const kr = kids(reference);
|
|
1038
|
+
const emptyOneSide = (k) => !ka.get(k) !== !kr.get(k);
|
|
1039
|
+
return diffs.filter(
|
|
1040
|
+
(d) => !(tall.test(d.property) && (acctOwn(d.key) || emptyOneSide(d.key))),
|
|
1041
|
+
);
|
|
750
1042
|
function styles(w, g, skip) {
|
|
751
1043
|
for (const p of STYLE_PROPS) {
|
|
752
1044
|
if (skip.includes(p)) continue;
|