stitch2 0.13.0 → 0.13.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 +23 -2
  2. package/package.json +1 -1
package/dist/audit.js CHANGED
@@ -212,14 +212,35 @@ export async function audit(opts) {
212
212
  return e;
213
213
  return null;
214
214
  };
215
+ // The part of a control its scrolling or clipping ancestors show: a link scrolled out of a nav strip is not drawn
216
+ // where its box would be.
217
+ const visibleBox = (el) => {
218
+ const r = el.getBoundingClientRect();
219
+ let { left, top, right, bottom } = r;
220
+ for (let e = el.parentElement; e && e !== document.body; e = e.parentElement) {
221
+ const cs = getComputedStyle(e);
222
+ if (cs.overflowX === 'visible' && cs.overflowY === 'visible')
223
+ continue;
224
+ const c = e.getBoundingClientRect();
225
+ if (cs.overflowX !== 'visible') {
226
+ left = Math.max(left, c.left);
227
+ right = Math.min(right, c.right);
228
+ }
229
+ if (cs.overflowY !== 'visible') {
230
+ top = Math.max(top, c.top);
231
+ bottom = Math.min(bottom, c.bottom);
232
+ }
233
+ }
234
+ return { left, top, right, bottom };
235
+ };
215
236
  // Behind an open modal (found above) only the modal's own controls count.
216
237
  const solid = interactive.filter((el) => opacity(el) > 0.05 && (!modal || modal.contains(el)));
217
238
  for (const [i, a] of solid.entries())
218
239
  for (const b of solid.slice(i + 1)) {
219
240
  if (a.contains(b) || b.contains(a) || layer(a) !== layer(b))
220
241
  continue;
221
- const r = a.getBoundingClientRect();
222
- const q = b.getBoundingClientRect();
242
+ const r = visibleBox(a);
243
+ const q = visibleBox(b);
223
244
  if (Math.min(r.right, q.right) - Math.max(r.left, q.left) > 2 && Math.min(r.bottom, q.bottom) - Math.max(r.top, q.top) > 2)
224
245
  push('error', 'control-overlap', b, `Overlaps another control (“${text(a).slice(0, 30) || a.getAttribute('aria-label') || a.tagName.toLowerCase()}”): give them room`);
225
246
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitch2",
3
- "version": "0.13.0",
3
+ "version": "0.13.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",