wallet-core/packages/taler-wallet-webextension/src/components/Banner.tsx

71 lines
2.0 KiB
TypeScript
Raw Normal View History

2022-06-06 17:06:25 +02:00
/*
This file is part of GNU Taler
(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/>
*/
2023-01-09 12:38:48 +01:00
import { TranslatedString } from "@gnu-taler/taler-util";
2023-01-04 15:24:58 +01:00
import { ComponentChildren, Fragment, h, JSX, VNode } from "preact";
2022-03-29 04:41:07 +02:00
import { Button } from "../mui/Button.js";
2023-01-04 15:24:58 +01:00
import { Divider } from "../mui/Divider.js";
2022-03-29 04:41:07 +02:00
import { Grid } from "../mui/Grid.js";
import { Paper } from "../mui/Paper.js";
2022-03-09 18:00:02 +01:00
2022-03-11 06:17:40 +01:00
interface Props extends JSX.HTMLAttributes<HTMLDivElement> {
2023-01-09 12:38:48 +01:00
titleHead?: VNode | TranslatedString;
2023-01-04 15:24:58 +01:00
children: ComponentChildren;
// elements: {
// icon?: VNode;
// description: VNode;
// action?: () => void;
// }[];
2022-03-11 06:17:40 +01:00
confirm?: {
label: string;
2022-06-01 20:47:47 +02:00
action: () => Promise<void>;
2022-03-11 06:17:40 +01:00
};
2022-03-09 18:00:02 +01:00
}
2022-09-13 16:07:39 +02:00
export function Banner({
titleHead,
2023-01-04 15:24:58 +01:00
children,
2022-09-13 16:07:39 +02:00
confirm,
2023-01-04 15:24:58 +01:00
href,
2022-09-13 16:07:39 +02:00
...rest
}: Props): VNode {
2022-03-09 18:00:02 +01:00
return (
<Fragment>
2022-03-11 06:17:40 +01:00
<Paper elevation={0} {...rest}>
2022-09-13 16:07:39 +02:00
{titleHead && (
2022-03-11 06:17:40 +01:00
<Grid container>
2022-09-13 16:07:39 +02:00
<Grid item>{titleHead}</Grid>
2022-03-09 18:00:02 +01:00
</Grid>
2022-03-11 06:17:40 +01:00
)}
2022-03-11 15:14:27 +01:00
<Grid container columns={1}>
2023-01-04 15:24:58 +01:00
{children}
2022-03-09 18:00:02 +01:00
</Grid>
2022-03-11 06:17:40 +01:00
{confirm && (
<Grid container justifyContent="flex-end" spacing={8}>
<Grid item>
<Button color="primary" onClick={confirm.action}>
{confirm.label}
</Button>
</Grid>
2022-03-09 18:00:02 +01:00
</Grid>
2022-03-11 06:17:40 +01:00
)}
2022-03-09 18:00:02 +01:00
</Paper>
<Divider />
</Fragment>
);
}
export default Banner;