Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(web): keep reconnect loader background transparent (#585)

Gustavo Ye3735282f91fe
diff --git a/src/web/src/app/globals.css b/src/web/src/app/globals.css
index a4910a1a0..1238e792c 100644
--- a/src/web/src/app/globals.css
+++ b/src/web/src/app/globals.css
@@ -84,38 +84,18 @@
}
.community-ws-connecting-loader {
- display: grid;
+ display: block;
width: 100px;
- aspect-ratio: 1;
- box-sizing: border-box;
- padding: 10px;
- background: var(--background);
- filter: blur(5px) contrast(10);
- mix-blend-mode: darken;
-}
-
-.dark .community-ws-connecting-loader {
- mix-blend-mode: lighten;
-}
-
-.community-ws-connecting-loader::before,
-.community-ws-connecting-loader::after {
- grid-area: 1 / 1;
- background:
- linear-gradient(var(--primary) 0 0) left,
- linear-gradient(var(--primary) 0 0) right;
- background-size: 20px 40px;
- background-origin: content-box;
- background-repeat: no-repeat;
- content: "";
+ height: 100px;
+ overflow: visible;
+ color: var(--primary);
+ background: transparent;
+ mix-blend-mode: normal;
}
-.community-ws-connecting-loader::after {
- width: 20px;
- height: 20px;
- margin: auto 0;
- border-radius: 50%;
- background: var(--primary);
+.community-ws-connecting-dot {
+ transform-box: fill-box;
+ transform-origin: center;
animation: community-ws-connecting 1s infinite;
}
@@ -127,12 +107,12 @@ body.driver-active .community-ws-reconnect-overlay * {
@keyframes community-ws-connecting {
90%,
100% {
- transform: translateX(300%);
+ transform: translateX(60px);
}
}
@media (prefers-reduced-motion: reduce) {
- .community-ws-connecting-loader::after {
+ .community-ws-connecting-dot {
animation: none;
}
}
diff --git a/src/web/src/components/community/shell/community-ws-reconnect-overlay.test.ts b/src/web/src/components/community/shell/community-ws-reconnect-overlay.test.ts
index a81c11995..1b0fc2db0 100644
--- a/src/web/src/components/community/shell/community-ws-reconnect-overlay.test.ts
+++ b/src/web/src/components/community/shell/community-ws-reconnect-overlay.test.ts
@@ -62,7 +62,12 @@ describe("CommunityWsReconnectBoundary", () => {
})
expect(renderer.root.findByType("h2").children).toEqual(["Connecting…"])
const motion = renderer.root.findByProps({ "data-connecting-motion": "" })
+ expect(motion.type).toBe("svg")
expect(motion.props.className).toContain("community-ws-connecting-loader")
+ expect(motion.findAllByType("rect")).toHaveLength(2)
+ expect(motion.findByType("circle").props.className).toBe("community-ws-connecting-dot")
+ expect(motion.findAllByType("filter")).toHaveLength(1)
+ expect(motion.findAllByType("feBlend")).toHaveLength(1)
expect(renderer.root.findAllByProps({ "data-testid": tid.wsRetry })).toHaveLength(0)
expect(focus).toHaveBeenCalledOnce()
})
diff --git a/src/web/src/components/community/shell/community-ws-reconnect-overlay.tsx b/src/web/src/components/community/shell/community-ws-reconnect-overlay.tsx
index 70cdd6ce5..0a1430c54 100644
--- a/src/web/src/components/community/shell/community-ws-reconnect-overlay.tsx
+++ b/src/web/src/components/community/shell/community-ws-reconnect-overlay.tsx
@@ -74,11 +74,41 @@ export function CommunityWsReconnectBoundary({ children }: { children: ReactNode
</>
) : (
<div role="status" aria-live="polite" aria-atomic="true" className="flex flex-col items-center">
- <div
+ <svg
aria-hidden="true"
data-connecting-motion=""
className="community-ws-connecting-loader mb-4"
- />
+ viewBox="0 0 100 100"
+ >
+ <defs>
+ <filter
+ id="community-ws-connecting-goo"
+ x="-20%"
+ y="-20%"
+ width="140%"
+ height="140%"
+ colorInterpolationFilters="sRGB"
+ >
+ <feGaussianBlur in="SourceGraphic" stdDeviation="5" result="blur" />
+ <feColorMatrix
+ in="blur"
+ values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10"
+ result="goo"
+ />
+ <feBlend in="SourceGraphic" in2="goo" />
+ </filter>
+ </defs>
+ <g fill="currentColor" filter="url(#community-ws-connecting-goo)">
+ <rect x="10" y="30" width="20" height="40" rx="10" />
+ <circle
+ className="community-ws-connecting-dot"
+ cx="20"
+ cy="50"
+ r="10"
+ />
+ <rect x="70" y="30" width="20" height="40" rx="10" />
+ </g>
+ </svg>
<h2 id="community-ws-reconnect-title" className="font-heading text-base font-medium">
Connecting…
</h2>
diff --git a/src/web/src/test/e2e-ui/25-community-ws-reconnect-overlay.spec.ts b/src/web/src/test/e2e-ui/25-community-ws-reconnect-overlay.spec.ts
index 9299c5390..93221f291 100644
--- a/src/web/src/test/e2e-ui/25-community-ws-reconnect-overlay.spec.ts
+++ b/src/web/src/test/e2e-ui/25-community-ws-reconnect-overlay.spec.ts
@@ -14,7 +14,7 @@ test("real WebSocket outage blocks the whole community surface and Retry restore
aliceWs = ws
ws.connectToServer()
})
- await alice.page.emulateMedia({ reducedMotion: "reduce" })
+ await alice.page.emulateMedia({ reducedMotion: "reduce", colorScheme: "dark" })
await alice.page.setViewportSize({ width: 390, height: 844 })
await gotoAfterUserWsAuth(alice.page, `/c/channels/${serverId}/${channelId}`)
const composer = composerEditable(alice.page)
@@ -35,12 +35,15 @@ test("real WebSocket outage blocks the whole community surface and Retry restore
const rect = element.getBoundingClientRect()
const content = element.previousElementSibling as HTMLElement | null
const connectingMotion = element.querySelector<HTMLElement>("[data-connecting-motion]")
+ const connectingDot = element.querySelector<SVGCircleElement>(".community-ws-connecting-dot")
+ const connectingStyle = connectingMotion ? getComputedStyle(connectingMotion) : null
return {
ariaHidden: content?.getAttribute("aria-hidden"),
inert: content?.hasAttribute("inert"),
- animationName: connectingMotion
- ? getComputedStyle(connectingMotion, "::after").animationName
- : null,
+ animationName: connectingDot ? getComputedStyle(connectingDot).animationName : null,
+ loaderBackground: connectingStyle?.backgroundColor,
+ loaderBlendMode: connectingStyle?.mixBlendMode,
+ loaderElement: connectingMotion?.tagName.toLowerCase(),
rect: { x: rect.x, y: rect.y, width: rect.width, height: rect.height },
viewport: { width: innerWidth, height: innerHeight },
}
@@ -49,6 +52,9 @@ test("real WebSocket outage blocks the whole community surface and Retry restore
ariaHidden: "true",
inert: true,
animationName: "none",
+ loaderBackground: "rgba(0, 0, 0, 0)",
+ loaderBlendMode: "normal",
+ loaderElement: "svg",
rect: { x: 0, y: 0, width: 390, height: 844 },
viewport: { width: 390, height: 844 },
})
@@ -57,22 +63,39 @@ test("real WebSocket outage blocks the whole community surface and Retry restore
const inertRoot = document.querySelector("[inert]")
return inertRoot?.contains(document.activeElement) ?? false
})).toBe(false)
- const mobileReconnectPath = testInfo.outputPath("390-reconnecting-reduced-motion.png")
+ const mobileReconnectPath = testInfo.outputPath("390-dark-reconnecting-reduced-motion.png")
await alice.page.screenshot({ path: mobileReconnectPath })
- await testInfo.attach("390-reconnecting-reduced-motion.png", {
+ await testInfo.attach("390-dark-reconnecting-reduced-motion.png", {
path: mobileReconnectPath,
contentType: "image/png",
})
await alice.page.setViewportSize({ width: 1280, height: 900 })
expect(await overlay.boundingBox()).toMatchObject({ x: 0, y: 0, width: 1280, height: 900 })
- const desktopReconnectPath = testInfo.outputPath("1280-reconnecting-reduced-motion.png")
+ const desktopReconnectPath = testInfo.outputPath("1280-dark-reconnecting-reduced-motion.png")
await alice.page.screenshot({ path: desktopReconnectPath })
- await testInfo.attach("1280-reconnecting-reduced-motion.png", {
+ await testInfo.attach("1280-dark-reconnecting-reduced-motion.png", {
path: desktopReconnectPath,
contentType: "image/png",
})
+
+ await alice.page.emulateMedia({ reducedMotion: "reduce", colorScheme: "light" })
+ await expect.poll(() => alice.page.evaluate(() => document.documentElement.classList.contains("dark")))
+ .toBe(false)
+ const desktopLightReconnectPath = testInfo.outputPath("1280-light-reconnecting-reduced-motion.png")
+ await alice.page.screenshot({ path: desktopLightReconnectPath })
+ await testInfo.attach("1280-light-reconnecting-reduced-motion.png", {
+ path: desktopLightReconnectPath,
+ contentType: "image/png",
+ })
+
await alice.page.setViewportSize({ width: 390, height: 844 })
+ const mobileLightReconnectPath = testInfo.outputPath("390-light-reconnecting-reduced-motion.png")
+ await alice.page.screenshot({ path: mobileLightReconnectPath })
+ await testInfo.attach("390-light-reconnecting-reduced-motion.png", {
+ path: mobileLightReconnectPath,
+ contentType: "image/png",
+ })
const retry = alice.page.getByTestId(tid.wsRetry)
await expect(retry).toBeVisible({ timeout: 40_000 })