@seanyeh77/ui-cli 0.48.0 → 0.48.2
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 +1 -1
- package/dist/cli.js +34 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ npx playwright install chromium # ui check 與 ui shots 用的瀏覽器;或
|
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
- `ui check <檔案或 URL>`:在 390 px 與 1280 px、淺色與深色打開頁面,檢查 console 錯誤、水平溢出、小於 48 px 的觸控目標、1280 px 時小於 24 px 又擠著別的目標的目標(WCAG 2.5.8)、卡片裡的卡片、原生控制項、被截斷又沒有 Tooltip 或 title 的介面文字、跑出卡片外的文字、同一列工具列或表單欄位不同高、390 px 時置中的兩行以上段落、AppShell 頁面的文件本身也在捲動、沒放進 layer 又蓋過元件的重設 CSS,以及 axe-core 的 WCAG 2.0、2.1、2.2 A 與 AA 規則,有問題時 exit 1。每次量測前等動畫和轉場結束(最多 1.5 s)。頁面沒有 viewport meta 時,390 px 只回報一次「缺 viewport meta」,不檢查觸控目標。 file:// 頁面的字型被 CORS 擋下時不算 console 錯誤,每頁最後寫一行 note,提醒用 http 開頁面。
|
|
11
|
-
- 它也會點開每個分頁(`[role=tablist]`)、SettingsLayout 的每個分類,以及工具列與頂欄裡 `[aria-haspopup]`
|
|
11
|
+
- 它也會點開每個分頁(`[role=tablist]`)、SettingsLayout 的每個分類,以及工具列與頂欄裡 `[aria-haspopup]` 按鈕的選單,檢查打開後的畫面(淺色與深色、兩種寬度,每頁最多 12 個狀態),只回報原本沒有的問題。24 px 檢查的鄰近目標只算看得到的部分:被儲存格或其他 `overflow` 裁掉的連結不算。
|
|
12
12
|
- 每個寬度與主題那一行的結果算進頁面和打開的狀態;各狀態的問題列在「after opening …」底下。
|
|
13
13
|
- `--open <selector>` 點開頁面上第一個符合的元素(對話框、側欄)並檢查,可以重複;`--no-interact` 不自動點分頁、分類和選單;`--no-axe` 不跑 axe-core。`--shots <資料夾>` 存每個寬度與主題的整頁截圖,也存每個打開的狀態。
|
|
14
14
|
- `ui shots <檔案或 URL>`:固定時間、停止動畫的截圖,寫成基準圖(`--out`)或和基準圖比對(`--compare`)。整頁截圖包含頁面自己的捲動區(AppShell 的主內容)裡捲到下面的內容。檔名來自檔案名稱或網址的路徑,再接查詢字串和 hash(`http://localhost:5173/settings#billing` 是 `settings-billing`,`iframe.html?id=button--primary` 是 `iframe-id-button-primary`)。網路閒置、字型載入、高度連續兩次相同之後才截圖。
|
package/dist/cli.js
CHANGED
|
@@ -133,6 +133,31 @@ function measure() {
|
|
|
133
133
|
}
|
|
134
134
|
(inSentence(el, cs) ? out.inline : out.small).push(`${describe(el)} ${Math.round(w)} x ${Math.round(h)} px`);
|
|
135
135
|
}
|
|
136
|
+
const shownPart = (el, r) => {
|
|
137
|
+
let { left, top, right, bottom } = r;
|
|
138
|
+
if (getComputedStyle(el).position === "fixed") return {
|
|
139
|
+
left,
|
|
140
|
+
top,
|
|
141
|
+
right,
|
|
142
|
+
bottom
|
|
143
|
+
};
|
|
144
|
+
for (let a = el.parentElement; a && a !== document.body; a = a.parentElement) {
|
|
145
|
+
const cs = getComputedStyle(a);
|
|
146
|
+
const cutX = cs.overflowX !== "visible";
|
|
147
|
+
const cutY = cs.overflowY !== "visible";
|
|
148
|
+
if (!cutX && !cutY) continue;
|
|
149
|
+
const ar = a.getBoundingClientRect();
|
|
150
|
+
if (cutX) [left, right] = [Math.max(left, ar.left), Math.min(right, ar.right)];
|
|
151
|
+
if (cutY) [top, bottom] = [Math.max(top, ar.top), Math.min(bottom, ar.bottom)];
|
|
152
|
+
if (right <= left || bottom <= top) return null;
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
left,
|
|
156
|
+
top,
|
|
157
|
+
right,
|
|
158
|
+
bottom
|
|
159
|
+
};
|
|
160
|
+
};
|
|
136
161
|
for (const t of targets) {
|
|
137
162
|
if (out.small24.length >= 60) break;
|
|
138
163
|
if (t.w >= 23.5 && t.h >= 23.5) continue;
|
|
@@ -145,10 +170,12 @@ function measure() {
|
|
|
145
170
|
}
|
|
146
171
|
const near = targets.find((o) => {
|
|
147
172
|
if (o === t || o.el.contains(t.el) || t.el.contains(o.el)) return false;
|
|
148
|
-
const
|
|
149
|
-
|
|
173
|
+
const v = shownPart(o.el, o.r);
|
|
174
|
+
if (!v) return false;
|
|
175
|
+
const dx = Math.max(v.left - cx, 0, cx - v.right);
|
|
176
|
+
const dy = Math.max(v.top - cy, 0, cy - v.bottom);
|
|
150
177
|
if (Math.hypot(dx, dy) < 12) return true;
|
|
151
|
-
return (o.w < 23.5 || o.h < 23.5) && Math.hypot(
|
|
178
|
+
return (o.w < 23.5 || o.h < 23.5) && Math.hypot((v.left + v.right) / 2 - cx, (v.top + v.bottom) / 2 - cy) < 24;
|
|
152
179
|
});
|
|
153
180
|
if (near) out.small24.push(`${describe(t.el)} ${Math.round(t.w)} x ${Math.round(t.h)} px, next to ${describe(near.el)}`);
|
|
154
181
|
}
|
|
@@ -974,7 +1001,7 @@ const HELP_CHECK = `ui check <file or URL>... [--shots DIR] [--strict] [--wait M
|
|
|
974
1001
|
Each measurement waits until the page's animations and transitions end (up to 1.5 s), so a fade is not measured
|
|
975
1002
|
half way.
|
|
976
1003
|
A page without <meta name="viewport"> gets one report at 390 px (缺 viewport meta) and no touch-target check there.
|
|
977
|
-
It also opens what the page hides behind clicks,
|
|
1004
|
+
It also opens what the page hides behind clicks, at both widths in both themes: each tab of a [role=tablist], each
|
|
978
1005
|
SettingsLayout category, and each menu or popover of an [aria-haspopup] button in a toolbar or top bar (up to 12
|
|
979
1006
|
states a page), and checks every state for the problems the page did not already have. The line of each width and
|
|
980
1007
|
theme counts the problems of the page and of its opened states; each state's problems follow under its name.
|
|
@@ -982,7 +1009,7 @@ const HELP_CHECK = `ui check <file or URL>... [--shots DIR] [--strict] [--wait M
|
|
|
982
1009
|
--no-interact skips the automatic tabs, categories and toolbar menus (--open still runs).
|
|
983
1010
|
--no-axe skips the axe-core pass.
|
|
984
1011
|
--shots DIR saves a full-page screenshot of each width and theme in DIR (<name>-<width>-<theme>.png, <name> as
|
|
985
|
-
in ui shots), and one of each opened state (<name>-<width
|
|
1012
|
+
in ui shots), and one of each opened state (<name>-<width>-<theme>-<state>.png; an open dialog, drawer or menu at the viewport size).
|
|
986
1013
|
--strict also fails on inline text links under 48 px.
|
|
987
1014
|
--wait MS waits this long after load before measuring (default 800).
|
|
988
1015
|
Exits 2 when a page cannot be checked at all: it does not load, or the check itself crashes.`;
|
|
@@ -1379,7 +1406,7 @@ async function check(targets, opts) {
|
|
|
1379
1406
|
};
|
|
1380
1407
|
await shoot("");
|
|
1381
1408
|
const states = [];
|
|
1382
|
-
if (
|
|
1409
|
+
if (opts.open.length || opts.interact) {
|
|
1383
1410
|
const itemKey = (item) => item.split(", next to ")[0].replace(/ \d+ x \d+ px$/, "");
|
|
1384
1411
|
const axeKey = (line) => line.split(" ")[0];
|
|
1385
1412
|
const knownAxe = new Set(axe.map(axeKey));
|
|
@@ -1409,7 +1436,7 @@ async function check(targets, opts) {
|
|
|
1409
1436
|
if (errors.length > before) found.unshift("console errors: " + errors.slice(before, before + 5).join(" | "));
|
|
1410
1437
|
if (opts.axe) {
|
|
1411
1438
|
const skip = trigger ? ["aria-hidden-focus"] : [];
|
|
1412
|
-
const more = (await run(() => axeRun(page,
|
|
1439
|
+
const more = (await run(() => axeRun(page, theme === "dark", skip)).catch(() => [])).filter((v) => !knownAxe.has(axeKey(v)));
|
|
1413
1440
|
if (more.length) found.push("accessibility (axe-core): " + more.join(" | "));
|
|
1414
1441
|
}
|
|
1415
1442
|
await shoot(`-${cleanName(label)}`, trigger);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seanyeh77/ui-cli",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.2",
|
|
4
4
|
"description": "Checks a page against SeanYeh's design system, compares its screenshots with baselines and prints component docs: ui check, ui shots, ui docs, ui list.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Hsiu-An Yeh",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"pixelmatch": "^8.0.0",
|
|
22
22
|
"playwright": "1.65.0",
|
|
23
23
|
"pngjs": "^7.0.0",
|
|
24
|
-
"@seanyeh77/ui": "^0.48.
|
|
24
|
+
"@seanyeh77/ui": "^0.48.2"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
27
|
"node": ">=22"
|