feat: polish app (#669)

This commit is contained in:
Cafe137
2024-07-17 06:49:22 -07:00
committed by GitHub
parent b4ebfc7c3f
commit 8558860f0a
18 changed files with 304 additions and 417 deletions
+25
View File
@@ -0,0 +1,25 @@
import { ChainState } from '@ethersphere/bee-js'
import { useContext, useEffect, useState } from 'react'
import { Context } from '../providers/Settings'
import ExpandableListItem from './ExpandableListItem'
export function ChainSync() {
const { beeApi } = useContext(Context)
const [chainState, setChainState] = useState<ChainState | null>(null)
useEffect(() => {
const interval = setInterval(() => {
if (!beeApi) {
return
}
beeApi.getChainState().then(setChainState).catch(console.error) // eslint-disable-line
}, 3_000)
return () => clearInterval(interval)
})
return (
<ExpandableListItem label="Chain state" value={chainState ? `${chainState.block} / ${chainState.chainTip}` : '-'} />
)
}
+9 -7
View File
@@ -1,9 +1,11 @@
import { Utils } from '@ethersphere/bee-js'
import { Typography } from '@material-ui/core/'
import { ReactElement } from 'react'
import Identicon from 'react-identicons'
import ClipboardCopy from './ClipboardCopy'
import QRCodeModal from './QRCodeModal'
import { BLOCKCHAIN_EXPLORER_URL } from '../constants'
import ClipboardCopy from './ClipboardCopy'
import { Flex } from './Flex'
import QRCodeModal from './QRCodeModal'
interface Props {
address: string | undefined
@@ -16,10 +18,10 @@ export default function EthereumAddress(props: Props): ReactElement {
return (
<Typography component="div" variant="subtitle1">
{props.address ? (
<div style={{ display: 'flex' }}>
<Flex>
{props.hideBlockie ? null : (
<div style={{ paddingTop: '5px', marginRight: '10px' }}>
<Identicon size={20} string={props.address} />
<Identicon size={20} string={Utils.capitalizeAddressERC55(props.address)} />
</div>
)}
<div>
@@ -43,9 +45,9 @@ export default function EthereumAddress(props: Props): ReactElement {
{props.address}
</a>
</div>
<QRCodeModal value={props.address} label={'Ethereum Address'} />
<ClipboardCopy value={props.address} />
</div>
<QRCodeModal value={Utils.capitalizeAddressERC55(props.address)} label={'Ethereum Address'} />
<ClipboardCopy value={Utils.capitalizeAddressERC55(props.address)} />
</Flex>
) : (
'-'
)}
+5 -4
View File
@@ -1,7 +1,8 @@
import { ReactElement, ReactNode, useState } from 'react'
import { makeStyles, Theme, createStyles } from '@material-ui/core/styles'
import { Collapse, ListItem, ListItemText, Typography } from '@material-ui/core'
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'
import { ExpandLess, ExpandMore } from '@material-ui/icons'
import { ReactElement, ReactNode, useState } from 'react'
import { Flex } from './Flex'
const useStyles = makeStyles((theme: Theme) =>
createStyles({
@@ -65,14 +66,14 @@ export default function ExpandableList({ children, label, level, defaultOpen, in
<div className={`${classes.root} ${rootLevelClass}`}>
<ListItem button onClick={handleClick} className={classes.header}>
<ListItemText primary={<Typography variant={typographyVariant}>{label}</Typography>} />
<div style={{ display: 'flex' }}>
<Flex>
{!open && (
<Typography variant="body2" className={classes.infoText}>
{info}
</Typography>
)}
{open ? <ExpandLess /> : <ExpandMore />}
</div>
</Flex>
</ListItem>
<Collapse in={open} timeout="auto" unmountOnExit>
<div className={contentLevelClass}>{children}</div>
+9
View File
@@ -0,0 +1,9 @@
import { ReactNode } from 'react'
interface Props {
children: ReactNode
}
export function Flex({ children }: Props) {
return <div style={{ display: 'flex' }}>{children}</div>
}
+1 -1
View File
@@ -133,7 +133,7 @@ export default function SideBar(): ReactElement {
<SideBarItem
iconStart={<GithubIcon className={classes.icon} />}
iconEnd={<ExternalLinkIcon className={classes.icon} color="#595959" />}
label={<span>Github repository</span>}
label={<span>GitHub</span>}
/>
</MUILink>
</List>