wallet-core/packages/taler-wallet-webextension/src/NavigationBar.tsx

110 lines
3.1 KiB
TypeScript
Raw Normal View History

/*
This file is part of TALER
(C) 2016 GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
2016-07-07 17:59:29 +02:00
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
2016-03-01 19:46:20 +01:00
/**
* Popup shown to the user when they click
* the Taler browser action button.
*
* @author Florian Dold
*/
2017-05-29 15:18:48 +02:00
/**
* Imports.
*/
2021-06-30 23:24:08 +02:00
import { i18n } from "@gnu-taler/taler-util";
2022-02-16 19:15:47 +01:00
import { VNode, h } from "preact";
import { JustInDevMode } from "./components/JustInDevMode";
import { NavigationHeader, NavigationHeaderHolder } from "./components/styled";
2016-10-10 00:37:08 +02:00
2021-06-16 22:01:06 +02:00
export enum Pages {
2021-11-15 15:18:58 +01:00
welcome = "/welcome",
2022-01-20 17:12:28 +01:00
2021-11-15 15:18:58 +01:00
balance = "/balance",
2022-01-25 14:29:29 +01:00
balance_history = "/balance/history/:currency?",
2022-01-20 17:12:28 +01:00
balance_manual_withdraw = "/balance/manual-withdraw/:currency?",
balance_deposit = "/balance/deposit/:currency",
balance_transaction = "/balance/transaction/:tid",
2021-11-15 15:18:58 +01:00
dev = "/dev",
2022-01-20 17:12:28 +01:00
2021-11-15 15:18:58 +01:00
backup = "/backup",
2022-01-20 17:12:28 +01:00
backup_provider_detail = "/backup/provider/:pid",
backup_provider_add = "/backup/provider/add",
settings = "/settings",
settings_exchange_add = "/settings/exchange/add",
2022-01-20 17:12:28 +01:00
cta = "/cta/:action",
cta_pay = "/cta/pay",
cta_refund = "/cta/refund",
cta_tips = "/cta/tip",
cta_withdraw = "/cta/withdraw",
2021-06-16 22:01:06 +02:00
}
2022-02-16 19:15:47 +01:00
export function PopupNavBar({ path = "" }: { path?: string }): VNode {
const innerUrl = chrome.runtime
? new URL(chrome.runtime.getURL("/static/wallet.html#/settings")).href
: "#";
2016-10-10 00:37:08 +02:00
return (
2022-02-16 19:15:47 +01:00
<NavigationHeader>
<a
href="/balance"
class={path.startsWith("/balance") ? "active" : ""}
>{i18n.str`Balance`}</a>
<a
href="/backup"
class={path.startsWith("/backup") ? "active" : ""}
>{i18n.str`Backup`}</a>
<a />
<a href={innerUrl} target="_blank" rel="noreferrer">
<div class="settings-icon" title="Settings" />
</a>
</NavigationHeader>
2016-10-10 00:37:08 +02:00
);
}
2022-02-16 19:15:47 +01:00
export function WalletNavBar({ path = "" }: { path?: string }): VNode {
2021-11-15 15:18:58 +01:00
return (
2022-02-16 19:15:47 +01:00
<NavigationHeaderHolder>
<NavigationHeader>
<a
href="/balance"
class={path.startsWith("/balance") ? "active" : ""}
>{i18n.str`Balance`}</a>
<a
href="/backup"
class={path.startsWith("/backup") ? "active" : ""}
>{i18n.str`Backup`}</a>
<JustInDevMode>
<a
href="/dev"
class={path.startsWith("/dev") ? "active" : ""}
>{i18n.str`Dev`}</a>
</JustInDevMode>
<a />
<a
href="/settings"
class={path.startsWith("/settings") ? "active" : ""}
>
<div class="settings-icon" title="Settings" />
</a>
</NavigationHeader>
</NavigationHeaderHolder>
2021-11-15 15:18:58 +01:00
);
2021-07-16 17:00:39 +02:00
}