taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 9244012b158d52fe7171de6b0e0f0f399bd40015
parent 73eda74c408a1bd2b34ccf206e91213744836a94
Author: Florian Dold <dold@taler.net>
Date:   Thu, 26 Nov 2026 00:19:21 +0100

wallet web UI: show the extension header before JavaScript loads

Render the desktop header or mobile navigation in the initial HTML so
the wallet opens with the same layout as the running extension.

Issue: https://bugs.taler.net/n/10644

Diffstat:
Mpackages/wallet-webui/build.mjs | 10++++++++--
Mpackages/wallet-webui/src/extension-entry.tsx | 1+
Mpackages/wallet-webui/src/styles/main.css | 10++++++++++
Mpackages/wallet-webui/src/ui/Shell.tsx | 4++--
Apackages/wallet-webui/static/wallet-shell.html | 14++++++++++++++
5 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/packages/wallet-webui/build.mjs b/packages/wallet-webui/build.mjs @@ -70,11 +70,12 @@ async function html( styles = "./styles.css", icon = "./taler-logo-light.svg", manifest, + bootShell = "", } = {}, ) { await writeFile( new URL(entry, directory), - `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="color-scheme" content="light dark"><title>${title}</title>${manifest ? `<link rel="manifest" href="${manifest}">` : ""}<link rel="icon" href="${icon}"><link rel="stylesheet" href="${styles}"></head><body><div id="app"></div><script type="module" src="${app}"></script></body></html>`, + `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="color-scheme" content="light dark"><title>${title}</title>${manifest ? `<link rel="manifest" href="${manifest}">` : ""}<link rel="icon" href="${icon}"><link rel="stylesheet" href="${styles}"></head><body><div id="app">${bootShell}</div><script type="module" src="${app}"></script></body></html>`, ); } @@ -326,7 +327,12 @@ for (const target of ["chrome", "firefox"]) { await readFile(new URL("content-script.js", directory)), ); } - await html(directory, "wallet.html", "GNU Taler Wallet"); + await html(directory, "wallet.html", "GNU Taler Wallet", { + bootShell: await readFile( + new URL("./static/wallet-shell.html", import.meta.url), + "utf8", + ), + }); await html(directory, "popup.html", "GNU Taler Wallet"); if (extensionSqliteTest && target === "chrome") { await html(directory, "sqlite-offscreen.html", "SQLite worker host", { diff --git a/packages/wallet-webui/src/extension-entry.tsx b/packages/wallet-webui/src/extension-entry.tsx @@ -6,6 +6,7 @@ import { StorybookEntry, storybookLocationFromHash } from "./stories/entry.js"; const root = document.getElementById("app"); if (!root) throw Error("application root missing"); +root.replaceChildren(); if (window.top !== window) { // wallet.html is web-accessible for the legacy window.taler URL converter, // but wallet state and controls must never render in a merchant iframe. diff --git a/packages/wallet-webui/src/styles/main.css b/packages/wallet-webui/src/styles/main.css @@ -2,6 +2,16 @@ @tailwind components; @tailwind utilities; +/* The extension document paints this chrome while the wallet starts. */ +@layer components { + .wallet-mobile-nav { + @apply fixed inset-x-0 bottom-0 z-20 grid grid-cols-3 items-end border-t border-outlineVariant bg-surface px-4 pb-[max(.55rem,env(safe-area-inset-bottom))] pt-2 md:hidden; + } + .wallet-mobile-scan { + @apply mx-auto -mt-8 grid h-16 w-16 place-items-center rounded-full bg-primaryContainer text-onPrimaryContainer shadow-lg; + } +} + @font-face { font-family: Roboto; font-style: normal; diff --git a/packages/wallet-webui/src/ui/Shell.tsx b/packages/wallet-webui/src/ui/Shell.tsx @@ -173,7 +173,7 @@ export function Shell(props: { </div> <nav aria-label={i18n.str`Wallet`} - class="fixed inset-x-0 bottom-0 z-20 grid grid-cols-3 items-end border-t border-outlineVariant bg-surface px-4 pb-[max(.55rem,env(safe-area-inset-bottom))] pt-2 md:hidden" + class="wallet-mobile-nav" > <MobileNav href="/" icon="balances" description={unreadDescription}> {balancesLabel} @@ -181,7 +181,7 @@ export function Shell(props: { <Link href="/scan" aria-label={i18n.str`Scan QR code`} - class="mx-auto -mt-8 grid h-16 w-16 place-items-center rounded-full bg-primaryContainer text-onPrimaryContainer shadow-lg" + class="wallet-mobile-scan" > <WalletIcon name="scan" class="h-8 w-8" /> </Link> diff --git a/packages/wallet-webui/static/wallet-shell.html b/packages/wallet-webui/static/wallet-shell.html @@ -0,0 +1,14 @@ +<div aria-hidden="true" inert> + <header class="hidden border-b border-outlineVariant bg-surface md:block"> + <div class="mx-auto max-w-7xl px-4 py-3 md:px-5 md:py-4"> + <picture> + <source media="(prefers-color-scheme: dark)" srcset="./taler-logo-dark.svg"> + <img src="./taler-logo-light.svg" alt="" class="h-12 w-auto"> + </picture> + </div> + </header> + <div class="wallet-mobile-nav"> + <span class="min-h-12"></span> + <span class="wallet-mobile-scan"></span> + </div> +</div>