From caea5ae309028fef12c5cd036dcd1d264dd451e6 Mon Sep 17 00:00:00 2001 From: Vojtech Simetka Date: Sat, 18 Jun 2022 17:09:13 +0200 Subject: [PATCH] feat: info page redesign (#390) * feat: info page redesign * feat: add chequebook card --- src/components/Card.tsx | 77 ++++++++++++++++ src/components/Map.tsx | 9 ++ src/components/SwarmButton.tsx | 20 +++-- src/pages/info/index.tsx | 156 ++++++++++++++++++++++++--------- src/theme.tsx | 2 +- 5 files changed, 214 insertions(+), 50 deletions(-) create mode 100644 src/components/Card.tsx create mode 100644 src/components/Map.tsx diff --git a/src/components/Card.tsx b/src/components/Card.tsx new file mode 100644 index 0000000..30cf141 --- /dev/null +++ b/src/components/Card.tsx @@ -0,0 +1,77 @@ +import { createStyles, makeStyles, Theme, Typography } from '@material-ui/core' +import { ReactElement } from 'react' +import { AlertCircle, Check } from 'react-feather' +import { SwarmButton, SwarmButtonProps } from './SwarmButton' + +interface Props { + icon: ReactElement + title: string + subtitle: string + buttonProps: SwarmButtonProps + status: 'ok' | 'error' +} + +const useStyles = (backgroundColor: string) => + makeStyles((theme: Theme) => + createStyles({ + root: { + flexGrow: 1, + flexBasis: '100px', + }, + wrapper: { + backgroundColor, + padding: '16px', + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + textAlign: 'center', + }, + iconWrapper: { + display: 'flex', + alignItems: 'flex-start', + marginBottom: '18px', + }, + button: { + width: '100%', + marginTop: '2px', + backgroundColor, + '&:hover': { + backgroundColor: theme.palette.primary.main, + color: 'white', + boxShadow: 'none', + // https://github.com/mui-org/material-ui/issues/22543 + '@media (hover: none)': { + backgroundColor: theme.palette.primary.main, + color: 'white', + boxShadow: 'none', + }, + }, + }, + }), + ) + +export default function Card({ buttonProps, icon, title, subtitle, status }: Props): ReactElement { + const backgroundColor = status === 'error' ? 'white' : '#f3f3f3' + const { className, ...rest } = buttonProps + const classes = useStyles(backgroundColor)() + + return ( +
+
+
+ {icon} + {status === 'ok' ? ( + + ) : ( + + )} +
+ + {title} + + {subtitle} +
+ +
+ ) +} diff --git a/src/components/Map.tsx b/src/components/Map.tsx new file mode 100644 index 0000000..30b661b --- /dev/null +++ b/src/components/Map.tsx @@ -0,0 +1,9 @@ +import { ReactElement, CSSProperties } from 'react' + +interface Props { + style?: CSSProperties +} + +export default function Card({ style }: Props): ReactElement { + return
+} diff --git a/src/components/SwarmButton.tsx b/src/components/SwarmButton.tsx index 84bb5e0..46976b3 100644 --- a/src/components/SwarmButton.tsx +++ b/src/components/SwarmButton.tsx @@ -1,13 +1,9 @@ -import { Button, CircularProgress, createStyles, makeStyles } from '@material-ui/core' +import { Button, ButtonProps, CircularProgress, createStyles, makeStyles } from '@material-ui/core' import React, { ReactElement } from 'react' import { IconProps } from 'react-feather' -interface Props { - onClick: () => void +export interface SwarmButtonProps extends ButtonProps { iconType: React.ComponentType - children: string - className?: string - disabled?: boolean loading?: boolean cancel?: boolean variant?: 'text' | 'contained' | 'outlined' @@ -51,7 +47,9 @@ export function SwarmButton({ loading, cancel, variant = 'contained', -}: Props): ReactElement { + style, + ...other +}: SwarmButtonProps): ReactElement { const classes = useStyles() function getIconColor() { @@ -73,14 +71,18 @@ export function SwarmButton({ return ( - - } - /> - - - - - - {nodeAddresses?.underlay.map(addr => ( - - ))} - - - - - - - - - + )} + + } + /> + ) } diff --git a/src/theme.tsx b/src/theme.tsx index 6c5cc68..98a88c5 100644 --- a/src/theme.tsx +++ b/src/theme.tsx @@ -174,7 +174,7 @@ export const theme = createTheme({ palette: { type: 'light', background: { - default: '#efefef', + default: '#ededed', }, primary: { light: '#fcf2e8',