Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Page card: glaze the preview into the footer

luishron123e550d9c36217
diff --git a/src/components/app/AppChrome.tsx b/src/components/app/AppChrome.tsx
index 38fea0a7d9..9d3af47181 100644
--- a/src/components/app/AppChrome.tsx
+++ b/src/components/app/AppChrome.tsx
@@ -70,10 +70,14 @@ export function AppHeader({
);
}
-export function PageCardFooter({ title, detail, updated, infoId, infoOpen, onInfo, onReload, reloading = false }: {
+/** Over the foot of a page preview: the page blurs and fades into the card, so the footer reads as part of it. */
+export const PAGE_GLAZE = "pointer-events-none absolute inset-x-0 bottom-0 h-20 bg-gradient-to-t from-composer to-transparent backdrop-blur-md [mask-image:linear-gradient(to_bottom,transparent,black)]";
+
+export function PageCardFooter({ title, detail, updated, glazed = false, infoId, infoOpen, onInfo, onReload, reloading = false }: {
title: string;
detail: string;
updated: boolean;
+ glazed?: boolean;
infoId: string;
infoOpen: boolean;
onInfo(): void;
@@ -81,7 +85,7 @@ export function PageCardFooter({ title, detail, updated, infoId, infoOpen, onInf
reloading?: boolean;
}) {
return (
- <div data-page-footer className="flex items-center gap-3 border-t border-ink/[0.08] px-4 py-3">
+ <div data-page-footer className={cn("flex items-center gap-3 px-4 py-3", !glazed && "border-t border-ink/[0.08]")}>
<AppWindow aria-hidden="true" size={16} className="shrink-0 text-ink-tertiary" />
<div className="min-w-0 flex-1">
<div title={title} className="truncate text-[13px] font-medium leading-[18px] text-ink"><bdi dir="auto">{title}</bdi></div>
diff --git a/src/components/app/AppMessage.compact.test.ts b/src/components/app/AppMessage.compact.test.ts
index 3eaf1d71c1..1042aadfde 100644
--- a/src/components/app/AppMessage.compact.test.ts
+++ b/src/components/app/AppMessage.compact.test.ts
@@ -64,6 +64,15 @@ describe("a bot's page as a compact card", () => {
expect(Array.from(card().querySelectorAll("button"), (button) => button.getAttribute("aria-label"))).toEqual(["About this app", "Reload app", "Open page"]);
});
+ it("glazes the foot of the preview into the footer, and only while there is a preview", async () => {
+ await render(row(payload()));
+ expect(card().querySelector("[data-app-box] [data-page-glaze]")).not.toBeNull();
+ expect(card().querySelector("[data-page-footer]")!.className).not.toContain("border-t");
+ await press(opener());
+ expect(card().querySelector("[data-page-glaze]")).toBeNull();
+ expect(card().querySelector("[data-page-footer]")!.className).toContain("border-t");
+ });
+
it("names the version once the page has been updated", async () => {
await render(row(payload({ rev: 1, doc: "d1", history: ["d0"] })));
expect(card().querySelector("[data-page-footer]")!.textContent).toBe("PricingPage · v2");
diff --git a/src/components/app/AppMessage.tsx b/src/components/app/AppMessage.tsx
index 7e4665557b..5bfc02f343 100644
--- a/src/components/app/AppMessage.tsx
+++ b/src/components/app/AppMessage.tsx
@@ -7,7 +7,7 @@ import { appBlockedLine } from "./app-blocked";
import { APP_FRAME_LIMITS } from "../../../shared/app-frame/bridge";
import { AppDocumentError, fetchAppDocument, type AppFetchFailure } from "./app-api";
import { APP_POOL_LIMITS, useAppPoolSlot, type AppPool } from "./app-pool";
-import { AppDone, AppHeader, AppInfo, AppOpenButton, AppPlaceholder, AppStrip, APP_SURFACE, PageCardFooter } from "./AppChrome";
+import { AppDone, AppHeader, AppInfo, AppOpenButton, AppPlaceholder, AppStrip, APP_SURFACE, PAGE_GLAZE, PageCardFooter } from "./AppChrome";
import { AppFrame, type AppFrameHandle, type AppFrameProblem } from "./AppFrame";
import type { AppSelection } from "./app-frame-host";
import { PageCitationButton } from "../CitationUI";
@@ -254,8 +254,10 @@ function AppRow({ botId, botName, threadId, message, payload, pool, room }: {
) : (
<AppPlaceholder height={boxHeight} loading={slot.live} open={slot.live ? undefined : reloadNow} />
)}
+ {compact && <div aria-hidden="true" data-page-glaze className={PAGE_GLAZE} />}
</div>
);
+ const glazed = compact && !collapsed && !noPage && !(fullScreen && current);
const info = infoOpen && <AppInfo id={infoId} network={payload.network ?? { connect: [], resources: [] }} bytes={payload.bytes ?? 0} bordered={bordered || compact} />;
const reopen = collapsed && (
<div className={cn("flex", bordered || compact ? "px-4 pb-3.5" : "pb-2", compact && "pt-3.5")}>
@@ -277,7 +279,7 @@ function AppRow({ botId, botName, threadId, message, payload, pool, room }: {
className={cn("w-full text-start", WIDTH)}
>
{compact ? (
- <div className={APP_SURFACE}>
+ <div className={cn(APP_SURFACE, "shadow-(--shadow-float)")}>
<div className="group/page relative">
{reopen}
{body}
@@ -285,6 +287,7 @@ function AppRow({ botId, botName, threadId, message, payload, pool, room }: {
title={payload.title}
detail={version.last > 0 ? `${kind} · ${t("chat.preview.version", { n: version.rev + 1 })}` : kind}
updated={version.flash}
+ glazed={glazed}
infoId={infoId}
infoOpen={infoOpen}
onInfo={() => setInfoOpen((open) => !open)}