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

60 lines
1.5 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
)}
<Grid container wrap="nowrap" spacing={1} alignItems="center">
{elements.map((e, i) => (
<Fragment key={i}>
{e.icon && (
<Grid item>
<Avatar>{e.icon}</Avatar>
</Grid>
)}
<Grid item>{e.description}</Grid>
</Fragment>
))}
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;