@siyahi/tools 0.1.9-next.20 → 0.1.9-next.21

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/package.json +1 -1
  2. package/shots.mjs +10 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siyahi/tools",
3
- "version": "0.1.9-next.20",
3
+ "version": "0.1.9-next.21",
4
4
  "description": "Checks and build helpers for Siyahi pages: a lint plugin, a font preload plugin, a theme contrast check, and screenshot and layout shift scripts.",
5
5
  "homepage": "https://siyahi.jatinbansal.com",
6
6
  "license": "MIT",
package/shots.mjs CHANGED
@@ -107,6 +107,15 @@ const PROBE = `((chrome) => {
107
107
  (style.clipPath === "inset(50%)" || style.clip === "rect(0px, 0px, 0px, 0px)");
108
108
  return r.width > 0 && r.height > 0 && !el.closest(chrome) && style.visibility !== "hidden" && !hiddenControl;
109
109
  };
110
+ // Tailwind's sr-only (and a closed dialog's title kept for screen readers) clips to nothing, so it has no place
111
+ // in the gutter; the cut-off check still sees it, as a clipped visible control must not slip through.
112
+ const screenReaderOnly = (el) => {
113
+ for (let node = el; node; node = node.parentElement) {
114
+ const style = getComputedStyle(node);
115
+ if (style.clip === "rect(0px, 0px, 0px, 0px)" || style.clipPath === "inset(50%)") return true;
116
+ }
117
+ return false;
118
+ };
110
119
  // Pixels of el cut off at the side by an ancestor that hides its overflow,
111
120
  // and how it hides it, up to the nearest one that scrolls, which shows the
112
121
  // rest on scroll.
@@ -124,7 +133,7 @@ const PROBE = `((chrome) => {
124
133
  };
125
134
  const visible = [...document.querySelectorAll('h1,h2,h3,h4,p,li,td,th,[data-slot="card"]')].filter((el) => {
126
135
  const r = el.getBoundingClientRect();
127
- return shown(el) && r.right > 0 && r.left < de.clientWidth && !scrollsSideways(el);
136
+ return shown(el) && !screenReaderOnly(el) && r.right > 0 && r.left < de.clientWidth && !scrollsSideways(el);
128
137
  });
129
138
  // Badges, card titles and descriptions are spans and divs, which the tag list misses.
130
139
  const clipped = [...document.querySelectorAll('h1,h2,h3,h4,p,li,td,th,a,button,input,select,textarea,label,[data-slot="badge"],[data-slot="card-title"],[data-slot="card-description"]')]