Skip to content

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

Add a linocut night card to the top of the Cloud plans sheet and the Cloud Pro popup

milind-sonidf01da1e2dbc
diff --git a/docs/cloud-pro.md b/docs/cloud-pro.md
index 04c9f7a959..63d7b83014 100644
--- a/docs/cloud-pro.md
+++ b/docs/cloud-pro.md
@@ -2023,7 +2023,9 @@ screen's note.
the menu is.
- **The dialog** (`components/CloudAddDialog.tsx`, one state→view function,
`lib/cloud-plan` `cloudAddView`) covers the buying journey only: the offer
- (MausBot Cloud's name beside its three mascots and one line, then one card
+ (the night card: MausBot Cloud's name and one line over a linocut night sky
+ where the three bots ride a cloud while this computer's laptop sleeps, with
+ Compare plans in the card; then one card
per plan the Admin sells, side by side on a wide sheet and stacked in a
narrow window, from `lib/cloud-plan` `planCards`: its name, "Most popular"
as a quiet tag on the Admin's recommended plan only, the price per month,
diff --git a/docs/verification/evidence/pricing-night-card/choose-1040-daylight.jpg b/docs/verification/evidence/pricing-night-card/choose-1040-daylight.jpg
new file mode 100644
index 0000000000..3783a98ffd
Binary files /dev/null and b/docs/verification/evidence/pricing-night-card/choose-1040-daylight.jpg differ
diff --git a/docs/verification/evidence/pricing-night-card/choose-1040-midnight.jpg b/docs/verification/evidence/pricing-night-card/choose-1040-midnight.jpg
new file mode 100644
index 0000000000..4070e508f7
Binary files /dev/null and b/docs/verification/evidence/pricing-night-card/choose-1040-midnight.jpg differ
diff --git a/docs/verification/evidence/pricing-night-card/choose-compare-midnight.jpg b/docs/verification/evidence/pricing-night-card/choose-compare-midnight.jpg
new file mode 100644
index 0000000000..585876cc74
Binary files /dev/null and b/docs/verification/evidence/pricing-night-card/choose-compare-midnight.jpg differ
diff --git a/docs/verification/evidence/pricing-night-card/choose-daylight.jpg b/docs/verification/evidence/pricing-night-card/choose-daylight.jpg
new file mode 100644
index 0000000000..55ab6dd002
Binary files /dev/null and b/docs/verification/evidence/pricing-night-card/choose-daylight.jpg differ
diff --git a/docs/verification/evidence/pricing-night-card/choose-midnight.jpg b/docs/verification/evidence/pricing-night-card/choose-midnight.jpg
new file mode 100644
index 0000000000..1b3f029f20
Binary files /dev/null and b/docs/verification/evidence/pricing-night-card/choose-midnight.jpg differ
diff --git a/docs/verification/evidence/pricing-night-card/concepts.jpg b/docs/verification/evidence/pricing-night-card/concepts.jpg
new file mode 100644
index 0000000000..cfe101a0c5
Binary files /dev/null and b/docs/verification/evidence/pricing-night-card/concepts.jpg differ
diff --git a/docs/verification/evidence/pricing-night-card/daylight-night-vs-dusk.jpg b/docs/verification/evidence/pricing-night-card/daylight-night-vs-dusk.jpg
new file mode 100644
index 0000000000..51f090c532
Binary files /dev/null and b/docs/verification/evidence/pricing-night-card/daylight-night-vs-dusk.jpg differ
diff --git a/docs/verification/evidence/pricing-night-card/pro-popup-daylight.jpg b/docs/verification/evidence/pricing-night-card/pro-popup-daylight.jpg
new file mode 100644
index 0000000000..520fdacdcf
Binary files /dev/null and b/docs/verification/evidence/pricing-night-card/pro-popup-daylight.jpg differ
diff --git a/docs/verification/evidence/pricing-night-card/pro-popup-midnight.jpg b/docs/verification/evidence/pricing-night-card/pro-popup-midnight.jpg
new file mode 100644
index 0000000000..1b23ef7d2f
Binary files /dev/null and b/docs/verification/evidence/pricing-night-card/pro-popup-midnight.jpg differ
diff --git a/scripts/check-skin-contrast.mjs b/scripts/check-skin-contrast.mjs
index ed63122d3d..969be58965 100644
--- a/scripts/check-skin-contrast.mjs
+++ b/scripts/check-skin-contrast.mjs
@@ -243,4 +243,32 @@ for (const skinId of ["daylight", "pop"]) {
if (!bubbleFailed) console.log(`✓ ${skinId} bubble — editor, controls and paired fills above 4.5:1`);
}
+// MausBot Cloud's night card paints its own sky in every skin: an indigo dusk in the light scheme, a deep night in the
+// dark one. Its text sits between the sky's first two stops; the close button's glyph also lands on the far stop.
+const night = [...css.matchAll(/:root\s*\{([^}]*)\}/g)].map(([, body]) => declarations(body)).find(tokens => tokens["--cloud-night-from"]);
+if (!night) {
+ failed = true;
+ console.log("✗ night card — no :root block defines --cloud-night-from");
+} else {
+ for (const [scheme, pick] of [["dusk", 1], ["night", 2]]) {
+ const value = (token) => /^light-dark\(\s*([^,]+?)\s*,\s*([^)]+?)\s*\)$/.exec(night[token] ?? "")?.[pick] ?? night[token] ?? "";
+ let schemeFailed = false;
+ for (const [fg, bg, min] of [
+ ["--cloud-night-ink", "--cloud-night-from", 4.5],
+ ["--cloud-night-ink", "--cloud-night-mid", 4.5],
+ ["--cloud-night-ink-quiet", "--cloud-night-from", 4.5],
+ ["--cloud-night-ink-quiet", "--cloud-night-mid", 4.5],
+ ["--cloud-night-ink-quiet", "--cloud-night-to", 3],
+ ]) {
+ const ratio = contrast(value(fg), value(bg));
+ if (ratio === null || ratio < min) {
+ failed = true;
+ schemeFailed = true;
+ console.log(`✗ night card (${scheme}) — ${fg} on ${bg}: ${ratio?.toFixed(2) ?? "unmeasurable"}:1 (needs ${min}:1)`);
+ }
+ }
+ if (!schemeFailed) console.log(`✓ night card (${scheme}) — its text and close button clear the sky behind them`);
+ }
+}
+
process.exit(failed ? 1 : 0);
diff --git a/src/components/AppNotices.test.ts b/src/components/AppNotices.test.ts
index 2d33d95f33..aff3276045 100644
--- a/src/components/AppNotices.test.ts
+++ b/src/components/AppNotices.test.ts
@@ -26,7 +26,7 @@ vi.mock("@/state/store", () => ({ useStore: () => ({ state: f.state, dispatch: f
CLOUD_LINK_SETTINGS: { type: "toggleAppSettings", open: true, section: "cloudAccount", cloudLink: true } }));
vi.mock("@/lib/analytics", () => ({ emailGateDone: () => false, track: vi.fn(), identifyEmail: vi.fn(), analyticsChoiceKnown: () => true }));
vi.mock("@/lib/updater", () => ({ useUpdaterState: () => f.updater }));
-vi.mock("./cloud-buy/CloudMascots", () => ({ CloudMascots: () => null }));
+vi.mock("./cloud-buy/NightCard", () => ({ NightCard: ({ children }: { children: unknown }) => children }));
// Who MausBot belongs to: unknown (as before the session answers) unless a test says otherwise.
vi.mock("@/lib/default-bot", async original => ({ ...await original<typeof import("@/lib/default-bot")>(), useViewerEmail: () => f.viewerEmail }));
vi.mock("@/lib/brand", () => ({ brandStatus: () => ({ brand: { name: "OpenMausBot" }, source: f.brand, file: "" }) }));
diff --git a/src/components/CloudAddDialog.test.ts b/src/components/CloudAddDialog.test.ts
index df7551ac75..ce34d67a79 100644
--- a/src/components/CloudAddDialog.test.ts
+++ b/src/components/CloudAddDialog.test.ts
@@ -16,7 +16,7 @@ vi.mock("react", async original => ({ ...await original<typeof import("react")>(
}));
vi.mock("@/state/store", () => ({ useStore: () => ({ state: f.state, dispatch: f.dispatch }) }));
vi.mock("@/lib/analytics", () => ({ track: vi.fn() }));
-vi.mock("./cloud-buy/CloudMascots", () => ({ CloudMascots: () => createElement("i", { "data-cloud-mascots": "" }) }));
+vi.mock("./cloud-buy/NightCard", () => ({ NightCard: ({ children }: { children: ReactNode }) => createElement("div", { "data-night-card": "" }, children) }));
import { CloudAddDialog, CloudAddPanel, CloudAddSheet, type CloudAddActions, type CloudAddUi } from "./CloudAddDialog";
import { ChooseScreen } from "./cloud-buy/ChooseScreen";
import { cloudAddView, type CloudAddView } from "@/lib/cloud-plan";
@@ -92,7 +92,7 @@ describe("each screen of the sheet says one thing and offers one next step", ()
"Every plan includes", "Works while you're away", "Routines, long jobs and replies keep going around the clock.", "Private to you", "Reach it from anywhere",
"A real browser and desktop", "Bring everything over", "Your bots, chats and memory move across in about a minute.",
"Secure checkout in your browser", "Apple Pay", "G Pay", "Card", "Cancel in two clicks", "Already have a plan? Sign in"]);
- expect(html, "the mascots stand before the title").toMatch(/<i data-cloud-mascots=""><\/i><h2 id="cloud-add-title"/);
+ expect(html, "the night card holds the title, the line and Compare plans").toMatch(/<div data-night-card=""><h2 id="cloud-add-title"[^]*Compare plans[^]*<\/div><\/div><section/);
expect(html.match(/data-plan-row="(hours|storage|voice)"/g), "what sets the cards apart, three rows on each").toHaveLength(9);
expect(tree.filter(node => node.props.id?.startsWith?.("cloud-plan-details-")).map(node => node.props.hidden), "the rest waits for Compare plans").toEqual([true, true, true]);
expect(tree.filter(node => node.props["data-plan-buy"]).map(node => node.props.className.includes("ui-button-primary")), "one primary action, on the recommended plan")
@@ -324,6 +324,7 @@ describe("each screen of the sheet says one thing and offers one next step", ()
const sheet = (kind: CloudAddView["kind"], staging = false) => renderToStaticMarkup(createElement(CloudAddSheet, { kind, staging, onClose: vi.fn(), children: "x" }));
expect(sheet("offer")).toContain("max-w-[920px]"); expect(sheet("starting")).toContain("max-w-[720px]"); expect(sheet("waiting")).toContain("max-w-[540px]");
expect(sheet("offer")).toContain('aria-label="Close"');
+ expect(sheet("offer"), "over a night card the close button takes the card's light ink").toContain("group-has-[[data-night-card]]/sheet:text-(--cloud-night-ink-quiet)");
expect(sheet("offer"), "above Settings and the welcome flow (z-50), which it opens over").toContain("fixed inset-0 z-[60]");
expect(sheet("offer")).not.toContain("data-cloud-staging");
expect(text(sheet("offer", true))).toMatch(/Staging ?: This app uses the staging MausBot Cloud: test payments and test Clouds, not real ones\./);
diff --git a/src/components/CloudAddDialog.tsx b/src/components/CloudAddDialog.tsx
index f3bf48d20d..7eca7bfbe4 100644
--- a/src/components/CloudAddDialog.tsx
+++ b/src/components/CloudAddDialog.tsx
@@ -15,7 +15,7 @@ import { useStore } from "@/state/store";
import { ChooseScreen } from "./cloud-buy/ChooseScreen";
import { OneCloudScreen, StatusScreen } from "./cloud-buy/OneCloudScreen";
import { PayScreen } from "./cloud-buy/PayScreen";
-import { CLOSE, SHEET, StagingMark } from "./cloud-buy/parts";
+import { CLOSE, ON_NIGHT, SHEET, StagingMark } from "./cloud-buy/parts";
import { SetupScreen, TeamReadyScreen, TeamSetupScreen } from "./cloud-buy/SetupScreen";
import { BrowserSignInScreen, codeDigits, SignInScreen } from "./cloud-buy/SignInScreen";
@@ -93,9 +93,9 @@ const HELD: ReadonlySet<CloudAddView["kind"]> = new Set(["sign-in", "signing-in"
export function CloudAddSheet({ kind, staging, onClose, children }: { kind: CloudAddView["kind"]; staging: boolean; onClose: () => void; children: ReactNode }) {
return <div className="ui-scrim fixed inset-0 z-[60] flex items-center justify-center p-4 sm:p-6" onMouseDown={event => event.target === event.currentTarget && !HELD.has(kind) && onClose()}>
<div role="dialog" aria-modal="true" aria-labelledby="cloud-add-title" data-cloud-add-dialog tabIndex={-1}
- className={cn(SHEET, "animate-pop-in relative max-h-full w-full overflow-y-auto overscroll-contain outline-none", WIDTH[kind] ?? "max-w-[540px]")}>
- <button type="button" onClick={onClose} aria-label={t("cloudAdd.close")} className={cn(CLOSE, "absolute end-4 top-4 z-10")}><X size={16} /></button>
- {staging && <StagingMark className="absolute end-14 top-[22px] z-10" />}
+ className={cn(SHEET, "group/sheet animate-pop-in relative max-h-full w-full overflow-y-auto overscroll-contain outline-none", WIDTH[kind] ?? "max-w-[540px]")}>
+ <button type="button" onClick={onClose} aria-label={t("cloudAdd.close")} className={cn(CLOSE, ON_NIGHT, "absolute end-4 top-4 z-10")}><X size={16} /></button>
+ {staging && <StagingMark className="absolute end-14 top-[22px] z-10 group-has-[[data-night-card]]/sheet:bg-app" />}
{children}
</div>
</div>;
diff --git a/src/components/CloudProPopup.tsx b/src/components/CloudProPopup.tsx
index 62db16aa06..8589fbc4e6 100644
--- a/src/components/CloudProPopup.tsx
+++ b/src/components/CloudProPopup.tsx
@@ -8,8 +8,8 @@ import { cn } from "@/lib/cn";
import { buyOfferAllowed, cloudIntroView, cloudPlanLabel, cloudPlanLine, cloudPlanView, moneyBackLine, trialRunning, usd, type CloudPlanView, type CloudSource } from "@/lib/cloud-plan";
import { t } from "@/lib/i18n";
import { cloudPlanFromAccount, cloudPlanFromSnapshot, type CloudPlanFacts } from "@/lib/usage-snapshot";
-import { CloudMascots } from "./cloud-buy/CloudMascots";
-import { CLOSE, PRIMARY, QUIET, SHEET, Tag } from "./cloud-buy/parts";
+import { NightCard } from "./cloud-buy/NightCard";
+import { CLOSE, ON_NIGHT, PRIMARY, QUIET, SHEET, Tag, TAG_ON_NIGHT } from "./cloud-buy/parts";
import { NotNowButton } from "./NoticeCard";
import { UPDATES_CONSENT_POPUP } from "./UpdatesConsent";
@@ -162,13 +162,14 @@ export function CloudProPopup({ view, onPrimary, onSeePlans, onNotNow, onClose }
}, [onClose]);
return <div className="ui-scrim fixed inset-0 z-50 flex items-center justify-center p-6" onMouseDown={event => { if (event.target === event.currentTarget) onClose(); }}>
<div role="dialog" aria-modal="true" aria-labelledby={TITLE} aria-describedby="cloud-pro-popup-body" data-cloud-pro-popup={view.plan} tabIndex={-1}
- className={cn(SHEET, "animate-pop-in relative max-h-full w-full max-w-[440px] overflow-y-auto px-6 pb-4 pt-5 outline-none")}>
- <div className="flex min-h-8 flex-wrap items-center gap-x-2.5 gap-y-1 pe-10">
- <CloudMascots size={22} />
- <h2 id={TITLE} tabIndex={-1} className="text-[17px] font-medium leading-6 tracking-[-0.008em] outline-none!">{t("cloudProPopup.title")}</h2>
- {view.badge && <Tag>{view.badge}</Tag>}
+ className={cn(SHEET, "group/sheet animate-pop-in relative max-h-full w-full max-w-[440px] overflow-y-auto px-6 pb-4 pt-5 outline-none")}>
+ <div className="-mx-4 -mt-3">
+ <NightCard small>
+ <h2 id={TITLE} tabIndex={-1} className="text-[17px] font-medium leading-6 tracking-[-0.008em] outline-none!">{t("cloudProPopup.title")}</h2>
+ {view.badge && <Tag className={cn("mt-1.5 self-start", TAG_ON_NIGHT)}>{view.badge}</Tag>}
+ </NightCard>
</div>
- <div id="cloud-pro-popup-body" className="mt-2 flex flex-col gap-4">
+ <div id="cloud-pro-popup-body" className="mt-4 flex flex-col gap-4">
<p className="text-[14px] leading-5 text-ink-secondary [text-wrap:pretty]">{t("cloudIntro.body")}</p>
<ul className="flex flex-col gap-2 text-[14px] leading-5">
{view.points.map(point => <li key={point} className="flex items-start gap-2.5"><Check size={16} strokeWidth={1.5} className="mt-0.5 shrink-0 text-ink-tertiary" aria-hidden="true" />{point}</li>)}
@@ -186,7 +187,7 @@ export function CloudProPopup({ view, onPrimary, onSeePlans, onNotNow, onClose }
<p className="min-w-0 flex-1 text-[12px] leading-4 text-ink-tertiary">{t("pro.disclaimer")}</p>
<NotNowButton onClick={onNotNow} />
</div>
- <button type="button" onClick={onClose} aria-label={t("cloudAdd.close")} className={cn(CLOSE, "absolute end-4 top-4")}><X size={16} /></button>
+ <button type="button" onClick={onClose} aria-label={t("cloudAdd.close")} className={cn(CLOSE, ON_NIGHT, "absolute end-4 top-4")}><X size={16} /></button>
</div>
</div>;
}
diff --git a/src/components/cloud-buy/ChooseScreen.tsx b/src/components/cloud-buy/ChooseScreen.tsx
index 3c1212d2c1..e4305bf60e 100644
--- a/src/components/cloud-buy/ChooseScreen.tsx
+++ b/src/components/cloud-buy/ChooseScreen.tsx
@@ -7,8 +7,8 @@ import { cn } from "@/lib/cn";
import { cardRows, moneyBackShort, planCards, sharedTrialDays, trialTimeline, type CloudPlanCard, type CloudPlanCardRow } from "@/lib/cloud-plan";
import { t } from "@/lib/i18n";
import type { LocaleKey } from "@/locales";
-import { CloudMascots } from "./CloudMascots";
-import { Heading, LINK, PRIMARY_WIDE, QUIET_WIDE, SCREEN, Tag } from "./parts";
+import { NightCard } from "./NightCard";
+import { LINK, PRIMARY_WIDE, QUIET_WIDE, SCREEN, Tag } from "./parts";
const FEATURES: ReadonlyArray<readonly [LucideIcon, LocaleKey, LocaleKey]> = [
[Moon, "cloudBuy.benefit.awayTitle", "cloudBuy.benefit.away"],
@@ -81,13 +81,17 @@ export function ChooseScreen({ offer, current = null, own = null, now, busy, sig
const moneyBack = moneyBackShort(offer);
const trial = Boolean(sharedTrialDays(offer));
return <div data-cloud-add={offer.plans.some(plan => plan.trialDays) ? "offer-trial" : "offer"} className={SCREEN}>
- <div className="grid gap-y-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-end sm:gap-x-6">
- <Heading mark={<CloudMascots size={22} />} title={t("pro.name")}
- sub={<><span className="font-medium text-ink">{t("cloudBuy.title")}</span> {t("cloudBuy.lede")}</>} />
- <button type="button" aria-expanded={compare} aria-controls={cards.map(card => detailsId(card.tier)).join(" ")} onClick={() => setCompare(!compare)}
- className="-ms-2.5 inline-flex items-center gap-1 justify-self-start rounded-full py-0.5 pe-1.5 ps-2.5 text-[13px] leading-[18px] text-ink-secondary transition-colors hover:bg-ink/[0.06] hover:text-ink sm:-me-2 sm:ms-0 sm:justify-self-end motion-reduce:transition-none">
- {t("pro.seePlans")}<ChevronDown size={14} strokeWidth={1.5} aria-hidden="true" className={cn("transition-transform motion-reduce:transition-none", compare && "rotate-180")} />
- </button>
+ <div className="-mx-4 -mt-3">
+ <NightCard>
+ <h2 id="cloud-add-title" tabIndex={-1} className="text-[17px] font-medium leading-6 tracking-[-0.008em] outline-none!">{t("pro.name")}</h2>
+ <p className="mt-0.5 max-w-[440px] text-[14px] leading-5 text-(--cloud-night-ink-quiet) [text-wrap:pretty]">
+ <span className="font-medium text-(--cloud-night-ink)">{t("cloudBuy.title")}</span> {t("cloudBuy.lede")}
+ </p>
+ <button type="button" aria-expanded={compare} aria-controls={cards.map(card => detailsId(card.tier)).join(" ")} onClick={() => setCompare(!compare)}
+ className="-ms-2 mt-2 inline-flex items-center gap-1 self-start rounded-full py-0.5 pe-1.5 ps-2 text-[13px] leading-[18px] text-(--cloud-night-ink-quiet) transition-colors hover:bg-white/10 hover:text-(--cloud-night-ink) motion-reduce:transition-none">
+ {t("pro.seePlans")}<ChevronDown size={14} strokeWidth={1.5} aria-hidden="true" className={cn("transition-transform motion-reduce:transition-none", compare && "rotate-180")} />
+ </button>
+ </NightCard>
</div>
{notice && <p role="status" className="rounded-[12px] bg-ink/[0.04] px-4 py-3 text-[13px] leading-[18px] text-ink">{notice}</p>}
<section aria-labelledby="cloud-add-plans">
diff --git a/src/components/cloud-buy/CloudMascots.tsx b/src/components/cloud-buy/CloudMascots.tsx
deleted file mode 100644
index f830be0bea..0000000000
--- a/src/components/cloud-buy/CloudMascots.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-// MausBot Cloud's mark: three of the app's own Maus bots, small, beside the Cloud's name.
-import { memo, useEffect, useRef, useState, useSyncExternalStore, type RefObject } from "react";
-import { MausAvatar } from "@/components/Avatar";
-import type { MausColor, MausState } from "@/lib/mascot";
-import { reducedMotion } from "@/lib/onboarding";
-
-/** Each bot keeps one calm state, which the mascot animates by itself (its faces, blinks and a slow bob or sway). */
-const CREW: readonly { color: MausColor; state: MausState }[] = [
- { color: "orange", state: "working" },
- { color: "pink", state: "idle" },
- { color: "green", state: "thinking" },
-];
-
-function subscribeReducedMotion(changed: () => void) {
- const query = globalThis.window?.matchMedia?.("(prefers-reduced-motion: reduce)");
- query?.addEventListener?.("change", changed);
- const root = globalThis.document?.documentElement;
- const hook = root && typeof MutationObserver === "function" ? new MutationObserver(changed) : null;
- if (root) hook?.observe(root, { attributes: true, attributeFilter: ["data-reduced-motion"] });
- return () => {
- query?.removeEventListener?.("change", changed);
- hook?.disconnect();
- };
-}
-
-function useInView(target: RefObject<HTMLElement | null>) {
- const [inView, setInView] = useState(true);
- useEffect(() => {
- const node = target.current;
- if (!node || typeof IntersectionObserver !== "function") return;
- const watch = new IntersectionObserver(entries => setInView(entries.at(-1)?.isIntersecting ?? true));
- watch.observe(node);
- return () => watch.disconnect();
- }, [target]);
- return inView;
-}
-
-/** Hidden from screen readers: the name beside it says what it is. */
-export const CloudMascots = memo(function CloudMascots({ size = 20 }: { size?: number }) {
- const root = useRef<HTMLSpanElement>(null);
- const inView = useInView(root);
- const live = !useSyncExternalStore(subscribeReducedMotion, reducedMotion, reducedMotion);
- const moving = live && inView;
- return <span ref={root} aria-hidden="true" data-cloud-mascots="" data-paused={moving ? undefined : ""} className="inline-flex shrink-0 items-center gap-0.5">
- {CREW.map(({ color, state }) => <MausAvatar key={color} color={color} state={state} size={size} animated={moving} trackPointer={false} />)}
- </span>;
-});
diff --git a/src/components/cloud-buy/CloudMascots.test.ts b/src/components/cloud-buy/NightCard.test.ts
similarity index 54%
rename from src/components/cloud-buy/CloudMascots.test.ts
rename to src/components/cloud-buy/NightCard.test.ts
index 9d86ce44ed..2f660c916a 100644
--- a/src/components/cloud-buy/CloudMascots.test.ts
+++ b/src/components/cloud-buy/NightCard.test.ts
@@ -1,4 +1,5 @@
// @vitest-environment happy-dom
+import { readFileSync } from "node:fs";
import { act, createElement } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
@@ -6,18 +7,19 @@ import { MAUS_COLOR_NAMES } from "@/lib/mascot";
type Seen = { color: string; state: string; animated: boolean; trackPointer?: boolean; size: number };
vi.mock("@/components/Avatar", () => ({
- MausAvatar: ({ color, state, animated, trackPointer, size, ...choreography }: Seen) => createElement("i", {
- "data-maus": color, "data-state": state, "data-animated": String(animated), "data-pointer": String(trackPointer), "data-size": String(size),
+ MausAvatar: ({ color, state, animated, trackPointer, size: _size, ...choreography }: Seen) => createElement("i", {
+ "data-maus": color, "data-state": state, "data-animated": String(animated), "data-pointer": String(trackPointer),
"data-extra": Object.keys(choreography).join(",") }),
}));
-const { CloudMascots } = await import("./CloudMascots");
+const { NightCard } = await import("./NightCard");
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
let host: HTMLDivElement, root: Root;
-const render = async (size?: number) => { await act(async () => { root.render(createElement(CloudMascots, size === undefined ? {} : { size })); }); };
-const mark = () => host.querySelector<HTMLElement>("[data-cloud-mascots]")!;
+const render = async (small = false) => { await act(async () => { root.render(createElement(NightCard, { small, children: createElement("h2", null, "MausBot Cloud") })); }); };
+const card = () => host.querySelector<HTMLElement>("[data-night-card]")!;
const mascots = () => [...host.querySelectorAll<HTMLElement>("[data-maus]")];
const animated = () => mascots().map(node => node.dataset.animated);
+const motion = () => ["twinkle", "z", "shoot"].map(name => host.querySelectorAll(`.cloud-night-${name}`).length);
beforeEach(() => { host = document.createElement("div"); document.body.append(host); root = createRoot(host); });
afterEach(async () => {
@@ -27,7 +29,14 @@ afterEach(async () => {
vi.useRealTimers(); vi.unstubAllGlobals(); vi.restoreAllMocks();
});
-it("three of the app's own mascots in three colours, each in its own calm state, small and hidden from screen readers beside the name", async () => {
+it("the scene is hidden from screen readers: the card's own text is what is read", async () => {
+ await render();
+ expect(card().querySelector("svg")!.getAttribute("aria-hidden")).toBe("true");
+ expect(card().textContent).toBe("MausBot Cloud");
+ expect(card().querySelector("h2")!.closest("svg"), "the text sits outside the scene").toBeNull();
+});
+
+it("three of the app's own mascots ride the cloud in three colours, each in a calm state, never following the pointer", async () => {
await render();
const colors = mascots().map(node => node.dataset.maus!);
expect(colors).toHaveLength(3);
@@ -35,38 +44,44 @@ it("three of the app's own mascots in three colours, each in its own calm state,
for (const color of colors) expect(MAUS_COLOR_NAMES).toContain(color);
expect(mascots().map(node => node.dataset.state)).toEqual(["working", "idle", "thinking"]);
expect(mascots().map(node => node.dataset.extra), "no faces, gazes or motions laid on top").toEqual(["", "", ""]);
- expect(mascots().map(node => node.dataset.pointer), "they never follow the pointer").toEqual(["false", "false", "false"]);
- expect(mascots().map(node => node.dataset.size)).toEqual(["20", "20", "20"]);
- expect(mark().getAttribute("aria-hidden")).toBe("true");
- await render(22);
- expect(mascots().map(node => node.dataset.size)).toEqual(["22", "22", "22"]);
+ expect(mascots().map(node => node.dataset.pointer)).toEqual(["false", "false", "false"]);
});
-it("live, the only motion is the mascots' own: no timer or frame of its own", async () => {
+it("live, one star twinkles, the z's drift and now and then a star shoots, all in CSS: no timer or frame of its own", async () => {
vi.useFakeTimers();
await render();
- expect(mark().hasAttribute("data-paused")).toBe(false);
+ expect(card().hasAttribute("data-paused")).toBe(false);
expect(animated()).toEqual(["true", "true", "true"]);
+ expect(motion(), "twinkling stars, drifting z's, shooting stars").toEqual([1, 3, 1]);
expect(vi.getTimerCount(), "no setTimeout, setInterval or requestAnimationFrame").toBe(0);
const markup = host.innerHTML;
await act(async () => { vi.advanceTimersByTime(60_000); });
expect(host.innerHTML, "nothing changes on a clock").toBe(markup);
});
-it("reduced motion holds them still", async () => {
+it("its CSS moves three things, slowly, and holds them while paused", () => {
+ const css = readFileSync("src/styles.css", "utf8");
+ expect([...css.matchAll(/@keyframes (cloud-night-[\w-]+)/g)].map(match => match[1])).toEqual(["cloud-night-twinkle", "cloud-night-z", "cloud-night-shoot"]);
+ for (const [, seconds] of css.matchAll(/animation: cloud-night-[\w-]+ ([\d.]+)s/g)) expect(Number(seconds)).toBeGreaterThanOrEqual(7);
+ expect(css).toContain(".cloud-night[data-paused] * { animation-play-state: paused; }");
+});
+
+it("reduced motion is the same scene held still: no animation at all and the mascots still", async () => {
document.documentElement.dataset.reducedMotion = "true";
await render();
+ expect(motion()).toEqual([0, 0, 0]);
expect(animated()).toEqual(["false", "false", "false"]);
- expect(mark().hasAttribute("data-paused")).toBe(true);
+ expect(host.querySelectorAll("[style*='animation']")).toHaveLength(0);
+ expect(host.querySelectorAll("path[d^='M-2.6-2.6']"), "the z's still rise from the laptop").toHaveLength(3);
});
-it("the system setting or the dev hook, switched while they are shown, stills them at once and lets them go again", async () => {
+it("the system setting or the dev hook, switched while the card is shown, stills it at once and lets it go again", async () => {
let reduce = false;
const changes = new Set<() => void>();
vi.spyOn(window, "matchMedia").mockImplementation(query => ({ matches: reduce && query.includes("reduce"), media: query,
addEventListener: (_: string, changed: () => void) => changes.add(changed), removeEventListener: (_: string, changed: () => void) => changes.delete(changed) }) as unknown as MediaQueryList);
- const still = () => animated().every(flag => flag === "false");
- const moving = () => animated().every(flag => flag === "true");
+ const still = () => motion().every(count => count === 0) && animated().every(flag => flag === "false");
+ const moving = () => motion().every(count => count > 0) && animated().every(flag => flag === "true");
await render();
expect(moving()).toBe(true);
reduce = true;
@@ -81,7 +96,7 @@ it("the system setting or the dev hook, switched while they are shown, stills th
expect(moving(), "dev hook off").toBe(true);
});
-it("out of view they hold still until they are back", async () => {
+it("out of view it holds: the mascots stop and the CSS animations pause until it is back", async () => {
let visible: (seen: boolean) => void = () => {};
vi.stubGlobal("IntersectionObserver", class {
constructor(report: IntersectionObserverCallback) {
@@ -91,11 +106,17 @@ it("out of view they hold still until they are back", async () => {
disconnect() {}
});
await render();
- expect(animated()).toEqual(["true", "true", "true"]);
await act(async () => visible(false));
- expect(mark().hasAttribute("data-paused")).toBe(true);
+ expect(card().hasAttribute("data-paused")).toBe(true);
expect(animated()).toEqual(["false", "false", "false"]);
await act(async () => visible(true));
- expect(mark().hasAttribute("data-paused")).toBe(false);
+ expect(card().hasAttribute("data-paused")).toBe(false);
expect(animated()).toEqual(["true", "true", "true"]);
});
+
+it("the Cloud Pro popup's card is the smaller one", async () => {
+ await render();
+ expect(card().className).toContain("h-[120px]");
+ await render(true);
+ expect(card().className).toContain("h-[92px]");
+});
diff --git a/src/components/cloud-buy/NightCard.tsx b/src/components/cloud-buy/NightCard.tsx
new file mode 100644
index 0000000000..f781f11e34
--- /dev/null
+++ b/src/components/cloud-buy/NightCard.tsx
@@ -0,0 +1,85 @@
+// MausBot Cloud's night card, cut like a linocut: the three bots ride a cloud under the moon while this computer's
+// laptop sleeps on the hill.
+import { memo, useRef, type ReactNode } from "react";
+import { MausAvatar } from "@/components/Avatar";
+import { cn } from "@/lib/cn";
+import type { MausColor, MausState } from "@/lib/mascot";
+import { useLiveMotion } from "./live-motion";
+
+/** [x, y, radius, seconds per twinkle (0: steady), delay] in the card's 900×120 sky; the scene keeps to x ≥ 600. */
+const STARS = [
+ [20, 10, 0.7, 0, 0], [420, 108, 0.6, 0, 0], [472, 16, 0.9, 0, 0], [530, 106, 0.7, 0, 0], [566, 12, 1.1, 9, -3],
+ [598, 92, 0.7, 0, 0], [742, 10, 0.8, 0, 0], [652, 106, 0.6, 0, 0], [884, 74, 0.8, 0, 0],
+] as const;
+const SPARKLES = [[640, 20, 4.2], [712, 40, 3], [868, 62, 3.2]] as const;
+const CREW: readonly { color: MausColor; state: MausState; spot: readonly [x: number, y: number, size: number] }[] = [
+ { color: "orange", state: "working", spot: [636, 52, 28] },
+ { color: "pink", state: "idle", spot: [668, 46, 30] },
+ { color: "green", state: "thinking", spot: [702, 52, 28] },
+];
+const Z = "M-2.6-2.6h5.2l-5.2 5.2h5.2";
+
+const sparkle = (r: number) => `M0 ${-r}L${r * 0.22} ${-r * 0.22}L${r} 0L${r * 0.22} ${r * 0.22}L0 ${r}L${-r * 0.22} ${r * 0.22}L${-r} 0L${-r * 0.22} ${-r * 0.22}Z`;
+
+/** The shut laptop, asleep on the near hill: still z's in reduced motion, drifting ones otherwise. */
+function Laptop({ moving }: { moving: boolean }) {
+ return <g transform="translate(850 98)">
+ <ellipse cy="6.2" rx="25" ry="2.6" fill="#000" opacity=".3" />
+ <path d="M-23.5 1.6H23.5L21.6 5.2H-21.6Z" fill="var(--cloud-night-laptop-edge)" />
+ <path d="M-19.5-6.6H19.5L23.5 1.6H-23.5Z" fill="var(--cloud-night-laptop)" />
+ <path d="M-19.5-6.6H19.5L20.1-5.4H-20.1Z" fill="#fff" opacity=".45" />
+ <ellipse cy="-2.4" rx="2.2" ry="1.3" fill="var(--cloud-night-laptop-edge)" opacity=".55" />
+ <circle cx="17.2" cy="3.4" r=".8" fill="#9df0c4" />
+ <g transform="translate(22 -14)">
+ {[[0, 0, 0.6], [7, -8, 0.8], [15, -17, 1]].map(([x, y, scale]) =>
+ <g key={x} className={moving ? "cloud-night-z" : undefined} transform={`translate(${x} ${y}) scale(${scale})`}>
+ <path d={Z} fill="none" stroke="var(--cloud-night-z)" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
+ </g>)}
+ </g>
+ </g>;
+}
+
+const Scene = memo(function Scene({ moving }: { moving: boolean }) {
+ return <svg aria-hidden="true" viewBox="0 0 900 120" preserveAspectRatio="xMaxYMax slice" className="absolute inset-0 size-full">
+ <g fill="var(--cloud-night-star)">
+ {STARS.map(([x, y, r, seconds, delay]) => <circle key={`${x}-${y}`} cx={x} cy={y} r={r} opacity={seconds ? undefined : 0.6}
+ {...(moving && seconds ? { className: "cloud-night-twinkle", style: { animationDuration: `${seconds}s`, animationDelay: `${delay}s` } } : {})} />)}
+ </g>
+ <g fill="var(--cloud-night-paper)">
+ {SPARKLES.map(([x, y, r]) => <path key={x} transform={`translate(${x} ${y})`} d={sparkle(r)} />)}
+ </g>
+ {moving && <path className="cloud-night-shoot" d="M600 14l30 9" stroke="var(--cloud-night-star)" strokeWidth="1.2" strokeLinecap="round" />}
+ <circle cx="770" cy="44" r="27" fill="var(--cloud-night-paper)" />
+ <g fill="none" stroke="var(--cloud-night-carve)" strokeWidth="1.1" strokeLinecap="round">
+ <circle cx="760" cy="34" r="4.5" /><circle cx="776" cy="30" r="2.2" /><circle cx="783" cy="50" r="3.2" /><path d="M748 46c1 6 4 11 9 15" />
+ </g>
+ <path d="M560 120C610 98 662 86 724 90S846 82 900 76V120Z" fill="var(--cloud-night-far)" />
+ <path d="M610 120C660 106 712 100 772 104S860 98 900 96V120Z" fill="var(--cloud-night-near)" />
+ <g stroke="var(--cloud-night-far)" strokeWidth="1" strokeLinecap="round">
+ {[[680, 112], [700, 108], [722, 112], [800, 112], [822, 108], [878, 110]].map(([x, y]) => <path key={x} d={`M${x} ${y}l9-3`} />)}
+ </g>
+ <g fill="var(--cloud-night-paper)">
+ <rect x="622" y="71" width="124" height="21" rx="10.5" />
+ <circle cx="656.7" cy="71" r="17.7" /><circle cx="690.2" cy="66.2" r="23.2" /><circle cx="718.7" cy="73" r="16" />
+ </g>
+ <g fill="none" stroke="var(--cloud-night-carve)" strokeWidth="1" strokeLinecap="round">
+ <path d="M640 86c6-4 12-4 18 0" /><path d="M676 82c7-5 15-5 22 0" /><path d="M712 86c5-3 10-3 15 0" />
+ </g>
+ {CREW.map(({ color, state, spot: [x, y, size] }) => <foreignObject key={color} x={x} y={y} width={size} height={size} overflow="visible">
+ <MausAvatar color={color} state={state} size={size} animated={moving} trackPointer={false} />
+ </foreignObject>)}
+ <Laptop moving={moving} />
+ </svg>;
+});
+
+/** `children` is the card's text, over the empty sky on the left; the scene keeps right, clear of a close button in the corner.
+ * `small` is the Cloud Pro popup's. */
+export function NightCard({ small = false, children }: { small?: boolean; children: ReactNode }) {
+ const root = useRef<HTMLDivElement>(null);
+ const moving = useLiveMotion(root);
+ return <div ref={root} data-night-card="" data-paused={moving ? undefined : ""}
+ className={cn("cloud-night relative isolate overflow-hidden rounded-[12px]", small ? "h-[92px]" : "h-[120px]")}>
+ <Scene moving={moving} />
+ <div className={cn("relative z-10 flex h-full flex-col justify-center", small ? "px-5" : "px-6")}>{children}</div>
+ </div>;
+}
diff --git a/src/components/cloud-buy/live-motion.ts b/src/components/cloud-buy/live-motion.ts
new file mode 100644
index 0000000000..50ecbc1f27
--- /dev/null
+++ b/src/components/cloud-buy/live-motion.ts
@@ -0,0 +1,28 @@
+import { useEffect, useState, useSyncExternalStore, type RefObject } from "react";
+import { reducedMotion } from "@/lib/onboarding";
+
+function subscribeReducedMotion(changed: () => void) {
+ const query = globalThis.window?.matchMedia?.("(prefers-reduced-motion: reduce)");
+ query?.addEventListener?.("change", changed);
+ const root = globalThis.document?.documentElement;
+ const hook = root && typeof MutationObserver === "function" ? new MutationObserver(changed) : null;
+ if (root) hook?.observe(root, { attributes: true, attributeFilter: ["data-reduced-motion"] });
+ return () => {
+ query?.removeEventListener?.("change", changed);
+ hook?.disconnect();
+ };
+}
+
+/** Whether a decoration may move: never under reduced motion (the system setting or the dev hook), and only while on screen. */
+export function useLiveMotion(target: RefObject<HTMLElement | null>): boolean {
+ const [inView, setInView] = useState(true);
+ useEffect(() => {
+ const node = target.current;
+ if (!node || typeof IntersectionObserver !== "function") return;
+ const watch = new IntersectionObserver(entries => setInView(entries.at(-1)?.isIntersecting ?? true));
+ watch.observe(node);
+ return () => watch.disconnect();
+ }, [target]);
+ const live = !useSyncExternalStore(subscribeReducedMotion, reducedMotion, reducedMotion);
+ return live && inView;
+}
diff --git a/src/components/cloud-buy/parts.tsx b/src/components/cloud-buy/parts.tsx
index 873384ad8c..f379c429e2 100644
--- a/src/components/cloud-buy/parts.tsx
+++ b/src/components/cloud-buy/parts.tsx
@@ -7,6 +7,10 @@ import { t } from "@/lib/i18n";
export const SHEET = "rounded-2xl border-[0.5px] border-ink/10 bg-app text-ink";
export const SCREEN = "flex flex-col gap-5 px-6 pb-6 pt-5";
+/** The close button over a night card: light ink on the sky. */
+export const ON_NIGHT = "group-has-[[data-night-card]]/sheet:[color-scheme:var(--code-color-scheme)] group-has-[[data-night-card]]/sheet:text-(--cloud-night-ink-quiet) group-has-[[data-night-card]]/sheet:hover:bg-white/15 group-has-[[data-night-card]]/sheet:hover:text-(--cloud-night-ink)";
+/** A tag on a night card: a faint wash of the card's own ink. */
+export const TAG_ON_NIGHT = "bg-white/12 text-(--cloud-night-ink-quiet)";
export const CLOSE = "flex size-8 items-center justify-center rounded-full text-ink-secondary transition-colors hover:bg-ink/[0.06] hover:text-ink motion-reduce:transition-none";
/** A neutral ink pill in Midnight and Daylight, the skin's accent elsewhere. */
export const PRIMARY = "ui-button ui-button-primary ui-button-pill";
@@ -18,12 +22,9 @@ export const LINK = "rounded-sm text-[13px] font-medium text-ink underline decor
export const FIELD = "h-9 w-full rounded-[10px] border border-ink/15 bg-transparent px-3 text-[14px] text-ink outline-none transition-[border-color] duration-150 placeholder:text-ink-tertiary disabled:opacity-60 motion-reduce:transition-none";
const TAG = "inline-flex min-h-5 items-center gap-1 rounded-full bg-ink/[0.06] px-2 text-[12px] font-medium leading-4 text-ink-secondary";
-export function Heading({ title, sub, mark }: { title: string; sub?: ReactNode; mark?: ReactNode }) {
+export function Heading({ title, sub }: { title: string; sub?: ReactNode }) {
return <div className="flex flex-col gap-1 pe-10">
- <div className="flex items-center gap-2.5">
- {mark}
- <h2 id="cloud-add-title" tabIndex={-1} className="text-[17px] font-medium leading-6 tracking-[-0.008em] text-ink outline-none! [text-wrap:balance]">{title}</h2>
- </div>
+ <h2 id="cloud-add-title" tabIndex={-1} className="text-[17px] font-medium leading-6 tracking-[-0.008em] text-ink outline-none! [text-wrap:balance]">{title}</h2>
{sub && <p className="text-[14px] leading-5 text-ink-secondary [text-wrap:pretty]">{sub}</p>}
</div>;
}
diff --git a/src/styles.css b/src/styles.css
index 240d70dc01..15b8342695 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -2871,6 +2871,51 @@ button:disabled.bg-danger {
color: var(--bubble-selection-ink, #ffffff);
}
+/* MausBot Cloud's night: a deep night sky in the dark skins and an indigo dusk in the light ones. light-dark() picks by
+ the color-scheme of the element that paints it. One star twinkles, the z's drift and now and then a star shoots, each
+ slowly; the z's need transform-box to grow around their own centre. */
+:root {
+ --cloud-night-from: light-dark(#2c3274, #0e1230);
+ --cloud-night-mid: light-dark(#373b84, #151a45);
+ --cloud-night-to: light-dark(#7a68ae, #252c69);
+ --cloud-night-glow: light-dark(#f2a9c23d, #6d5fd02e);
+ --cloud-night-ink: #ffffff;
+ --cloud-night-ink-quiet: light-dark(#ffffffd6, #ffffffc4);
+ --cloud-night-star: light-dark(#ffffff, #fff7dd);
+ --cloud-night-laptop: light-dark(#eceef7, #c4c9de);
+ --cloud-night-laptop-edge: light-dark(#a9aecb, #7c84a8);
+ --cloud-night-z: light-dark(#ffffffe0, #dfe3ffcc);
+ --cloud-night-paper: light-dark(#f7eedb, #efe4c6);
+ --cloud-night-carve: light-dark(#d6c7a2, #c9bb95);
+ --cloud-night-far: light-dark(#5a4e9c, #1f2560);
+ --cloud-night-near: light-dark(#463f8c, #161b4b);
+}
+.cloud-night {
+ color-scheme: var(--code-color-scheme);
+ color: var(--cloud-night-ink);
+ background:
+ radial-gradient(55% 110% at 90% 115%, var(--cloud-night-glow), transparent 70%),
+ linear-gradient(100deg, var(--cloud-night-from) 0%, var(--cloud-night-mid) 55%, var(--cloud-night-to) 100%);
+ box-shadow: inset 0 0 0 0.5px rgb(255 255 255 / 0.08);
+}
+.cloud-night-twinkle { animation: cloud-night-twinkle 9s ease-in-out infinite; }
+.cloud-night-z { transform-box: fill-box; transform-origin: center; animation: cloud-night-z 7s linear infinite; }
+.cloud-night-z:nth-child(2) { animation-delay: -2.4s; }
+.cloud-night-z:nth-child(3) { animation-delay: -4.8s; }
+.cloud-night-shoot { opacity: 0; animation: cloud-night-shoot 19s ease-in infinite; }
+.cloud-night[data-paused] * { animation-play-state: paused; }
+@keyframes cloud-night-twinkle { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
+@keyframes cloud-night-z {
+ 0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
+ 15%, 70% { opacity: 1; }
+ 100% { opacity: 0; transform: translate(14px, -22px) scale(1.05); }
+}
+@keyframes cloud-night-shoot {
+ 0%, 90% { opacity: 0; transform: translate(0, 0); }
+ 92% { opacity: 0.9; }
+ 100% { opacity: 0; transform: translate(120px, 36px); }
+}
+
/* Trace waterfall: AI steps lavender, tools pale teal, errors red, each mixed into the skin's card so every skin keeps its contrast. */
.trace-bar { border: 1px solid transparent; }
.trace-bar-step {