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

83 lines
2.4 KiB
TypeScript
Raw Normal View History

/*
This file is part of GNU Taler
2022-06-06 17:05:26 +02:00
(C) 2022 Taler Systems S.A.
GNU 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.
GNU 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
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
*
* @author Sebastian Javier Marchano (sebasjm)
*/
2022-12-06 15:28:56 +01:00
import { Fragment, FunctionComponent, h } from "preact";
2022-03-29 04:41:07 +02:00
import { LogoHeader } from "./components/LogoHeader.js";
import { PopupBox, WalletBox } from "./components/styled/index.js";
2022-12-06 15:28:56 +01:00
import { strings } from "./i18n/strings.js";
2022-03-29 04:41:07 +02:00
import { PopupNavBar, WalletNavBar } from "./NavigationBar.js";
2022-12-06 15:28:56 +01:00
import * as components from "./components/index.stories.js";
import * as cta from "./cta/index.stories.js";
import * as mui from "./mui/index.stories.js";
2022-03-29 04:41:07 +02:00
import * as popup from "./popup/index.stories.js";
import * as wallet from "./wallet/index.stories.js";
2022-12-06 15:28:56 +01:00
import { renderStories } from "@gnu-taler/web-util/lib/index.browser";
2022-03-29 05:45:17 +02:00
2022-12-06 15:28:56 +01:00
function main(): void {
renderStories(
{ popup, wallet, cta, mui, components },
{
strings,
getWrapperForGroup,
},
);
}
2022-12-06 15:28:56 +01:00
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", main);
} else {
main();
2022-08-18 17:35:36 +02:00
}
function getWrapperForGroup(group: string): FunctionComponent {
switch (group) {
case "popup":
return function PopupWrapper({ children }: any) {
return (
2022-12-06 15:28:56 +01:00
<Fragment>
<PopupNavBar />
<PopupBox>{children}</PopupBox>
2022-12-06 15:28:56 +01:00
</Fragment>
);
};
case "wallet":
return function WalletWrapper({ children }: any) {
return (
2022-12-06 15:28:56 +01:00
<Fragment>
<LogoHeader />
<WalletNavBar />
<WalletBox>{children}</WalletBox>
2022-12-06 15:28:56 +01:00
</Fragment>
2022-04-06 17:20:00 +02:00
);
};
case "cta":
return function WalletWrapper({ children }: any) {
return (
2022-12-06 15:28:56 +01:00
<Fragment>
2022-04-06 17:20:00 +02:00
<WalletBox>{children}</WalletBox>
2022-12-06 15:28:56 +01:00
</Fragment>
);
};
default:
return Fragment;
}
}