An open-source, self-hosted system for apps built with web technologies.
The sign-in and sign-up form waits for the System's picture
zohayrslileh40b69c388aad
diff --git a/source/client/view/structure/authentication/credentials-form.tsx b/source/client/view/structure/authentication/credentials-form.tsxindex 7a94348..6f56c17 100644--- a/source/client/view/structure/authentication/credentials-form.tsx+++ b/source/client/view/structure/authentication/credentials-form.tsx@@ -4,7 +4,9 @@ import { useReducedMotion } from "@libs/react-motion"import { motion } from "motion/react"import { Button, Heading, Input, resolveSpacing, Surface, Text, useAppearance, useTiming } from "@phreshos/react-ui"import Alert from "../../components/alert"-import { useId, useState, type SyntheticEvent } from "react"+import { useId, useLayoutEffect, useRef, useState, type SyntheticEvent } from "react"+import { useRequirement } from "@libs/readiness"+import { logoRequirement } from "../readiness-requirements"import logo from "@/assets/logo.png"import { name, version } from "@/source/identity"@@ -16,6 +18,12 @@ export default function CredentialsForm({ title, description, submitLabel, passwconst reducedMotion = useReducedMotion()const { spacing } = useAppearance()+ // The form waits for its picture; one that cannot load does not hold the page.+ const logoLoaded = useRequirement(logoRequirement)+ // A picture already in the cache may finish before its load event is heard. This runs after the+ // requirement above is registered, since effects run in the order they are declared.+ const logoImage = useRef<HTMLImageElement>(null)+ useLayoutEffect(() => { if (logoImage.current?.complete) logoLoaded() }, [logoLoaded])const transaction = useTiming()("change")const [password, setPassword] = useState("")const [mismatch, setMismatch] = useState(false)@@ -79,7 +87,7 @@ export default function CredentialsForm({ title, description, submitLabel, passw<div className="grid justify-items-center text-center" style={{ gap: resolveSpacing("medium", spacing) }}>- <img src={logo} alt="" draggable={false} className="size-12 object-contain select-none" />+ <img ref={logoImage} src={logo} alt="" draggable={false} className="size-12 object-contain select-none" onLoad={logoLoaded} onError={logoLoaded} /><div className="grid" style={{ gap: resolveSpacing("small", spacing) }}>diff --git a/source/client/view/structure/readiness-requirements.ts b/source/client/view/structure/readiness-requirements.tsindex 94db3bb..9a5d18e 100644--- a/source/client/view/structure/readiness-requirements.ts+++ b/source/client/view/structure/readiness-requirements.ts@@ -15,6 +15,11 @@ export const wallpaperRequirement = Object.freeze<DesktopReadinessRequirement>({message: "Loading wallpaper…"})+/** The System's picture on the sign-in and sign-up form: the page appears with it, never without. */+export const logoRequirement = Object.freeze<DesktopReadinessRequirement>({+ message: "Loading…"+})+export const programsRequirement = Object.freeze<DesktopReadinessRequirement>({message: "Loading programs…"})diff --git a/tests/panel.test.tsx b/tests/panel.test.tsxindex bec688e..7dc6bfa 100644--- a/tests/panel.test.tsx+++ b/tests/panel.test.tsx@@ -8,6 +8,7 @@ import ShellSurface, { shellSurfaceClassName } from "@client/view/structure/deskimport Window from "@client/view/structure/desktop/windows/window"import Taskbar from "@client/view/structure/desktop/layers/shell/taskbar/taskbar"import { ApplicationContext } from "@client/view/contexts"+import Readiness from "@libs/readiness"import Application from "@client/core/application"import { test } from "vitest"import { name, version } from "@/source/identity"@@ -23,7 +24,8 @@ test("panel contract", async () => {function markup(children: ReactNode) {return renderToStaticMarkup(<ApplicationContext.Provider value={application}>- <UIProvider appearance={defaultAppearance} preferences={{ theme: "light", animations: true }}>{children}</UIProvider>+ {/* As in the Desktop, what renders here sits inside a readiness boundary. */}+ <Readiness requirements={[]}><UIProvider appearance={defaultAppearance} preferences={{ theme: "light", animations: true }}>{children}</UIProvider></Readiness></ApplicationContext.Provider>)}