@abbox/inspector 0.4.19 → 0.4.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.
@@ -12,4 +12,10 @@ export declare function hideHighlight(highlight: HTMLDivElement): void;
12
12
  export declare function hideSelectedHighlight(selectedHighlight: HTMLDivElement): void;
13
13
  export declare function rectForElement(el: Element): ElementRect;
14
14
  export declare function renderChangeMarkers(layer: HTMLDivElement, markers: ChangeMarker[], resolveElement: (refId: string) => Element | null, onSelect?: (changeId: string) => void): void;
15
+ /**
16
+ * A badge sits just above its element and moves with it. With no room above
17
+ * (the element starts at the top of the screen) it tucks inside the element's
18
+ * top edge instead, and scrolls away with the element rather than sticking.
19
+ */
20
+ export declare function badgeTop(elementTop: number): number;
15
21
  //# sourceMappingURL=overlay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/runtime/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMhE,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,cAAc,CAAC;IAC1B,iBAAiB,EAAE,cAAc,CAAC;IAClC,WAAW,EAAE,cAAc,CAAC;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,cAAc,CAgD5D;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,WAAW,GAChB,IAAI,CAQN;AAED,wBAAgB,yBAAyB,CACvC,iBAAiB,EAAE,cAAc,EACjC,IAAI,EAAE,WAAW,GAChB,IAAI,CAQN;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,CAE7D;AAED,wBAAgB,qBAAqB,CAAC,iBAAiB,EAAE,cAAc,GAAG,IAAI,CAE7E;AAED,wBAA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KAAK,IAAI,GACpC,IAAI,CA0FN;AAID;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAGnD"}
@@ -147,20 +147,38 @@ export function renderChangeMarkers(layer, markers, resolveElement, onSelect) {
147
147
  event.stopPropagation();
148
148
  onSelect?.(marker.elementRefId);
149
149
  };
150
+ // A labelled pill is far wider than a dot, so it needs much less movement.
150
151
  dot.style.animation = marker.pulse
151
- ? "abbox-inspector-pulse 1.4s ease-in-out infinite"
152
+ ? `abbox-inspector-pulse${marker.badge ? "-soft" : ""} 1.4s ease-in-out infinite`
152
153
  : "";
153
154
  dot.style.boxShadow = marker.pulse
154
- ? "0 0 0 4px rgba(255,255,255,0.35)"
155
+ ? `0 0 0 ${marker.badge ? 2 : 4}px rgba(255,255,255,0.35)`
155
156
  : "0 0 0 1px rgba(0,0,0,0.2)";
156
157
  if (marker.pulse)
157
158
  ensurePulseStyle(layer.ownerDocument);
159
+ // Only while its element is on screen: a chip left at the viewport edge
160
+ // floats over unrelated content.
161
+ const view = layer.ownerDocument.defaultView;
162
+ const onScreen = rect.bottom > 0 &&
163
+ rect.right > 0 &&
164
+ rect.top < (view?.innerHeight ?? Number.POSITIVE_INFINITY) &&
165
+ rect.left < (view?.innerWidth ?? Number.POSITIVE_INFINITY);
166
+ dot.style.display = onScreen ? "" : "none";
158
167
  dot.style.left = `${rect.x - 6}px`;
159
- dot.style.top = marker.badge
160
- ? `${Math.max(0, rect.top - 18)}px`
161
- : `${rect.top - 6}px`;
168
+ dot.style.top = `${marker.badge ? badgeTop(rect.top) : rect.top - 6}px`;
162
169
  }
163
170
  }
171
+ const BADGE_HEIGHT = 18;
172
+ /**
173
+ * A badge sits just above its element and moves with it. With no room above
174
+ * (the element starts at the top of the screen) it tucks inside the element's
175
+ * top edge instead, and scrolls away with the element rather than sticking.
176
+ */
177
+ export function badgeTop(elementTop) {
178
+ if (elementTop >= BADGE_HEIGHT)
179
+ return elementTop - BADGE_HEIGHT;
180
+ return elementTop >= 0 ? 0 : elementTop;
181
+ }
164
182
  const BADGE_COLORS = {
165
183
  "seo-error": "#dc2626",
166
184
  "seo-warning": "#d97706",
@@ -191,6 +209,10 @@ function ensurePulseStyle(doc) {
191
209
  style.textContent = `@keyframes abbox-inspector-pulse {
192
210
  0%, 100% { transform: scale(1); opacity: 1; }
193
211
  50% { transform: scale(1.35); opacity: 0.75; }
212
+ }
213
+ @keyframes abbox-inspector-pulse-soft {
214
+ 0%, 100% { transform: scale(1); opacity: 1; }
215
+ 50% { transform: scale(1.04); opacity: 0.9; }
194
216
  }`;
195
217
  doc.head.append(style);
196
218
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abbox/inspector",
3
- "version": "0.4.19",
3
+ "version": "0.4.21",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },