From a01ad4758f8d8f7605e9efd5694d6e203e2d2b6b Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 19 Jan 2022 00:20:51 -0300 Subject: [PATCH] header rendering --- .../taler-wallet-webextension/package.json | 4 +-- .../src/NavigationBar.tsx | 27 +++++++------------ .../src/popupEntryPoint.tsx | 14 +++++++--- .../src/walletEntryPoint.tsx | 15 ++++++++--- pnpm-lock.yaml | 2 +- 5 files changed, 35 insertions(+), 27 deletions(-) diff --git a/packages/taler-wallet-webextension/package.json b/packages/taler-wallet-webextension/package.json index 9b02eee24..900fb2ab7 100644 --- a/packages/taler-wallet-webextension/package.json +++ b/packages/taler-wallet-webextension/package.json @@ -23,7 +23,7 @@ "date-fns": "^2.28.0", "history": "4.10.1", "preact": "^10.5.13", - "preact-router": "^3.2.1", + "preact-router": "3.2.1", "qrcode-generator": "^1.4.4", "tslib": "^2.3.1" }, @@ -74,4 +74,4 @@ ], "exclude": [] } -} +} \ No newline at end of file diff --git a/packages/taler-wallet-webextension/src/NavigationBar.tsx b/packages/taler-wallet-webextension/src/NavigationBar.tsx index 44e8af78e..a25790852 100644 --- a/packages/taler-wallet-webextension/src/NavigationBar.tsx +++ b/packages/taler-wallet-webextension/src/NavigationBar.tsx @@ -26,21 +26,20 @@ */ import { i18n } from "@gnu-taler/taler-util"; import { ComponentChildren, h, VNode } from "preact"; -import Match from "preact-router/match"; import { PopupNavigation } from "./components/styled"; export enum Pages { welcome = "/welcome", balance = "/balance", balance_history = "/balance/history/:currency", - manual_withdraw = "/manual-withdraw/:currency?", - deposit = "/deposit/:currency", + manual_withdraw = "/balance/manual-withdraw/:currency?", + deposit = "/balance/deposit/:currency", + transaction = "/balance/transaction/:tid", settings = "/settings", dev = "/dev", cta = "/cta/:action", backup = "/backup", last_activity = "/last-activity", - transaction = "/transaction/:tid", provider_detail = "/provider/:pid", provider_add = "/provider/add", exchange_add = "/exchange/add", @@ -73,7 +72,13 @@ function Tab(props: TabProps): VNode { ); } -export function NavBar({ devMode, path }: { path: string; devMode: boolean }) { +export function NavBar({ + devMode, + path, +}: { + path: string; + devMode: boolean; +}): VNode { return (
@@ -89,15 +94,3 @@ export function NavBar({ devMode, path }: { path: string; devMode: boolean }) { ); } - -export function WalletNavBar({ devMode }: { devMode: boolean }) { - // const { devMode } = useDevContext(); - return ( - - {({ path }: any) => { - console.log("path", path); - return ; - }} - - ); -} diff --git a/packages/taler-wallet-webextension/src/popupEntryPoint.tsx b/packages/taler-wallet-webextension/src/popupEntryPoint.tsx index 5cd68b9b4..ecb49b01d 100644 --- a/packages/taler-wallet-webextension/src/popupEntryPoint.tsx +++ b/packages/taler-wallet-webextension/src/popupEntryPoint.tsx @@ -29,7 +29,7 @@ import { PopupBox } from "./components/styled"; import { DevContextProvider } from "./context/devContext"; import { useTalerActionURL } from "./hooks/useTalerActionURL"; import { strings } from "./i18n/strings"; -import { Pages, WalletNavBar } from "./NavigationBar"; +import { NavBar, Pages } from "./NavigationBar"; import { BackupPage } from "./wallet/BackupPage"; import { BalancePage } from "./popup/BalancePage"; import { DeveloperPage } from "./popup/DeveloperPage"; @@ -40,6 +40,7 @@ import { TalerActionFound } from "./popup/TalerActionFound"; import { ExchangeAddPage } from "./wallet/ExchangeAddPage"; import { IoCProviderForRuntime } from "./context/iocContext"; import { LastActivityPage } from "./wallet/LastActivityPage"; +import { Match } from "preact-router/match"; function main(): void { try { @@ -75,16 +76,21 @@ function CheckTalerActionComponent(): VNode { return ; } -function Application() { +function Application(): VNode { + const hash_history = createHashHistory(); return ( //
{({ devMode }: { devMode: boolean }) => ( - + + {({ path }: { path: string }) => ( + + )} + - + (undefined); + const hash_history = createHashHistory(); return (
{({ devMode }: { devMode: boolean }) => ( - + {/* won't work in the first render if is not called first */} + {/* https://github.com/preactjs/preact-router/issues/415 */} + + + {({ path }: { path: string }) => ( + + )} + {globalNotification && ( setGlobalNotification(undefined)}>
{globalNotification}
)} - +