mosaic-headless 1.36.0 → 1.36.1
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/SKILL.md +7 -2
- package/assets/templates/platforms/claude-ai.json +1 -1
- package/assets/templates/platforms/claude-code.json +1 -1
- package/assets/templates/platforms/codex-cli.json +1 -1
- package/assets/templates/platforms/copilot.json +1 -1
- package/assets/templates/platforms/gemini-cli.json +1 -1
- package/data/menu-verification.csv +35 -0
- package/package.json +1 -1
- package/references/design-system.md +39 -0
- package/scripts/check-release.mjs +1 -0
- package/tools/mo.py +14 -2
- package/tools/verify_menus.py +421 -0
package/SKILL.md
CHANGED
|
@@ -5,7 +5,7 @@ description: |
|
|
|
5
5
|
license: "MIT"
|
|
6
6
|
metadata:
|
|
7
7
|
author: "moksa (https://moksaweb.com)"
|
|
8
|
-
version: "1.36.
|
|
8
|
+
version: "1.36.1"
|
|
9
9
|
homepage: "https://github.com/Moksa1123/mosaic-headless"
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -148,6 +148,7 @@ them headlessly, measured.
|
|
|
148
148
|
| a loading screen, a cookie bar | a fixed div + `pageLoad` + `hide_at_end`, `data.hidden: true` so it does not block editing | recipe in references/interactions.md |
|
|
149
149
|
| a block repeated on several pages | a component, one definition, overrides per instance | references/design-system.md (components) |
|
|
150
150
|
| a popup, a drawer, a tour | the `modal` / `popover` nodes and their actions | references/dialog-and-triggers.md |
|
|
151
|
+
| a site menu: desktop hover dropdown + phone drawer | `dropdown` / `dropdown-wide` with `openOn: hover`; a `modal` drawer opened by `modalOpen` (there is no off-canvas node) | references/design-system.md (site menus), `tools/verify_menus.py` |
|
|
151
152
|
| remembering a visitor's choice | `setCookie`, `remember` / `forget`, cookie conditions | references/interactions.md |
|
|
152
153
|
| text that comes from the post, the user, a field | a dynamic `{"v": "@VAR(...)"}` value | references/dynamic-content.md |
|
|
153
154
|
| a colour, a size used twice | a collection variable | references/design-system.md |
|
|
@@ -632,6 +633,7 @@ variable's `customProperty` is optional.
|
|
|
632
633
|
| `data/node-type-notes.csv` | 8 | where a sweep outcome is true but misleading on its own, why. Surfaced by `mo.py type` |
|
|
633
634
|
| `data/interaction-verification.csv` | 11 | **probed live** - interaction animation shapes, with negative controls and the stored row beside the payload; the editor's shape binds, the six older candidates and two one-field-apart controls do not |
|
|
634
635
|
| `data/tutorial-recipes-verification.csv` | 16 | **driven live** - Mosaic's four docs tutorials (dark/light switcher, loading overlay, class-driven reveal, loop with hover pause) plus the off-canvas toggle and the reading progress bar, built from `tools/interactions.py` and checked in Chromium |
|
|
636
|
+
| `data/menu-verification.csv` | 34 | **driven live** - every way to build a site menu on one page: hover dropdown and mega panel (mouse, keyboard, touch tablet), and three phone menus (modal drawer, navbar, the tutorial's click panel) on a 390px touch phone - Esc, focus trap and return, aria, scroll lock, a sticky header over the close button |
|
|
635
637
|
| `data/intro-verification.csv` | 8 + 15 | **sampled live** - the entrance sequence over fifteen timestamps on a monotonic clock, plus the eight assertions about it |
|
|
636
638
|
| `data/variants.csv` | 157 | **live** — the variant catalog (Mosaic's built-in element classes); their IDs are what a `variant` record must use, and `class_name` is what the element emits |
|
|
637
639
|
| `data/dynamic-variables.csv` | 75 | source — every `@VAR('ns/name')` expression, by namespace |
|
|
@@ -1003,6 +1005,7 @@ with `tools/prune_unbound.php` (dry run by default) after a batch of rebuilds.
|
|
|
1003
1005
|
| `verify_rwd.py` | does every `_t`/`_m` declaration reach the served stylesheet? |
|
|
1004
1006
|
| `verify_browser.py` | does the **browser** compute what the stylesheet promised - and does the result pass a design audit? |
|
|
1005
1007
|
| `verify_intro.py` | does the page-load animation play, and - the part that matters - does it END and hand the page back? |
|
|
1008
|
+
| `verify_menus.py` | build and drive every site-menu option: does hover hold, do the keyboard and a touch tablet work, does the phone drawer trap focus, close on Esc and stay above a sticky header? |
|
|
1006
1009
|
| `verify_loop.py` | a decoration that runs forever: does it loop (paused-timeline scrub), does it bury text or controls anywhere a reader can rest, does it open by pointer and by keyboard, is it still under reduced motion? |
|
|
1007
1010
|
| `probe_accordion.py` | the accordion family nested as its factory requires, plus the guard's refusal of the bare node - the probe that corrected two rows of this skill's own tables |
|
|
1008
1011
|
| `from_elementor.py` | an Elementor `_elementor_data` tree -> a Mosaic page spec, with every element it cannot convert reported by name and reason (`--strict` to refuse a lossy spec) |
|
|
@@ -1109,7 +1112,9 @@ python tools/sweep_style_properties.py --config sweep.json --page moksa --csv da
|
|
|
1109
1112
|
python tools/sweep_node_properties.py --config sweep.json --page moksa --csv data/node-property-verification.csv
|
|
1110
1113
|
python tools/sweep_style_states.py --config sweep.json --post 20 --slug probe-lab --csv data/style-state-verification.csv
|
|
1111
1114
|
python tools/sweep_interactions.py --config sweep.json --post 20 --slug probe-lab --csv data/interaction-verification.csv
|
|
1112
|
-
python tools/verify_recipes.py --config sweep.json --post <ID of the probe-recipes page> --slug probe-recipes \
|
|
1115
|
+
python tools/verify_recipes.py --config sweep.json --post <ID of the probe-recipes page> --slug probe-recipes \
|
|
1116
|
+
--csv data/tutorial-recipes-verification.csv # --post REBINDS that post's template: check the ID first
|
|
1117
|
+
python tools/verify_menus.py --config sweep.json --post <ID of the menu-lab page> --slug menu-lab --csv data/menu-verification.csv
|
|
1113
1118
|
python tools/verify_loop.py --url https://site/ --window mk-loop --toggle mk-plate-title --panel mk-plate-item \
|
|
1114
1119
|
--parts ukw-sky,ukw-sun,ukw-fuji,ukw-mist,ukw-sea,ukw-crest,ukw-boat,ukw-wave,ukw-claw,ukw-swell,ukw-key,mk-loop-seal \
|
|
1115
1120
|
--period 14000 --csv data/loop-verification.csv
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.36.
|
|
23
|
+
"version": "1.36.1"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "Upload via Settings -> Skills -> Upload. Claude.ai parses SKILL.md frontmatter and surfaces the skill in your library. The extraction tool (extract-block-schema.php) needs a live WP-CLI connection and won't run in the sandbox; use it from a local terminal against your own site instead.",
|
|
26
26
|
"uploadSteps": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.36.
|
|
23
|
+
"version": "1.36.1"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "Auto-loads on session start when SKILL.md frontmatter parses successfully.",
|
|
26
26
|
"verified": true,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.36.
|
|
23
|
+
"version": "1.36.1"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "Confirmed (2026-07-11): Codex CLI natively supports the SKILL.md spec. Place SKILL.md under .codex/skills/<name>/ (project) or ~/.codex/skills/<name>/ (personal) and Codex loads the name+description at session start, then the full body on demand. A parallel, broader convention .agents/skills/ (searched from cwd up to repo root, then ~/.agents/skills/) also exists across multiple tools - if your Codex CLI version prioritizes that path instead, mirror the same SKILL.md there.",
|
|
26
26
|
"verified": true,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.36.
|
|
23
|
+
"version": "1.36.1"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "CHANGED as of 2026-07-11: GitHub Copilot added a proper '.github/skills/' Agent Skills directory (December 2025), alongside the older single-file .github/copilot-instructions.md convention. This config targets the new skills-directory form. If your Copilot version predates this (pre Dec 2025), use the instructions-append fallback instead (see fallback below).",
|
|
26
26
|
"fallback": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.36.
|
|
23
|
+
"version": "1.36.1"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "CHANGED as of 2026-07-11: Gemini CLI now natively supports the same SKILL.md standard as Claude Code and Codex CLI - the same directory-based skill works unmodified. Gemini CLI discovers skills in this precedence order: built-in, extension skills, ~/.gemini/skills/ (personal), .gemini/skills/ (project, shared via version control). At session start Gemini injects each discovered skill's name+description into the system prompt and calls activate_skill when a task matches.",
|
|
26
26
|
"verified": true,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
group,check,result,evidence
|
|
2
|
+
SEO,panel links are <a href> in the server HTML,PASS,"18 links: ml-d1, ml-d2, ml-d3, ml-d4, ml-dd-l1, ml-dd-l2, ml-dd-l3, ml-mega-l1, ml-mega-l2, ml-mega-l3, ml-mega-l4, ml-mega-l5, ml-mega-l6, ml-nb-l1, ml-nb-l2, ml-nb-l3, ml-oc-l1, ml-oc-l2"
|
|
3
|
+
SEO,a dropdown-toggle with a url renders as,INFO,"<a class=""m-dropdown-toggle _l"" id=""ml-dd-toggle"" href=""/components/"" aria-haspopup=""true"" aria-expanded=""false"">"
|
|
4
|
+
DESKTOP,panels closed at rest,PASS,"dd False, mega False"
|
|
5
|
+
DESKTOP,hover opens the dropdown,PASS,"visible after 58 ms, aria-expanded=true"
|
|
6
|
+
DESKTOP,moving down into the panel keeps it open,PASS,still shown 500 ms after entering the panel
|
|
7
|
+
DESKTOP,leaving closes it,PASS,hidden after 159 ms
|
|
8
|
+
DESKTOP,mega panel opens on hover,PASS,x=0 w=1280 (viewport 1280)
|
|
9
|
+
KEYS,Enter on a toggle that has a url,INFO,navigated to https://mosaic.moksaweb.com/components/
|
|
10
|
+
KEYS,ArrowDown opens it,PASS,"shown=True, focus on ml-dd-toggle"
|
|
11
|
+
KEYS,ArrowDown moves into the links,INFO,focus on ml-dd-toggle
|
|
12
|
+
KEYS,Escape closes it and returns focus,PASS,"shown=False, focus on ml-dd-toggle"
|
|
13
|
+
KEYS,Space opens the mega panel (toggle without url),PASS,shown=True aria-expanded=true
|
|
14
|
+
KEYS,Tab from the open toggle goes to,INFO,ml-mega-l1
|
|
15
|
+
TOUCH,first tap on a linked toggle,PASS,"url stays=True, panel shown=True"
|
|
16
|
+
TOUCH,second tap on the same toggle,INFO,stayed; shown=False
|
|
17
|
+
TOUCH,tap opens the mega panel,PASS,
|
|
18
|
+
TOUCH,tap outside closes it,PASS,
|
|
19
|
+
PHONE,"desktop menu hidden, burger shown",PASS,
|
|
20
|
+
DRAWER,burger opens the modal drawer,PASS,"{'open': True, 'role': None, 'label': '主選單', 'modal': 'true', 'tag': 'dialog', 'scroll': 'clip/clip'}"
|
|
21
|
+
DRAWER,focus moves into the drawer,PASS,focus on ml-drawer-win
|
|
22
|
+
DRAWER,close button inside the viewport,PASS,x=314 y=16 w=60 h=40
|
|
23
|
+
DRAWER,close button not covered by the z-1000 sticky header,PASS,element at its centre: self
|
|
24
|
+
DRAWER,Tab stays inside the drawer,PASS,"focus visited ['ml-close', 'ml-d1', 'ml-d2', 'ml-d3', 'ml-d4']"
|
|
25
|
+
DRAWER,Escape closes it,PASS,
|
|
26
|
+
DRAWER,focus returns to the burger,PASS,focus on ml-burger
|
|
27
|
+
DRAWER,the close button closes it,PASS,
|
|
28
|
+
DRAWER,a tap on the overlay closes it,PASS,
|
|
29
|
+
NAVBAR,collapsed below _t,PASS,"{'mode': True, 'tag': 'mosaic-navbar-toggle', 'expanded': 'false', 'controls': None}"
|
|
30
|
+
NAVBAR,toggle opens the links,PASS,"aria-expanded=true, focus on ml-nb-toggle"
|
|
31
|
+
NAVBAR,Escape closes it,PASS,shown=False
|
|
32
|
+
PANEL,click interaction opens the panel,PASS,
|
|
33
|
+
PANEL,its close control is covered by the sticky header,INFO,element at its centre: ml-burger
|
|
34
|
+
PANEL,Escape closes it,FAIL,shown=True
|
|
35
|
+
PANEL,focus moved into it,FAIL,focus on None
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mosaic-headless",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.1",
|
|
4
4
|
"description": "AI-agent skill: build Mosaic Pro (Nextend) WordPress sites by writing the underlying data model directly - 23 custom tables, no visual editor, no DOM. Every node type, style property and node property swept against a live install and asserted on the delivered HTML and compiled CSS. Installs into Claude Code, Cursor, Codex CLI, Gemini CLI, Copilot, Continue, Windsurf and Claude.ai.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wordpress",
|
|
@@ -235,6 +235,45 @@ work; set `openOn:"hover"` if hover is what you want. Style the open look throug
|
|
|
235
235
|
the `___dropdown--opened` state. Menus support one submenu level only - no
|
|
236
236
|
sub-submenus.
|
|
237
237
|
|
|
238
|
+
### Site menus: what each way of building one does, measured
|
|
239
|
+
|
|
240
|
+
There is **no off-canvas node** - not in 1.0.11, not in 1.0.12 (134 types; the
|
|
241
|
+
1.0.12 package searched for offcanvas / off-canvas / drawer), and not on the roadmap.
|
|
242
|
+
Mosaic's "off-canvas menu" is a tutorial (a div and click interactions). The menu
|
|
243
|
+
lab, `tools/verify_menus.py` (`data/menu-verification.csv`, 34 checks on 1.0.12),
|
|
244
|
+
builds every option on one page under a z-index 1000 sticky header and drives it
|
|
245
|
+
with a mouse, the keyboard, a touch tablet and a 390px touch phone:
|
|
246
|
+
|
|
247
|
+
| | desktop `dropdown` / `dropdown-wide`, `openOn: hover` |
|
|
248
|
+
|---|---|
|
|
249
|
+
| hover | opens in ~65 ms (fadeDown), closes ~150 ms after leaving - moving down into the panel does not drop it |
|
|
250
|
+
| keyboard | Space / ArrowDown open it; ArrowDown does NOT move into the links, Tab does; Escape closes and leaves focus on the toggle |
|
|
251
|
+
| toggle with a `url` | renders as `<a href>`; Enter navigates |
|
|
252
|
+
| touch | first tap on a linked toggle opens without navigating; the second tap closes it, still without navigating - so the parent page must be a link INSIDE the panel ("overview" as the first item); a tap outside closes |
|
|
253
|
+
| SEO | every panel link is an `<a href>` in the server HTML, before any script |
|
|
254
|
+
| mega | `dropdown-wide`'s panel spans the viewport (x 0, full width); one submenu level only |
|
|
255
|
+
|
|
256
|
+
| phone menu | Esc | focus | aria | close button vs sticky header |
|
|
257
|
+
|---|---|---|---|---|
|
|
258
|
+
| **(b) Pro `modal` as a drawer** | closes | moves in, Tab is trapped, returns to the opener | `<dialog aria-modal="true" aria-label>` from `accessibleLabel` | top layer: never covered; html/body `overflow: clip` while open |
|
|
259
|
+
| (a) `navbar` below `buttonBreakpoint` | closes | stays on the toggle, no trap | `aria-expanded`, no `aria-controls` | in flow inside the header |
|
|
260
|
+
| (c) div + click odd/even (the tutorial) | **does nothing** | never moves | none | **covered** when its z-index is under the header's |
|
|
261
|
+
|
|
262
|
+
The drawer the lab measures, and the recommendation:
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
modal closedby: everything, accessibleLabel, padding 0 (the browser's dialog padding)
|
|
266
|
+
modal-overlay backgroundColor with alpha
|
|
267
|
+
modal-window position absolute, top 0, right 0, height 100dvh (the NATIVE field), width 86%,
|
|
268
|
+
maxWidth 360px, overflow auto; first child: a button with modalClose
|
|
269
|
+
opener a button with click -> modalOpen, target = the modal's nodeID (a uuid5, so a
|
|
270
|
+
rebuild keeps it)
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
A notch inset: `paddingTop: "max(16px, env(safe-area-inset-top))"` and the `calc()`
|
|
274
|
+
form are dropped by the native field; the same in `customDeclarations` survives. Mosaic's
|
|
275
|
+
viewport meta has no `viewport-fit=cover`, so `env()` is 0 unless a site adds it.
|
|
276
|
+
|
|
238
277
|
`dropdown-wrapper` used to read as a leaf in `placement-rules.csv`. Its
|
|
239
278
|
`canBeParentFor()` returns `true`, but on `DropdownWrapperElementTypeFactoryAbstract`,
|
|
240
279
|
and the extractor never read the abstract files, so it saw no override and wrote
|
|
@@ -130,6 +130,7 @@ const counts = {
|
|
|
130
130
|
"data/style-state-verification.csv": 59,
|
|
131
131
|
"data/interaction-verification.csv": 11,
|
|
132
132
|
"data/tutorial-recipes-verification.csv": 16,
|
|
133
|
+
"data/menu-verification.csv": 34,
|
|
133
134
|
"data/data-class-hierarchy.csv": 131,
|
|
134
135
|
"data/custom-fields-verification.csv": 62,
|
|
135
136
|
"data/dialog-verification.csv": 19,
|
package/tools/mo.py
CHANGED
|
@@ -652,10 +652,22 @@ def cmd_placement(a):
|
|
|
652
652
|
emit(payload, lambda: (
|
|
653
653
|
head("placement: %s" % a.name),
|
|
654
654
|
print("rule : %s" % payload["rule"]),
|
|
655
|
-
|
|
656
|
-
|
|
655
|
+
# canBeParentFor() is checked only on the editor's drop / paste path
|
|
656
|
+
# (PlacementValidatorRaw), never on a REST commit - so "none" with heal
|
|
657
|
+
# children (navbar, dropdown) means: its own children exist, and the
|
|
658
|
+
# client cannot drag anything else into it in the editor.
|
|
659
|
+
print("editor drop-in : %s" % (", ".join(payload["allowed_children"])
|
|
660
|
+
or ("any type" if payload["rule"] == "any"
|
|
661
|
+
else "refused - nothing can be dragged in"))),
|
|
657
662
|
print("heal() inserts : %s" % (", ".join(payload["default_children"])
|
|
658
663
|
or "nothing")),
|
|
664
|
+
payload["rule"] == "none" and print(
|
|
665
|
+
" (editor-only: a REST commit does not check this rule, so\n"
|
|
666
|
+
" children written over REST still render - but a client\n"
|
|
667
|
+
" cannot drag anything into it in the editor. navbar is\n"
|
|
668
|
+
" navbar > navbar-toggle + navigation and dropdown is\n"
|
|
669
|
+
" dropdown > toggle + wrapper by their factories; put\n"
|
|
670
|
+
" anything else INSIDE navigation / the wrapper)"),
|
|
659
671
|
print("named parents : %s" % (", ".join(payload["named_parents"])
|
|
660
672
|
or "none - no type asks for it by name")),
|
|
661
673
|
print("also accepted by: %d permissive containers (rule=any / deny-list)"
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Build every way Mosaic can make a site menu on one page, then drive each one.
|
|
3
|
+
|
|
4
|
+
python tools/verify_menus.py --config c.json --post <ID of menu-lab> --slug menu-lab \
|
|
5
|
+
--csv data/menu-verification.csv
|
|
6
|
+
|
|
7
|
+
Mosaic has no off-canvas node. A desktop menu is a `dropdown` / `dropdown-wide`; a
|
|
8
|
+
phone menu is one of three assemblies, and they differ on exactly what a visitor
|
|
9
|
+
notices - whether Esc closes it, where focus goes, whether a sticky header can sit
|
|
10
|
+
on top of its close button:
|
|
11
|
+
|
|
12
|
+
DESKTOP a sticky header (z-index 1000) with a `dropdown` (openOn hover, its toggle
|
|
13
|
+
carrying a url), a `dropdown-wide` mega panel and a plain `menu-link`.
|
|
14
|
+
Asserted with a mouse, with the keyboard, and on a touch tablet: open and
|
|
15
|
+
close timing, aria-expanded, Esc, what a tap on a linked toggle does, and
|
|
16
|
+
whether the panel links are in the HTML before any script runs.
|
|
17
|
+
DRAWER (b) a Pro `modal` as a right-hand drawer: overlay + window, opened by a
|
|
18
|
+
hamburger's modalOpen, closed by a modalClose button inside, Esc and the
|
|
19
|
+
overlay. Asserted at 390px on a touch phone.
|
|
20
|
+
NAVBAR (a) `navbar` > `navbar-toggle` + `navigation`, collapsing below `_t`.
|
|
21
|
+
PANEL (c) Mosaic's off-canvas tutorial: a fixed div opened by click odd/even
|
|
22
|
+
interactions - z-index 50, under the sticky header, on purpose.
|
|
23
|
+
"""
|
|
24
|
+
from __future__ import annotations
|
|
25
|
+
|
|
26
|
+
import mosaic_config
|
|
27
|
+
import argparse
|
|
28
|
+
import csv
|
|
29
|
+
import os
|
|
30
|
+
import re
|
|
31
|
+
import sys
|
|
32
|
+
import time
|
|
33
|
+
import urllib.request
|
|
34
|
+
import uuid
|
|
35
|
+
|
|
36
|
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
37
|
+
import interactions as ix # noqa: E402
|
|
38
|
+
from build_page import Surface # noqa: E402
|
|
39
|
+
from build_site import bind_page, build_page_document, build_shell # noqa: E402
|
|
40
|
+
from sweep_node_types import Client # noqa: E402
|
|
41
|
+
|
|
42
|
+
NS = uuid.UUID("6d6f7361-6963-4865-6164-6c657373ff0c")
|
|
43
|
+
INK, PAPER = "rgb(22, 24, 28)", "rgb(250, 250, 247)"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def det(name):
|
|
47
|
+
return str(uuid.uuid5(NS, name))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def link(attr, label, url, **style):
|
|
51
|
+
st = {"paddingTop": "10px", "paddingBottom": "10px", "paddingLeft": "14px",
|
|
52
|
+
"paddingRight": "14px", "color": INK, "fontSize": "15px"}
|
|
53
|
+
st.update(style)
|
|
54
|
+
return {"type": "menu-link", "data": {"attrID": attr, "url": url},
|
|
55
|
+
"style": {"&": {"_": st}, "focus-visible": {"_": {
|
|
56
|
+
"customDeclarations": "outline:2px solid rgb(9,99,199);outline-offset:2px;"}}},
|
|
57
|
+
"children": [{"type": "wysiwyg-text", "data": {"text": label}}]}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def button(attr, label, actions, **style):
|
|
61
|
+
st = {"paddingTop": "10px", "paddingBottom": "10px", "paddingLeft": "14px",
|
|
62
|
+
"paddingRight": "14px", "backgroundColor": INK, "color": PAPER,
|
|
63
|
+
"cursor": "pointer"}
|
|
64
|
+
st.update(style)
|
|
65
|
+
return {"type": "button", "data": {"attrID": attr, "interactions": [ix.on("click", actions)]},
|
|
66
|
+
"style": {"&": {"_": st}},
|
|
67
|
+
"children": [{"type": "wysiwyg-text", "data": {"text": label}}]}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def act(kind, node_id):
|
|
71
|
+
return {"type": kind, "uuid": str(uuid.uuid4()),
|
|
72
|
+
"settings": {"target": {"type": "element", "uuid": node_id}}}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
PANEL = {"backgroundColor": PAPER, "paddingTop": "8px", "paddingBottom": "8px",
|
|
76
|
+
"minWidth": "220px",
|
|
77
|
+
"customDeclarations": "border:1px solid rgb(22,24,28);box-shadow:0 18px 40px rgba(22,24,28,.16);"}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def tree():
|
|
81
|
+
drawer, panel = det("drawer"), det("panel")
|
|
82
|
+
desktop = {"type": "div", "data": {"attrID": "ml-desk"},
|
|
83
|
+
"style": {"&": {"_": {"display": "flex", "alignItems": "center", "columnGap": "8px"},
|
|
84
|
+
"_t": {"display": "none"}}},
|
|
85
|
+
"children": [
|
|
86
|
+
{"type": "dropdown", "data": {"attrID": "ml-dd", "openOn": "hover", "animation": "fadeDown"},
|
|
87
|
+
"style": {"&": {"_": {"position": "relative"}}},
|
|
88
|
+
"children": [
|
|
89
|
+
{"type": "dropdown-toggle", "data": {"attrID": "ml-dd-toggle", "url": "/components/"},
|
|
90
|
+
"style": {"&": {"_": {"paddingTop": "10px", "paddingBottom": "10px",
|
|
91
|
+
"paddingLeft": "14px", "paddingRight": "14px",
|
|
92
|
+
"color": INK, "cursor": "pointer"}}},
|
|
93
|
+
"children": [{"type": "wysiwyg-text", "data": {"text": "服務"}}]},
|
|
94
|
+
{"type": "dropdown-wrapper", "data": {"attrID": "ml-dd-menu"},
|
|
95
|
+
"style": {"&": {"_": dict(PANEL, flexDirection="column")}},
|
|
96
|
+
"children": [link("ml-dd-l%d" % i, t, u) for i, (t, u) in enumerate(
|
|
97
|
+
[("服務總覽", "/components/"), ("表單", "/forms/"), ("輪播", "/sliders/")], 1)]}]},
|
|
98
|
+
{"type": "dropdown-wide", "data": {"attrID": "ml-mega", "openOn": "hover", "animation": "fadeDown"},
|
|
99
|
+
"children": [
|
|
100
|
+
{"type": "dropdown-toggle", "data": {"attrID": "ml-mega-toggle"},
|
|
101
|
+
"style": {"&": {"_": {"paddingTop": "10px", "paddingBottom": "10px",
|
|
102
|
+
"paddingLeft": "14px", "paddingRight": "14px",
|
|
103
|
+
"color": INK, "cursor": "pointer"}}},
|
|
104
|
+
"children": [{"type": "wysiwyg-text", "data": {"text": "全部功能"}}]},
|
|
105
|
+
{"type": "dropdown-wrapper-wide", "data": {"attrID": "ml-mega-menu"},
|
|
106
|
+
"style": {"&": {"_": dict(PANEL, display="grid", gridCols="repeat(3, 1fr)",
|
|
107
|
+
paddingLeft="24px", paddingRight="24px")}},
|
|
108
|
+
"children": [link("ml-mega-l%d" % i, t, u) for i, (t, u) in enumerate(
|
|
109
|
+
[("元件牆", "/components/"), ("表單", "/forms/"), ("內容", "/content/"),
|
|
110
|
+
("輪播", "/sliders/"), ("彈出層", "/popovers/"), ("對話框", "/dialogs/")], 1)]}]},
|
|
111
|
+
link("ml-contact", "聯絡", "/forms/")]}
|
|
112
|
+
|
|
113
|
+
header = {"type": "div", "data": {"attrID": "ml-header"},
|
|
114
|
+
"style": {"&": {"_": {"position": "sticky", "top": "0px", "zIndex": "1000",
|
|
115
|
+
"height": "64px", "display": "flex", "alignItems": "center",
|
|
116
|
+
"justifyContent": "space-between",
|
|
117
|
+
"paddingLeft": "20px", "paddingRight": "20px",
|
|
118
|
+
"backgroundColor": PAPER,
|
|
119
|
+
"customDeclarations": "border-bottom:1px solid rgb(22,24,28);"}}},
|
|
120
|
+
"children": [
|
|
121
|
+
{"type": "text", "data": {"attrID": "ml-logo", "tagName": "p"}, "text": "MENU LAB"},
|
|
122
|
+
desktop,
|
|
123
|
+
{"type": "div", "data": {"attrID": "ml-mob"},
|
|
124
|
+
"style": {"&": {"_": {"display": "none"}, "_t": {"display": "flex", "columnGap": "8px"}}},
|
|
125
|
+
"children": [
|
|
126
|
+
button("ml-burger", "選單", [act("modalOpen", drawer)]),
|
|
127
|
+
{"type": "div", "data": {"attrID": "ml-oc-btn", "interactions": [_panel_toggle(panel)]},
|
|
128
|
+
"style": {"&": {"_": {"paddingTop": "10px", "paddingBottom": "10px",
|
|
129
|
+
"paddingLeft": "14px", "paddingRight": "14px",
|
|
130
|
+
"cursor": "pointer",
|
|
131
|
+
"customDeclarations": "border:1px solid rgb(22,24,28);"}}},
|
|
132
|
+
"text": "面板"}]}]}
|
|
133
|
+
|
|
134
|
+
modal = {"type": "modal", "nodeID": drawer,
|
|
135
|
+
"data": {"attrID": "ml-drawer", "closedby": "everything", "accessibleLabel": "主選單"},
|
|
136
|
+
"style": {"&": {"_": {"paddingTop": "0px", "paddingBottom": "0px",
|
|
137
|
+
"paddingLeft": "0px", "paddingRight": "0px"}}},
|
|
138
|
+
"children": [
|
|
139
|
+
{"type": "modal-overlay", "data": {"attrID": "ml-drawer-ov"},
|
|
140
|
+
"style": {"&": {"_": {"backgroundColor": "rgba(22, 24, 28, 0.5)"}}}},
|
|
141
|
+
{"type": "modal-window", "data": {"attrID": "ml-drawer-win"},
|
|
142
|
+
"style": {"&": {"_": {"position": "absolute", "top": "0px", "right": "0px",
|
|
143
|
+
"height": "100dvh", "width": "86%", "maxWidth": "360px",
|
|
144
|
+
"backgroundColor": PAPER, "overflow": "auto",
|
|
145
|
+
"display": "flex", "flexDirection": "column",
|
|
146
|
+
"paddingTop": "16px", "paddingLeft": "16px",
|
|
147
|
+
"paddingRight": "16px", "paddingBottom": "24px"}}},
|
|
148
|
+
"children": [
|
|
149
|
+
button("ml-close", "關閉", [act("modalClose", drawer)], alignSelf="flex-end"),
|
|
150
|
+
link("ml-d1", "服務總覽", "/components/"), link("ml-d2", "表單", "/forms/"),
|
|
151
|
+
link("ml-d3", "輪播", "/sliders/"), link("ml-d4", "聯絡", "/forms/")]}]}
|
|
152
|
+
|
|
153
|
+
navbar = {"type": "navbar", "data": {"attrID": "ml-nb", "buttonBreakpoint": "_t",
|
|
154
|
+
"animation": "fadeDown", "disableScroll": "1"},
|
|
155
|
+
"style": {"&": {"_": {"display": "flex", "alignItems": "center",
|
|
156
|
+
"justifyContent": "space-between", "paddingTop": "12px",
|
|
157
|
+
"paddingBottom": "12px", "paddingLeft": "20px", "paddingRight": "20px",
|
|
158
|
+
"customDeclarations": "border-bottom:1px solid rgb(22,24,28);"}}},
|
|
159
|
+
"children": [
|
|
160
|
+
{"type": "navbar-toggle", "data": {"attrID": "ml-nb-toggle"},
|
|
161
|
+
"style": {"&": {"_": {"paddingTop": "10px", "paddingBottom": "10px",
|
|
162
|
+
"paddingLeft": "14px", "paddingRight": "14px", "cursor": "pointer",
|
|
163
|
+
"customDeclarations": "border:1px solid rgb(22,24,28);"}}},
|
|
164
|
+
"children": [{"type": "wysiwyg-text", "data": {"text": "NAVBAR"}}]},
|
|
165
|
+
{"type": "navigation", "data": {"attrID": "ml-nb-nav"},
|
|
166
|
+
"style": {"&": {"_": {"display": "flex", "columnGap": "8px"}}},
|
|
167
|
+
"children": [link("ml-nb-l1", "服務", "/components/"), link("ml-nb-l2", "表單", "/forms/"),
|
|
168
|
+
link("ml-nb-l3", "聯絡", "/forms/")]}]}
|
|
169
|
+
|
|
170
|
+
oc_panel = {"type": "div", "nodeID": panel, "data": {"attrID": "ml-oc-panel"},
|
|
171
|
+
"style": {"&": {"_": {"display": "none", "position": "fixed", "zIndex": "50",
|
|
172
|
+
"top": "0px", "right": "0px", "bottom": "0px", "width": "300px",
|
|
173
|
+
"flexDirection": "column", "paddingTop": "16px",
|
|
174
|
+
"paddingLeft": "16px", "paddingRight": "16px",
|
|
175
|
+
"backgroundColor": "rgb(240, 240, 235)"}}},
|
|
176
|
+
"children": [
|
|
177
|
+
{"type": "div", "data": {"attrID": "ml-oc-close", "interactions": [_panel_toggle(panel)]},
|
|
178
|
+
"style": {"&": {"_": {"paddingTop": "10px", "paddingBottom": "10px", "cursor": "pointer"}}},
|
|
179
|
+
"text": "關閉面板"},
|
|
180
|
+
link("ml-oc-l1", "服務總覽", "/components/"), link("ml-oc-l2", "表單", "/forms/")]}
|
|
181
|
+
|
|
182
|
+
return {"type": "div", "data": {"attrID": "ml-root"},
|
|
183
|
+
"children": [header, modal, navbar, oc_panel,
|
|
184
|
+
{"type": "div", "data": {"attrID": "ml-body"},
|
|
185
|
+
"style": {"&": {"_": {"height": "2400px", "paddingTop": "40px",
|
|
186
|
+
"paddingLeft": "20px", "paddingRight": "20px"}}},
|
|
187
|
+
"children": [{"type": "text", "data": {"attrID": "ml-copy", "tagName": "p"},
|
|
188
|
+
"text": "選單實驗頁:桌機 hover 下拉、mega 下拉、modal 抽屜、navbar 收合、互動面板。"},
|
|
189
|
+
# which spelling of a notch inset survives the style validator
|
|
190
|
+
{"type": "div", "data": {"attrID": "ml-safe-native"},
|
|
191
|
+
"style": {"&": {"_": {"paddingTop": "max(16px, env(safe-area-inset-top))"}}}},
|
|
192
|
+
{"type": "div", "data": {"attrID": "ml-safe-custom"},
|
|
193
|
+
"style": {"&": {"_": {"customDeclarations":
|
|
194
|
+
"padding-top:max(16px, env(safe-area-inset-top));"}}}},
|
|
195
|
+
{"type": "div", "data": {"attrID": "ml-safe-calc"},
|
|
196
|
+
"style": {"&": {"_": {"paddingTop": "calc(16px + env(safe-area-inset-top))"}}}}]}]}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def _panel_toggle(panel):
|
|
200
|
+
t = ix.on("click", [ix.display(start="flex", target=ix.element(panel)),
|
|
201
|
+
ix.tween([("translateX", "100%", "0%")], 300, target=ix.element(panel))],
|
|
202
|
+
slot="odd")
|
|
203
|
+
return ix.add_slot(t, "even", [ix.tween([("translateX", "0%", "100%")], 300, target=ix.element(panel)),
|
|
204
|
+
ix.display(end="none", duration=300, target=ix.element(panel))])
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def build(client, cfg, post, slug):
|
|
208
|
+
surface = Surface()
|
|
209
|
+
master, _h, _f = build_shell(client, cfg, {"pages": [], "shell": {}}, surface)
|
|
210
|
+
template = bind_page(client, cfg, master, slug, post)
|
|
211
|
+
build_page_document(client, cfg, master, template, tree(), surface)
|
|
212
|
+
return master
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
# ---------------------------------------------------------------- the drive
|
|
216
|
+
|
|
217
|
+
INFO = """id => { const e = document.getElementById(id); if (!e) return null;
|
|
218
|
+
const r = e.getBoundingClientRect(), s = getComputedStyle(e);
|
|
219
|
+
return {shown: r.width > 2 && r.height > 2 && s.display !== 'none' && s.visibility !== 'hidden'
|
|
220
|
+
&& parseFloat(s.opacity) > 0.05,
|
|
221
|
+
x: r.x, y: r.y, w: r.width, h: r.height, tag: e.tagName.toLowerCase(),
|
|
222
|
+
expanded: e.getAttribute('aria-expanded')}; }"""
|
|
223
|
+
ON_TOP = """id => { const e = document.getElementById(id); const r = e.getBoundingClientRect();
|
|
224
|
+
const t = document.elementFromPoint(r.x + r.width / 2, r.y + Math.min(r.height / 2, 12));
|
|
225
|
+
return t ? (e.contains(t) ? 'self' : (t.id || t.className || t.tagName)) : 'nothing'; }"""
|
|
226
|
+
ACTIVE = """() => { let a = document.activeElement; while (a && !a.id) a = a.parentElement;
|
|
227
|
+
return a ? a.id : null; }"""
|
|
228
|
+
IN_DRAWER = """() => !!document.activeElement && !!document.activeElement.closest('#ml-drawer')"""
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def drive(url, rows):
|
|
232
|
+
from playwright.sync_api import sync_playwright
|
|
233
|
+
|
|
234
|
+
def row(group, check, ok, evidence):
|
|
235
|
+
rows.append([group, check, "PASS" if ok else ("INFO" if ok is None else "FAIL"), evidence])
|
|
236
|
+
print(" %-8s %-46s %-4s %s" % (group, check, rows[-1][2], evidence))
|
|
237
|
+
|
|
238
|
+
bust = lambda: "%s?_v=%d" % (url, time.time() * 1000) # noqa: E731
|
|
239
|
+
|
|
240
|
+
# the HTML before any script: are the panel links crawlable?
|
|
241
|
+
raw = urllib.request.urlopen(urllib.request.Request(bust(), headers={"User-Agent": "Mozilla/5.0"})).read().decode("utf-8")
|
|
242
|
+
hrefs = re.findall(r'id="(ml-(?:dd|mega|d|nb|oc)-?l?\d+)"[^>]*href="([^"]*)"|href="([^"]*)"[^>]*id="(ml-(?:dd|mega|d|nb|oc)-?l?\d+)"', raw)
|
|
243
|
+
ids = sorted({a or d for a, _b, _c, d in hrefs})
|
|
244
|
+
row("SEO", "panel links are <a href> in the server HTML", len(ids) >= 15,
|
|
245
|
+
"%d links: %s" % (len(ids), ", ".join(ids)))
|
|
246
|
+
dt = re.search(r'<[a-z-]+[^>]*id="ml-dd-toggle"[^>]*>', raw)
|
|
247
|
+
row("SEO", "a dropdown-toggle with a url renders as", None, dt.group(0)[:160] if dt else "absent")
|
|
248
|
+
|
|
249
|
+
with sync_playwright() as pw:
|
|
250
|
+
b = pw.chromium.launch()
|
|
251
|
+
|
|
252
|
+
# ---------------- desktop, mouse
|
|
253
|
+
p = b.new_page(viewport={"width": 1280, "height": 800})
|
|
254
|
+
p.goto(bust(), wait_until="networkidle")
|
|
255
|
+
info = lambda i: p.evaluate(INFO, i) # noqa: E731
|
|
256
|
+
row("DESKTOP", "panels closed at rest", not info("ml-dd-menu")["shown"] and not info("ml-mega-menu")["shown"],
|
|
257
|
+
"dd %s, mega %s" % (info("ml-dd-menu")["shown"], info("ml-mega-menu")["shown"]))
|
|
258
|
+
t = info("ml-dd-toggle")
|
|
259
|
+
p.mouse.move(t["x"] + t["w"] / 2, t["y"] + t["h"] / 2)
|
|
260
|
+
t0 = time.time(); opened_at = None
|
|
261
|
+
while time.time() - t0 < 2:
|
|
262
|
+
if info("ml-dd-menu")["shown"]:
|
|
263
|
+
opened_at = time.time() - t0; break
|
|
264
|
+
p.wait_for_timeout(20)
|
|
265
|
+
row("DESKTOP", "hover opens the dropdown", opened_at is not None,
|
|
266
|
+
"visible after %s ms, aria-expanded=%s" % (int(opened_at * 1000) if opened_at else "-",
|
|
267
|
+
info("ml-dd-toggle")["expanded"]))
|
|
268
|
+
m = info("ml-dd-menu")
|
|
269
|
+
p.mouse.move(m["x"] + 30, m["y"] + m["h"] / 2, steps=8)
|
|
270
|
+
p.wait_for_timeout(500)
|
|
271
|
+
row("DESKTOP", "moving down into the panel keeps it open", info("ml-dd-menu")["shown"],
|
|
272
|
+
"still shown 500 ms after entering the panel")
|
|
273
|
+
p.mouse.move(700, 600)
|
|
274
|
+
t0 = time.time(); closed_at = None
|
|
275
|
+
while time.time() - t0 < 3:
|
|
276
|
+
if not info("ml-dd-menu")["shown"]:
|
|
277
|
+
closed_at = time.time() - t0; break
|
|
278
|
+
p.wait_for_timeout(20)
|
|
279
|
+
row("DESKTOP", "leaving closes it", closed_at is not None,
|
|
280
|
+
"hidden after %s ms" % (int(closed_at * 1000) if closed_at else "-"))
|
|
281
|
+
g = info("ml-mega-toggle")
|
|
282
|
+
p.mouse.move(g["x"] + g["w"] / 2, g["y"] + g["h"] / 2)
|
|
283
|
+
p.wait_for_timeout(600)
|
|
284
|
+
mg = info("ml-mega-menu")
|
|
285
|
+
row("DESKTOP", "mega panel opens on hover", mg["shown"],
|
|
286
|
+
"x=%d w=%d (viewport 1280)" % (mg["x"], mg["w"]))
|
|
287
|
+
p.mouse.move(700, 700); p.wait_for_timeout(800)
|
|
288
|
+
|
|
289
|
+
# keyboard
|
|
290
|
+
p.goto(bust(), wait_until="networkidle")
|
|
291
|
+
p.focus("#ml-dd-toggle")
|
|
292
|
+
p.keyboard.press("Enter")
|
|
293
|
+
p.wait_for_timeout(1200)
|
|
294
|
+
p.wait_for_load_state("domcontentloaded")
|
|
295
|
+
row("KEYS", "Enter on a toggle that has a url", None,
|
|
296
|
+
"navigated to %s" % p.url if "menu-lab" not in p.url
|
|
297
|
+
else "opened=%s" % info("ml-dd-menu")["shown"])
|
|
298
|
+
if "menu-lab" not in p.url:
|
|
299
|
+
p.goto(bust(), wait_until="networkidle")
|
|
300
|
+
p.focus("#ml-dd-toggle")
|
|
301
|
+
p.keyboard.press("ArrowDown"); p.wait_for_timeout(500)
|
|
302
|
+
row("KEYS", "ArrowDown opens it", info("ml-dd-menu")["shown"],
|
|
303
|
+
"shown=%s, focus on %s" % (info("ml-dd-menu")["shown"], p.evaluate(ACTIVE)))
|
|
304
|
+
p.keyboard.press("ArrowDown"); p.wait_for_timeout(150)
|
|
305
|
+
row("KEYS", "ArrowDown moves into the links", None, "focus on %s" % p.evaluate(ACTIVE))
|
|
306
|
+
p.keyboard.press("Escape"); p.wait_for_timeout(500)
|
|
307
|
+
row("KEYS", "Escape closes it and returns focus", not info("ml-dd-menu")["shown"],
|
|
308
|
+
"shown=%s, focus on %s" % (info("ml-dd-menu")["shown"], p.evaluate(ACTIVE)))
|
|
309
|
+
p.focus("#ml-mega-toggle"); p.keyboard.press("Space"); p.wait_for_timeout(500)
|
|
310
|
+
row("KEYS", "Space opens the mega panel (toggle without url)", info("ml-mega-menu")["shown"],
|
|
311
|
+
"shown=%s aria-expanded=%s" % (info("ml-mega-menu")["shown"], info("ml-mega-toggle")["expanded"]))
|
|
312
|
+
p.keyboard.press("Tab"); p.wait_for_timeout(150)
|
|
313
|
+
row("KEYS", "Tab from the open toggle goes to", None, p.evaluate(ACTIVE))
|
|
314
|
+
p.close()
|
|
315
|
+
|
|
316
|
+
# ---------------- touch tablet at desktop width
|
|
317
|
+
ctx = b.new_context(viewport={"width": 1366, "height": 1024}, has_touch=True, is_mobile=True)
|
|
318
|
+
p = ctx.new_page(); p.goto(bust(), wait_until="networkidle")
|
|
319
|
+
info = lambda i: p.evaluate(INFO, i) # noqa: E731
|
|
320
|
+
p.tap("#ml-dd-toggle"); p.wait_for_timeout(600)
|
|
321
|
+
row("TOUCH", "first tap on a linked toggle", "menu-lab" in p.url and info("ml-dd-menu")["shown"],
|
|
322
|
+
"url stays=%s, panel shown=%s" % ("menu-lab" in p.url, info("ml-dd-menu")["shown"] if "menu-lab" in p.url else "-"))
|
|
323
|
+
if "menu-lab" in p.url:
|
|
324
|
+
p.tap("#ml-dd-toggle"); p.wait_for_timeout(900)
|
|
325
|
+
row("TOUCH", "second tap on the same toggle", None,
|
|
326
|
+
"navigated to %s" % p.url if "menu-lab" not in p.url else "stayed; shown=%s" % info("ml-dd-menu")["shown"])
|
|
327
|
+
p.goto(bust(), wait_until="networkidle")
|
|
328
|
+
p.tap("#ml-mega-toggle"); p.wait_for_timeout(600)
|
|
329
|
+
row("TOUCH", "tap opens the mega panel", info("ml-mega-menu")["shown"], "")
|
|
330
|
+
p.tap("#ml-copy"); p.wait_for_timeout(600)
|
|
331
|
+
row("TOUCH", "tap outside closes it", not info("ml-mega-menu")["shown"], "")
|
|
332
|
+
ctx.close()
|
|
333
|
+
|
|
334
|
+
# ---------------- phone
|
|
335
|
+
ctx = b.new_context(viewport={"width": 390, "height": 844}, has_touch=True, is_mobile=True)
|
|
336
|
+
p = ctx.new_page(); p.goto(bust(), wait_until="networkidle")
|
|
337
|
+
info = lambda i: p.evaluate(INFO, i) # noqa: E731
|
|
338
|
+
row("PHONE", "desktop menu hidden, burger shown", not info("ml-desk")["shown"] and info("ml-burger")["shown"], "")
|
|
339
|
+
p.tap("#ml-burger"); p.wait_for_timeout(700)
|
|
340
|
+
d = p.evaluate("""() => { const m = document.getElementById('ml-drawer');
|
|
341
|
+
return {open: m.matches(':popover-open') || m.open, role: m.getAttribute('role'),
|
|
342
|
+
label: m.getAttribute('aria-label'), modal: m.getAttribute('aria-modal'),
|
|
343
|
+
tag: m.tagName.toLowerCase(), scroll: getComputedStyle(document.documentElement).overflow
|
|
344
|
+
+ '/' + getComputedStyle(document.body).overflow}; }""")
|
|
345
|
+
row("DRAWER", "burger opens the modal drawer", d["open"], str(d))
|
|
346
|
+
row("DRAWER", "focus moves into the drawer", p.evaluate(IN_DRAWER), "focus on %s" % p.evaluate(ACTIVE))
|
|
347
|
+
c = info("ml-close")
|
|
348
|
+
row("DRAWER", "close button inside the viewport", c["shown"] and c["y"] >= 0 and c["x"] + c["w"] <= 390,
|
|
349
|
+
"x=%d y=%d w=%d h=%d" % (c["x"], c["y"], c["w"], c["h"]))
|
|
350
|
+
row("DRAWER", "close button not covered by the z-1000 sticky header", p.evaluate(ON_TOP, "ml-close") == "self",
|
|
351
|
+
"element at its centre: %s" % p.evaluate(ON_TOP, "ml-close"))
|
|
352
|
+
seen = set()
|
|
353
|
+
for _ in range(8):
|
|
354
|
+
p.keyboard.press("Tab"); seen.add(p.evaluate(ACTIVE))
|
|
355
|
+
row("DRAWER", "Tab stays inside the drawer", all((s or "").startswith(("ml-d", "ml-close")) for s in seen),
|
|
356
|
+
"focus visited %s" % sorted(s or "-" for s in seen))
|
|
357
|
+
p.keyboard.press("Escape"); p.wait_for_timeout(600)
|
|
358
|
+
closed = not p.evaluate("() => document.getElementById('ml-drawer').matches(':popover-open')")
|
|
359
|
+
row("DRAWER", "Escape closes it", closed, "")
|
|
360
|
+
row("DRAWER", "focus returns to the burger", p.evaluate(ACTIVE) == "ml-burger", "focus on %s" % p.evaluate(ACTIVE))
|
|
361
|
+
p.tap("#ml-burger"); p.wait_for_timeout(700)
|
|
362
|
+
p.tap("#ml-close"); p.wait_for_timeout(700)
|
|
363
|
+
row("DRAWER", "the close button closes it",
|
|
364
|
+
not p.evaluate("() => document.getElementById('ml-drawer').matches(':popover-open')"), "")
|
|
365
|
+
p.tap("#ml-burger"); p.wait_for_timeout(700)
|
|
366
|
+
p.mouse.click(20, 400); p.wait_for_timeout(700)
|
|
367
|
+
row("DRAWER", "a tap on the overlay closes it",
|
|
368
|
+
not p.evaluate("() => document.getElementById('ml-drawer').matches(':popover-open')"), "")
|
|
369
|
+
|
|
370
|
+
# navbar
|
|
371
|
+
p.goto(bust(), wait_until="networkidle")
|
|
372
|
+
nb = p.evaluate("""() => { const t = document.getElementById('ml-nb-toggle');
|
|
373
|
+
return {mode: document.getElementById('ml-nb').className.includes('dropdown-mode'),
|
|
374
|
+
tag: t.tagName.toLowerCase(), expanded: t.getAttribute('aria-expanded'),
|
|
375
|
+
controls: t.getAttribute('aria-controls')}; }""")
|
|
376
|
+
row("NAVBAR", "collapsed below _t", nb["mode"] and not info("ml-nb-nav")["shown"], str(nb))
|
|
377
|
+
p.tap("#ml-nb-toggle"); p.wait_for_timeout(700)
|
|
378
|
+
row("NAVBAR", "toggle opens the links", info("ml-nb-nav")["shown"],
|
|
379
|
+
"aria-expanded=%s, focus on %s" % (info("ml-nb-toggle")["expanded"], p.evaluate(ACTIVE)))
|
|
380
|
+
p.keyboard.press("Escape"); p.wait_for_timeout(600)
|
|
381
|
+
row("NAVBAR", "Escape closes it", not info("ml-nb-nav")["shown"], "shown=%s" % info("ml-nb-nav")["shown"])
|
|
382
|
+
|
|
383
|
+
# interaction panel
|
|
384
|
+
p.goto(bust(), wait_until="networkidle")
|
|
385
|
+
p.tap("#ml-oc-btn"); p.wait_for_timeout(700)
|
|
386
|
+
row("PANEL", "click interaction opens the panel", info("ml-oc-panel")["shown"], "")
|
|
387
|
+
row("PANEL", "its close control is covered by the sticky header", None,
|
|
388
|
+
"element at its centre: %s" % p.evaluate(ON_TOP, "ml-oc-close"))
|
|
389
|
+
p.keyboard.press("Escape"); p.wait_for_timeout(600)
|
|
390
|
+
row("PANEL", "Escape closes it", not info("ml-oc-panel")["shown"], "shown=%s" % info("ml-oc-panel")["shown"])
|
|
391
|
+
row("PANEL", "focus moved into it", p.evaluate("() => !!document.activeElement.closest('#ml-oc-panel')"),
|
|
392
|
+
"focus on %s" % p.evaluate(ACTIVE))
|
|
393
|
+
ctx.close()
|
|
394
|
+
b.close()
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
def main():
|
|
398
|
+
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
399
|
+
ap.add_argument("--config")
|
|
400
|
+
ap.add_argument("--post", required=True, type=int)
|
|
401
|
+
ap.add_argument("--slug", default="menu-lab")
|
|
402
|
+
ap.add_argument("--csv")
|
|
403
|
+
ap.add_argument("--no-build", action="store_true")
|
|
404
|
+
a = ap.parse_args()
|
|
405
|
+
cfg = mosaic_config.load(a.config)
|
|
406
|
+
if not a.no_build:
|
|
407
|
+
master = build(Client(cfg), cfg, a.post, a.slug)
|
|
408
|
+
print("built on master %s" % master[:8])
|
|
409
|
+
rows = []
|
|
410
|
+
drive("%s/%s/" % (cfg["base"].rstrip("/"), a.slug), rows)
|
|
411
|
+
if a.csv:
|
|
412
|
+
with open(a.csv, "w", newline="", encoding="utf-8") as fh:
|
|
413
|
+
w = csv.writer(fh)
|
|
414
|
+
w.writerow(["group", "check", "result", "evidence"])
|
|
415
|
+
w.writerows(rows)
|
|
416
|
+
fails = sum(1 for r in rows if r[2] == "FAIL")
|
|
417
|
+
print("\n%d checks, %d FAIL" % (len(rows), fails))
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
if __name__ == "__main__":
|
|
421
|
+
main()
|