feat: various UI improvements (#36)
* fix: content offset When the appbar was changed to a `div` the content became offset, this fixes that. * style: make display of cheques table more readable * style: restyle sidebar * fix: content overflow * chore: split theme into separate file * feat: show ethereum transaction link for cashout * feat: make cashout link to etherscan transaction Co-authored-by: Vojtech Simetka <vojtech@simetka.cz>
This commit is contained in:
+1
-58
@@ -2,12 +2,11 @@ import React, { useEffect, useState } from 'react';
|
|||||||
import { BrowserRouter as Router } from 'react-router-dom';
|
import { BrowserRouter as Router } from 'react-router-dom';
|
||||||
import './App.css';
|
import './App.css';
|
||||||
|
|
||||||
import { createMuiTheme } from '@material-ui/core/styles';
|
|
||||||
import { ThemeProvider } from '@material-ui/styles';
|
import { ThemeProvider } from '@material-ui/styles';
|
||||||
import CssBaseline from '@material-ui/core/CssBaseline';
|
import CssBaseline from '@material-ui/core/CssBaseline';
|
||||||
|
|
||||||
import BaseRouter from './routes/routes';
|
import BaseRouter from './routes/routes';
|
||||||
|
import { lightTheme, darkTheme } from './theme';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
@@ -16,62 +15,6 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const lightTheme = createMuiTheme({
|
|
||||||
palette: {
|
|
||||||
type: "light",
|
|
||||||
background: {
|
|
||||||
default: '#fafafa',
|
|
||||||
},
|
|
||||||
primary: {
|
|
||||||
main: '#6a6a6a',
|
|
||||||
},
|
|
||||||
secondary: {
|
|
||||||
main: '#333333',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
typography: {
|
|
||||||
fontFamily: [
|
|
||||||
'Work Sans',
|
|
||||||
'Montserrat',
|
|
||||||
'Nunito',
|
|
||||||
'Roboto',
|
|
||||||
'"Helvetica Neue"',
|
|
||||||
'Arial',
|
|
||||||
'sans-serif'
|
|
||||||
].join(','),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const darkTheme = createMuiTheme({
|
|
||||||
palette: {
|
|
||||||
type: "dark",
|
|
||||||
background: {
|
|
||||||
default: '#0d1117', //'#111827',
|
|
||||||
paper: '#161b22', //'#1f2937',
|
|
||||||
},
|
|
||||||
primary: {
|
|
||||||
// light: will be calculated from palette.primary.main,
|
|
||||||
main: '#dd7700' //'#3f51b5',
|
|
||||||
// dark: will be calculated from palette.primary.main,
|
|
||||||
// contrastText: will be calculated to contrast with palette.primary.main
|
|
||||||
},
|
|
||||||
secondary: {
|
|
||||||
main: '#1f2937',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
typography: {
|
|
||||||
fontFamily: [
|
|
||||||
'Work Sans',
|
|
||||||
'Montserrat',
|
|
||||||
'Nunito',
|
|
||||||
'Roboto',
|
|
||||||
'"Helvetica Neue"',
|
|
||||||
'Arial',
|
|
||||||
'sans-serif'
|
|
||||||
].join(','),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [themeMode, toggleThemeMode] = useState('light');
|
const [themeMode, toggleThemeMode] = useState('light');
|
||||||
|
|||||||
@@ -6,16 +6,18 @@ import DialogActions from '@material-ui/core/DialogActions';
|
|||||||
import DialogContent from '@material-ui/core/DialogContent';
|
import DialogContent from '@material-ui/core/DialogContent';
|
||||||
import DialogContentText from '@material-ui/core/DialogContentText';
|
import DialogContentText from '@material-ui/core/DialogContentText';
|
||||||
import DialogTitle from '@material-ui/core/DialogTitle';
|
import DialogTitle from '@material-ui/core/DialogTitle';
|
||||||
import { Snackbar } from '@material-ui/core';
|
import { Snackbar, Container, CircularProgress } from '@material-ui/core';
|
||||||
|
|
||||||
import { beeDebugApi } from '../services/bee';
|
import { beeDebugApi } from '../services/bee';
|
||||||
|
|
||||||
export default function DepositModal() {
|
import EthereumAddress from './EthereumAddress';
|
||||||
const [open, setOpen] = React.useState(false);
|
|
||||||
const [peerId, setPeerId] = React.useState('');
|
|
||||||
|
|
||||||
const [showToast, setToastVisibility] = React.useState(false);
|
export default function DepositModal() {
|
||||||
const [toastContent, setToastContent] = React.useState('');
|
const [open, setOpen] = React.useState<boolean>(false);
|
||||||
|
const [peerId, setPeerId] = React.useState('');
|
||||||
|
const [loadingCashout, setLoadingCashout] = React.useState<boolean>(false);
|
||||||
|
const [showToast, setToastVisibility] = React.useState<boolean>(false);
|
||||||
|
const [toastContent, setToastContent] = React.useState<JSX.Element | null>(null);
|
||||||
|
|
||||||
const handleClickOpen = () => {
|
const handleClickOpen = () => {
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
@@ -27,20 +29,31 @@ export default function DepositModal() {
|
|||||||
|
|
||||||
const handleCashout = () => {
|
const handleCashout = () => {
|
||||||
if (peerId) {
|
if (peerId) {
|
||||||
|
setLoadingCashout(true)
|
||||||
beeDebugApi.chequebook.peerCashout(peerId)
|
beeDebugApi.chequebook.peerCashout(peerId)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
handleToast(`Successfully cashed out cheque. Transaction ${res.data.transactionHash}`)
|
handleToast(<span>Successfully cashed out cheque. Transaction
|
||||||
|
<EthereumAddress
|
||||||
|
hideBlockie
|
||||||
|
transaction
|
||||||
|
address={res.data.transactionHash}
|
||||||
|
network={'goerli'}
|
||||||
|
/>
|
||||||
|
</span>)
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
handleToast('Error with cashout')
|
handleToast(<span>Error with cashout</span>)
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setLoadingCashout(false)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
handleToast('Peer Id invalid')
|
handleToast(<span>Peer Id invalid</span>)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleToast = (text: string) => {
|
const handleToast = (text: JSX.Element) => {
|
||||||
setToastContent(text)
|
setToastContent(text)
|
||||||
setToastVisibility(true);
|
setToastVisibility(true);
|
||||||
setTimeout(
|
setTimeout(
|
||||||
@@ -61,6 +74,11 @@ export default function DepositModal() {
|
|||||||
/>
|
/>
|
||||||
<Dialog open={open} onClose={handleClose} aria-labelledby="form-dialog-title">
|
<Dialog open={open} onClose={handleClose} aria-labelledby="form-dialog-title">
|
||||||
<DialogTitle id="form-dialog-title">Cashout Cheque</DialogTitle>
|
<DialogTitle id="form-dialog-title">Cashout Cheque</DialogTitle>
|
||||||
|
{loadingCashout ?
|
||||||
|
<Container style={{textAlign:'center', padding:'50px'}}>
|
||||||
|
<CircularProgress />
|
||||||
|
</Container>
|
||||||
|
:
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogContentText style={{marginTop: '20px'}}>
|
<DialogContentText style={{marginTop: '20px'}}>
|
||||||
Specify the peer Id of the peer you would like to cashout.
|
Specify the peer Id of the peer you would like to cashout.
|
||||||
@@ -74,7 +92,7 @@ export default function DepositModal() {
|
|||||||
fullWidth
|
fullWidth
|
||||||
onChange={(e) => setPeerId(e.target.value)}
|
onChange={(e) => setPeerId(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</DialogContent>
|
</DialogContent>}
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={handleClose} color="primary">
|
<Button onClick={handleClose} color="primary">
|
||||||
Cancel
|
Cancel
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ const useStyles = makeStyles((theme: Theme) =>
|
|||||||
},
|
},
|
||||||
activeSideBarItem: {
|
activeSideBarItem: {
|
||||||
borderLeft: '4px solid #dd7700',
|
borderLeft: '4px solid #dd7700',
|
||||||
|
backgroundColor: 'inherit !important'
|
||||||
},
|
},
|
||||||
toolbar: theme.mixins.toolbar,
|
toolbar: theme.mixins.toolbar,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
body {
|
body {
|
||||||
|
height: 100vh;
|
||||||
|
min-height: 100vh;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||||
@@ -7,6 +9,12 @@ body {
|
|||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#root {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 100%;
|
||||||
|
overflow-y: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||||
monospace;
|
monospace;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ const useStyles = makeStyles((theme: Theme) =>
|
|||||||
toolbar: theme.mixins.toolbar,
|
toolbar: theme.mixins.toolbar,
|
||||||
content: {
|
content: {
|
||||||
marginLeft: '240px',
|
marginLeft: '240px',
|
||||||
marginTop: '64px',
|
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
backgroundColor: theme.palette.background.default,
|
backgroundColor: theme.palette.background.default,
|
||||||
padding: theme.spacing(3),
|
padding: theme.spacing(3),
|
||||||
|
|||||||
@@ -68,34 +68,34 @@ function ChequebookTable(props: IProps) {
|
|||||||
<ClipboardCopy value={peerCheque.peer} />
|
<ClipboardCopy value={peerCheque.peer} />
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell style={{maxWidth:'200px'}}>
|
<TableCell style={{maxWidth:'320px'}}>
|
||||||
<p style={{marginBottom: '0px', fontFamily: 'monospace, monospace'}}>
|
<p style={{marginBottom: '0px', fontFamily: 'monospace, monospace', display:'flex'}}>
|
||||||
{peerCheque.lastreceived?.payout ? ConvertBalanceToBZZ(peerCheque.lastreceived?.payout).toFixed(7).toLocaleString() : '-'}
|
<span style={{whiteSpace: 'nowrap', marginRight:'12px', paddingTop:'3px'}}>
|
||||||
</p>
|
{peerCheque.lastreceived?.payout ?
|
||||||
<p style={{marginBottom: '0px'}}>
|
`${ConvertBalanceToBZZ(peerCheque.lastreceived?.payout).toFixed(7).toLocaleString()} from`
|
||||||
<small>{peerCheque.lastreceived ?
|
: '-'}
|
||||||
|
</span>
|
||||||
|
{peerCheque.lastreceived ?
|
||||||
<EthereumAddress
|
<EthereumAddress
|
||||||
hideBlockie
|
hideBlockie
|
||||||
truncate
|
truncate
|
||||||
network='goerli'
|
network='goerli'
|
||||||
address={peerCheque.lastreceived.beneficiary}
|
address={peerCheque.lastreceived.beneficiary}
|
||||||
/> : null}
|
/> : null}
|
||||||
</small>
|
|
||||||
</p>
|
</p>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell style={{maxWidth:'200px'}}>
|
<TableCell style={{maxWidth:'320px'}}>
|
||||||
<p style={{marginBottom: '0px', fontFamily: 'monospace, monospace'}}>
|
<p style={{marginBottom: '0px', fontFamily: 'monospace, monospace', display:'flex'}}>
|
||||||
{peerCheque.lastsent?.payout ? ConvertBalanceToBZZ(peerCheque.lastsent?.payout).toFixed(7).toLocaleString() : '-'}
|
<span style={{whiteSpace: 'nowrap', marginRight:'12px', paddingTop:'3px'}}>
|
||||||
</p>
|
{peerCheque.lastsent?.payout ? `${ConvertBalanceToBZZ(peerCheque.lastsent?.payout).toFixed(7).toLocaleString()} to` : '-'}
|
||||||
<p style={{marginBottom: '0px'}}>
|
</span>
|
||||||
<small>{peerCheque.lastsent ?
|
{peerCheque.lastsent ?
|
||||||
<EthereumAddress
|
<EthereumAddress
|
||||||
hideBlockie
|
hideBlockie
|
||||||
truncate
|
truncate
|
||||||
network='goerli'
|
network='goerli'
|
||||||
address={peerCheque.lastsent.beneficiary}
|
address={peerCheque.lastsent.beneficiary}
|
||||||
/> : null}
|
/> : null}
|
||||||
</small>
|
|
||||||
</p>
|
</p>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="right">
|
<TableCell align="right">
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import { createMuiTheme } from '@material-ui/core/styles';
|
||||||
|
|
||||||
|
declare module '@material-ui/core/styles/createPalette' {
|
||||||
|
interface TypeBackground {
|
||||||
|
appBar: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const lightTheme = createMuiTheme({
|
||||||
|
palette: {
|
||||||
|
type: "light",
|
||||||
|
background: {
|
||||||
|
default: '#fafafa',
|
||||||
|
},
|
||||||
|
primary: {
|
||||||
|
main: '#6a6a6a',
|
||||||
|
},
|
||||||
|
secondary: {
|
||||||
|
main: '#333333',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typography: {
|
||||||
|
fontFamily: [
|
||||||
|
'Work Sans',
|
||||||
|
'Montserrat',
|
||||||
|
'Nunito',
|
||||||
|
'Roboto',
|
||||||
|
'"Helvetica Neue"',
|
||||||
|
'Arial',
|
||||||
|
'sans-serif'
|
||||||
|
].join(','),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const darkTheme = createMuiTheme({
|
||||||
|
palette: {
|
||||||
|
type: "dark",
|
||||||
|
background: {
|
||||||
|
default: '#0d1117',
|
||||||
|
paper: '#161b22',
|
||||||
|
},
|
||||||
|
primary: {
|
||||||
|
main: '#dd7700',
|
||||||
|
},
|
||||||
|
secondary: {
|
||||||
|
main: '#1f2937',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typography: {
|
||||||
|
fontFamily: [
|
||||||
|
'Work Sans',
|
||||||
|
'Montserrat',
|
||||||
|
'Nunito',
|
||||||
|
'Roboto',
|
||||||
|
'"Helvetica Neue"',
|
||||||
|
'Arial',
|
||||||
|
'sans-serif'
|
||||||
|
].join(','),
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user