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

118 lines
3.3 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.
*
2022-02-23 19:18:37 +01:00
* @author sebasjm
2016-03-01 19:46:20 +01:00
*/
2017-05-29 15:18:48 +02:00
/**
* Imports.
*/
2022-03-24 20:02:38 +01:00
import { h, VNode } from "preact";
2022-03-29 04:41:07 +02:00
import { JustInDevMode } from "./components/JustInDevMode.js";
2022-03-24 20:02:38 +01:00
import {
NavigationHeader,
NavigationHeaderHolder,
SvgIcon,
2022-03-29 04:41:07 +02:00
} from "./components/styled/index.js";
import { useTranslationContext } from "./context/translation.js";
2022-03-24 20:02:38 +01:00
import settingsIcon from "./svg/settings_black_24dp.svg";
2016-10-10 00:37:08 +02:00
2022-02-23 19:18:37 +01:00
/**
* List of pages used by the wallet
*
* @author sebasjm
*/
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/:currency?",
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",
2022-05-03 05:16:03 +02:00
cta_deposit = "/cta/deposit",
2021-06-16 22:01:06 +02:00
}
2022-02-16 19:15:47 +01:00
export function PopupNavBar({ path = "" }: { path?: string }): VNode {
2022-03-14 16:15:41 +01:00
const { i18n } = useTranslationContext();
2016-10-10 00:37:08 +02:00
return (
2022-02-16 19:15:47 +01:00
<NavigationHeader>
2022-02-23 19:18:37 +01:00
<a href="/balance" class={path.startsWith("/balance") ? "active" : ""}>
<i18n.Translate>Balance</i18n.Translate>
2022-02-23 19:18:37 +01:00
</a>
<a href="/backup" class={path.startsWith("/backup") ? "active" : ""}>
<i18n.Translate>Backup</i18n.Translate>
2022-02-23 19:18:37 +01:00
</a>
2022-03-09 18:00:02 +01:00
<a href="/settings">
2022-03-24 20:02:38 +01:00
<SvgIcon
title={i18n.str`Settings`}
dangerouslySetInnerHTML={{ __html: settingsIcon }}
color="white"
/>
2022-02-16 19:15:47 +01:00
</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 {
2022-03-14 16:15:41 +01:00
const { i18n } = useTranslationContext();
2021-11-15 15:18:58 +01:00
return (
2022-02-16 19:15:47 +01:00
<NavigationHeaderHolder>
<NavigationHeader>
2022-02-23 19:18:37 +01:00
<a href="/balance" class={path.startsWith("/balance") ? "active" : ""}>
<i18n.Translate>Balance</i18n.Translate>
2022-02-23 19:18:37 +01:00
</a>
<a href="/backup" class={path.startsWith("/backup") ? "active" : ""}>
<i18n.Translate>Backup</i18n.Translate>
2022-02-23 19:18:37 +01:00
</a>
2022-02-16 19:15:47 +01:00
<JustInDevMode>
2022-02-23 19:18:37 +01:00
<a href="/dev" class={path.startsWith("/dev") ? "active" : ""}>
<i18n.Translate>Dev</i18n.Translate>
2022-02-23 19:18:37 +01:00
</a>
2022-02-16 19:15:47 +01:00
</JustInDevMode>
<a
href="/settings"
class={path.startsWith("/settings") ? "active" : ""}
>
<i18n.Translate>Settings</i18n.Translate>
2022-02-16 19:15:47 +01:00
</a>
</NavigationHeader>
</NavigationHeaderHolder>
2021-11-15 15:18:58 +01:00
);
2021-07-16 17:00:39 +02:00
}