stitch2 0.19.0 → 0.19.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/dist/audit.js +34 -10
- package/package.json +1 -1
package/dist/audit.js
CHANGED
|
@@ -125,6 +125,9 @@ export async function audit(opts) {
|
|
|
125
125
|
for (let n = walker.nextNode(); n; n = walker.nextNode()) {
|
|
126
126
|
if (!n.textContent.trim())
|
|
127
127
|
continue;
|
|
128
|
+
// A label allowed two lines on purpose (line-clamp-2: a navigation rail's, under its icon) may wrap.
|
|
129
|
+
if ((parseInt(getComputedStyle(n.parentElement).getPropertyValue('-webkit-line-clamp')) || 0) > 1)
|
|
130
|
+
continue;
|
|
128
131
|
const range = document.createRange();
|
|
129
132
|
range.selectNodeContents(n);
|
|
130
133
|
const tops = [...range.getClientRects()].filter((r) => r.width > 1).map((r) => r.top + r.height / 2);
|
|
@@ -608,25 +611,46 @@ export async function audit(opts) {
|
|
|
608
611
|
}
|
|
609
612
|
}
|
|
610
613
|
// 6i. A medium window (600–1199 px: tablets, small laptops, Material's medium and expanded classes) is used: a
|
|
611
|
-
// phone column in the middle of it, with most of the window empty, is a layout that stopped adapting.
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
614
|
+
// phone column in the middle of it, with most of the window empty, is a layout that stopped adapting. Only for a
|
|
615
|
+
// page longer than the window (a list or a feed): a sign-in card or an empty state is narrow on purpose. Bars
|
|
616
|
+
// fixed to an edge (a tab bar, a side navigation) don't count, and a side navigation's width is not available.
|
|
617
|
+
const H = innerHeight;
|
|
618
|
+
if (W >= 600 && W < 1200 && document.documentElement.scrollHeight > H * 1.15) {
|
|
619
|
+
const rail = (e) => {
|
|
620
|
+
const cs = getComputedStyle(e);
|
|
621
|
+
if (cs.position !== 'fixed' && cs.position !== 'sticky')
|
|
622
|
+
return false;
|
|
623
|
+
const r = e.getBoundingClientRect();
|
|
624
|
+
return r.left <= 1 || r.right >= W - 1 || r.top <= 1 || r.bottom >= H - 1;
|
|
618
625
|
};
|
|
626
|
+
const rails = new Set();
|
|
627
|
+
let side = 0;
|
|
628
|
+
for (const el of all)
|
|
629
|
+
if (rail(el)) {
|
|
630
|
+
rails.add(el);
|
|
631
|
+
const r = el.getBoundingClientRect();
|
|
632
|
+
if (r.height >= H * 0.5 && r.width < W * 0.4)
|
|
633
|
+
side = Math.max(side, r.width);
|
|
634
|
+
}
|
|
635
|
+
const inRail = (el) => [...rails].some((r) => r.contains(el));
|
|
636
|
+
const room = W - side;
|
|
619
637
|
let left = W, right = 0;
|
|
620
638
|
for (const el of all) {
|
|
621
|
-
if (
|
|
639
|
+
if (el === document.body || el === document.documentElement || inRail(el))
|
|
640
|
+
continue;
|
|
641
|
+
const cs = getComputedStyle(el);
|
|
642
|
+
const box = (cs.backgroundColor !== 'rgba(0, 0, 0, 0)' && cs.backgroundColor !== 'transparent') || parseFloat(cs.borderTopWidth) > 0;
|
|
643
|
+
if (!(ownText(el) || box || el.matches('img, svg, input, textarea, select, button, [role="button"]')))
|
|
622
644
|
continue;
|
|
623
645
|
const r = el.getBoundingClientRect();
|
|
646
|
+
if (r.width >= room * 0.95)
|
|
647
|
+
continue;
|
|
624
648
|
left = Math.min(left, r.left);
|
|
625
649
|
right = Math.max(right, r.right);
|
|
626
650
|
}
|
|
627
651
|
const used = right - left;
|
|
628
|
-
if (used > 0 && used <
|
|
629
|
-
push('warning', 'narrow-layout', document.querySelector('main') ?? document.body, 'The content takes ' + Math.round(used) + ' of ' +
|
|
652
|
+
if (used > 0 && used < room * 0.6)
|
|
653
|
+
push('warning', 'narrow-layout', document.querySelector('main') ?? document.body, 'The content takes ' + Math.round(used) + ' of ' + Math.round(room) + 'px: a phone column in a wide window. Use the room (more columns, a side column) with the breakpoints, or give these widths to another variant');
|
|
630
654
|
}
|
|
631
655
|
return out.sort((x, y) => (x.severity === y.severity ? 0 : x.severity === 'error' ? -1 : 1));
|
|
632
656
|
}
|
package/package.json
CHANGED