stitch2 0.19.0 → 0.19.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.
Files changed (2) hide show
  1. package/dist/audit.js +31 -10
  2. package/package.json +1 -1
package/dist/audit.js CHANGED
@@ -608,25 +608,46 @@ export async function audit(opts) {
608
608
  }
609
609
  }
610
610
  // 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
- if (W >= 600 && W < 1200) {
613
- const fixedBar = (el) => {
614
- for (let e = el; e && e !== document.body; e = e.parentElement)
615
- if (['fixed', 'sticky'].includes(getComputedStyle(e).position))
616
- return true;
617
- return false;
611
+ // phone column in the middle of it, with most of the window empty, is a layout that stopped adapting. Only for a
612
+ // page longer than the window (a list or a feed): a sign-in card or an empty state is narrow on purpose. Bars
613
+ // fixed to an edge (a tab bar, a side navigation) don't count, and a side navigation's width is not available.
614
+ const H = innerHeight;
615
+ if (W >= 600 && W < 1200 && document.documentElement.scrollHeight > H * 1.15) {
616
+ const rail = (e) => {
617
+ const cs = getComputedStyle(e);
618
+ if (cs.position !== 'fixed' && cs.position !== 'sticky')
619
+ return false;
620
+ const r = e.getBoundingClientRect();
621
+ return r.left <= 1 || r.right >= W - 1 || r.top <= 1 || r.bottom >= H - 1;
618
622
  };
623
+ const rails = new Set();
624
+ let side = 0;
625
+ for (const el of all)
626
+ if (rail(el)) {
627
+ rails.add(el);
628
+ const r = el.getBoundingClientRect();
629
+ if (r.height >= H * 0.5 && r.width < W * 0.4)
630
+ side = Math.max(side, r.width);
631
+ }
632
+ const inRail = (el) => [...rails].some((r) => r.contains(el));
633
+ const room = W - side;
619
634
  let left = W, right = 0;
620
635
  for (const el of all) {
621
- if (!(ownText(el) || el.matches('img, svg, input, textarea, select, button, [role="button"]')) || fixedBar(el))
636
+ if (el === document.body || el === document.documentElement || inRail(el))
637
+ continue;
638
+ const cs = getComputedStyle(el);
639
+ const box = (cs.backgroundColor !== 'rgba(0, 0, 0, 0)' && cs.backgroundColor !== 'transparent') || parseFloat(cs.borderTopWidth) > 0;
640
+ if (!(ownText(el) || box || el.matches('img, svg, input, textarea, select, button, [role="button"]')))
622
641
  continue;
623
642
  const r = el.getBoundingClientRect();
643
+ if (r.width >= room * 0.95)
644
+ continue;
624
645
  left = Math.min(left, r.left);
625
646
  right = Math.max(right, r.right);
626
647
  }
627
648
  const used = right - left;
628
- if (used > 0 && used < W * 0.6)
629
- push('warning', 'narrow-layout', document.querySelector('main') ?? document.body, 'The content takes ' + Math.round(used) + ' of ' + W + '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');
649
+ if (used > 0 && used < room * 0.6)
650
+ 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
651
  }
631
652
  return out.sort((x, y) => (x.severity === y.severity ? 0 : x.severity === 'error' ? -1 : 1));
632
653
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitch2",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "description": "A design canvas, layout and type checks, component consistency and screen versioning for agent-built UI, on Google's DESIGN.md format.",
5
5
  "license": "MIT",
6
6
  "author": "ifokeev",