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/>
|
|
|
|
*/
|
2022-03-11 06:17:40 +01:00
|
|
|
import { h, Fragment, VNode, JSX } from "preact";
|
2022-03-29 04:41:07 +02:00
|
|
|
import { Divider } from "../mui/Divider.js";
|
|
|
|
import { Button } from "../mui/Button.js";
|
|
|
|
import { Typography } from "../mui/Typography.js";
|
|
|
|
import { Avatar } from "../mui/Avatar.js";
|
|
|
|
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> {
|
2022-09-13 16:07:39 +02:00
|
|
|
titleHead?: VNode;
|
2022-03-11 06:17:40 +01:00
|
|
|
elements: {
|
|
|
|
icon?: VNode;
|
|
|
|
description: VNode;
|
2022-03-11 20:18:26 +01:00
|
|
|
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,
|
|
|
|
elements,
|
|
|
|
confirm,
|
|
|
|
...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}>
|
2022-03-11 06:17:40 +01:00
|
|
|
{elements.map((e, i) => (
|
2022-03-11 15:14:27 +01:00
|
|
|
<Grid
|
|
|
|
container
|
|
|
|
item
|
|
|
|
xs={1}
|
|
|
|
key={i}
|
|
|
|
wrap="nowrap"
|
|
|
|
spacing={1}
|
|
|
|
alignItems="center"
|
2022-03-11 20:18:26 +01:00
|
|
|
onClick={e.action}
|
2022-03-11 15:14:27 +01:00
|
|
|
>
|
2022-03-11 06:17:40 +01:00
|
|
|
{e.icon && (
|
2022-03-11 15:14:27 +01:00
|
|
|
<Grid item xs={"auto"}>
|
2022-03-11 06:17:40 +01:00
|
|
|
<Avatar>{e.icon}</Avatar>
|
|
|
|
</Grid>
|
|
|
|
)}
|
|
|
|
<Grid item>{e.description}</Grid>
|
2022-03-11 15:14:27 +01:00
|
|
|
</Grid>
|
2022-03-11 06:17:40 +01:00
|
|
|
))}
|
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;
|