From 6a94c64fa23633d339c1c3e57c00b7899bbb6547 Mon Sep 17 00:00:00 2001 From: Emma Segal-Grossman Date: Tue, 28 May 2024 14:02:49 -0400 Subject: [PATCH] ensure loader fills image swiper, and only display loader when replay data is nullish, not when it's loaded but there's no image data (#1819) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1818 - Refactors image renderers, and changes the condition for which the loading indicator is displayed from "`.blobUrl` exists and has a truthey value" to "`` is not nullish" - Adds an additional class config to the shared QA loading indicator, and uses it in the image slider view to add a background and aspect ratio to the loading indicator's container so that it takes up the space it should and has an opaque background | Before | After | | --- | --- | | Screenshot 2024-05-22 at 5 17 14 PM | Screenshot 2024-05-22 at 5 17 31 PM | --- .../org/archived-item-qa/ui/screenshots.ts | 36 ++++++++----------- .../pages/org/archived-item-qa/ui/spinner.ts | 10 +++--- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/frontend/src/pages/org/archived-item-qa/ui/screenshots.ts b/frontend/src/pages/org/archived-item-qa/ui/screenshots.ts index 50234a73..3ab61b8f 100644 --- a/frontend/src/pages/org/archived-item-qa/ui/screenshots.ts +++ b/frontend/src/pages/org/archived-item-qa/ui/screenshots.ts @@ -2,13 +2,14 @@ import { msg } from "@lit/localize"; import clsx from "clsx"; import { html } from "lit"; import { guard } from "lit/directives/guard.js"; -import { when } from "lit/directives/when.js"; import type { BlobPayload, ReplayData } from "../types"; import { renderSpinner } from "./spinner"; -function image(blobUrl: BlobPayload["blobUrl"]) { +import { tw } from "@/utils/tailwind"; + +function image(blobUrl: BlobPayload["blobUrl"] | undefined) { if (!blobUrl) { return html`
+ guard(data, () => (data != null ? image(data.blobUrl) : imageSpinner)); + export function renderScreenshots( crawlData: ReplayData, qaData: ReplayData, splitView: boolean, ) { + const crawlImage = renderImage(crawlData); + const qaImage = renderImage(qaData); const content = html`

- ${when( - crawlData?.blobUrl !== undefined && crawlData.blobUrl, - image, - renderSpinner, - )} + ${crawlImage}

- ${when( - qaData?.blobUrl !== undefined && qaData.blobUrl, - image, - renderSpinner, - )} + ${qaImage}
` : html` @@ -83,18 +83,10 @@ export function renderScreenshots( >
- ${when( - crawlData?.blobUrl !== undefined && crawlData.blobUrl, - image, - renderSpinner, - )} + ${crawlImage}
- ${when( - qaData?.blobUrl !== undefined && qaData.blobUrl, - image, - renderSpinner, - )} + ${qaImage}
diff --git a/frontend/src/pages/org/archived-item-qa/ui/spinner.ts b/frontend/src/pages/org/archived-item-qa/ui/spinner.ts index 70674929..2b63e6a4 100644 --- a/frontend/src/pages/org/archived-item-qa/ui/spinner.ts +++ b/frontend/src/pages/org/archived-item-qa/ui/spinner.ts @@ -1,10 +1,12 @@ +import clsx from "clsx"; import { html } from "lit"; -import { tw } from "@/utils/tailwind"; - -export function renderSpinner() { +export function renderSpinner(className?: clsx.ClassValue) { return html`
`;