MCPcopy Create free account
hub / github.com/Roy3838/Observer / getBubbleStyle

Function getBubbleStyle

app/src/components/EditAgent/SimpleCreatorTutorial.tsx:67–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65 const pad = 8;
66
67 const getBubbleStyle = (): React.CSSProperties => {
68 if (!rect) return { top: '50%', left: '50%', transform: 'translate(-50%, -50%)' };
69 const W = 272, H = 220, vw = window.innerWidth, vh = window.innerHeight;
70 const clampTop = (t: number) => Math.max(pad, Math.min(t, vh - H - pad));
71 const left = Math.max(pad, Math.min(rect.left, vw - W - pad));
72 if (rect.right + W + pad * 3 < vw) return { left: rect.right + pad * 2, top: clampTop(rect.top) };
73 if (rect.left - W - pad > 0) return { left: rect.left - W - pad, top: clampTop(rect.top) };
74 // Below: flip above if off-screen
75 const belowTop = rect.bottom + pad * 2;
76 if (belowTop + H <= vh - pad) return { top: belowTop, left };
77 return { top: Math.max(pad, rect.top - H - pad * 2), left };
78 };
79
80 return createPortal(
81 <>

Callers 1

SimpleCreatorTutorialFunction · 0.70

Calls 1

clampTopFunction · 0.70

Tested by

no test coverage detected