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

68 lines
1.7 KiB
TypeScript
Raw Normal View History

2022-03-11 06:17:40 +01:00
import { h, Fragment, VNode, JSX } from "preact";
2022-03-09 18:00:02 +01:00
import { Divider } from "../mui/Divider";
2022-03-11 03:13:10 +01:00
import { Button } from "../mui/Button";
2022-03-09 18:00:02 +01:00
import { Typography } from "../mui/Typography";
import { Avatar } from "../mui/Avatar";
import { Grid } from "../mui/Grid";
import { Paper } from "../mui/Paper";
2022-03-11 06:17:40 +01:00
interface Props extends JSX.HTMLAttributes<HTMLDivElement> {
title?: string;
elements: {
icon?: VNode;
description: VNode;
}[];
confirm?: {
label: string;
action: () => void;
};
2022-03-09 18:00:02 +01:00
}
2022-03-11 06:17:40 +01:00
export function Banner({ title, elements, confirm, ...rest }: Props) {
2022-03-09 18:00:02 +01:00
return (
<Fragment>
2022-03-11 06:17:40 +01:00
<Paper elevation={0} {...rest}>
{title && (
<Grid container>
<Grid item>
<Typography>{title}</Typography>
</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 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;