Skip to content

Commit

Permalink
feat(webapp): implement design of nonCompliant BPs section
Browse files Browse the repository at this point in the history
refactor(webapp): add NonCompliantCard component
feat(webapp): apply design for rewards distribution section
chore(webapp): fix margins and spacing
  • Loading branch information
Torresmorah committed Jan 18, 2023
1 parent c32acfa commit b74ed21
Show file tree
Hide file tree
Showing 14 changed files with 413 additions and 280 deletions.
36 changes: 36 additions & 0 deletions webapp/src/components/Icons/NonCompliant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react'

const NonCompliant = () => (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M15.167 17.5v-1.667a3.333 3.333 0 0 0-3.333-3.333H5.167a3.333 3.333 0 0 0-3.333 3.333V17.5"
stroke="#000"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
clipRule="evenodd"
d="M8.5 9.167a3.333 3.333 0 1 0 0-6.667 3.333 3.333 0 0 0 0 6.667z"
stroke="#000"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M20.166 17.5v-1.667a3.333 3.333 0 0 0-2.5-3.225M14.334 2.608a3.333 3.333 0 0 1 0 6.459M20 3l5 5M25 3l-5 5"
stroke="#000"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
)

export default NonCompliant
4 changes: 3 additions & 1 deletion webapp/src/components/Icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import RewardsDistributionSvg from './RewardsDistribution'
import BPJsonSvg from './BPJson'
import EndpointSvg from './Endpoint'
import MissingBlocksSvg from './MissingBlocks'
import NonCompliantSvg from './NonCompliant'
import TopologySvg from './Topology'
import RewardsSvg from './Rewards'

Expand All @@ -14,6 +15,7 @@ export {
BPJsonSvg,
EndpointSvg,
MissingBlocksSvg,
NonCompliantSvg,
TopologySvg,
RewardsSvg
RewardsSvg,
}
76 changes: 76 additions & 0 deletions webapp/src/components/NonCompliantCard/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* eslint camelcase: 0 */
import React, { memo } from 'react'
import { makeStyles } from '@mui/styles'
import { useTranslation } from 'react-i18next'
import Typography from '@mui/material/Typography'
import moment from 'moment'

import { eosConfig } from '../../config'
import { formatWithThousandSeparator } from '../../utils'
import VisitSite from 'components/VisitSite'

import styles from './styles'

const useStyles = makeStyles(styles)

const NonCompliantCard = ({ producer, stats }) => {
const classes = useStyles()
const { t } = useTranslation('producerCardComponent')

const RowInfo = ({ title, value }) => {
return (
<div className={classes.flex}>
<Typography variant="body1" className={classes.bold}>
{title}:
</Typography>
<Typography variant="body1">{value}</Typography>
</div>
)
}

return (
<>
<div className={`${classes.content} ${classes.account}`}>
<Typography variant="h3">{producer.owner}</Typography>
<Typography variant="body1">{t('noInfo')}</Typography>
</div>
<div className={`${classes.content} ${classes.borderLine}`}>
<Typography variant="overline">{t('info')}</Typography>
<div className={classes.flex}>
<Typography variant="body1" className={classes.bold}>
{t('website')}:
</Typography>
<VisitSite title={t('openLink')} url={producer.url} />
</div>
<RowInfo
title={`${t('votes')}`}
value={`${formatWithThousandSeparator(producer.total_votes_eos, 0)}`}
/>
<RowInfo
title={`${t('lastClaimTime')}`}
value={`${moment(producer.last_claim_time).format('ll')}`}
/>
</div>
<div
className={`${classes.content} ${classes.borderLine} ${classes.hideRewards}`}
>
<Typography variant="overline">{t('dailyRewards')}</Typography>
<RowInfo
title={`${t('rewards')} (USD)`}
value={`$${formatWithThousandSeparator(
producer.total_rewards * stats.tokenPrice,
0,
)}`}
/>
<RowInfo
title={`${t('rewards')} (${eosConfig.tokenSymbol})`}
value={`${formatWithThousandSeparator(producer.total_rewards, 0)}`}
/>
</div>
</>
)
}

NonCompliantCard.propTypes = {}

export default memo(NonCompliantCard)
49 changes: 49 additions & 0 deletions webapp/src/components/NonCompliantCard/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export default (theme) => ({
flex: {
display: 'flex',
flexWrap: 'wrap',
},
bold: {
fontWeight: 'bold !important',
},
account: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'center',
[theme.breakpoints.down('sm')]: {
borderBottom: '1px solid rgba(0, 0, 0, 0.2)',
},
},
content: {
width: '250px',
height: 'auto',
margin: '0px',
flexGrow: '1',
[theme.breakpoints.down('lg')]: {
width: '150px',
},
[theme.breakpoints.down('sm')]: {
width: '100%',
},
},
borderLine: {
[theme.breakpoints.up('sm')]: {
marginTop: theme.spacing(3),
marginBottom: theme.spacing(3),
borderLeft: '1px solid rgba(0, 0, 0, 0.2)',
padding: theme.spacing(0, 3, 0),
},
[theme.breakpoints.down('sm')]: {
marginLeft: theme.spacing(3),
},
},
hideRewards: {
[theme.breakpoints.down('sm')]: {
'& .MuiTypography-overline': {
display: 'none',
},
},
},
})
1 change: 1 addition & 0 deletions webapp/src/hooks/customHooks/useNonCompliantState.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const useNonCompliantState = () => {
percentageRewards,
dailyRewards: nonCompliantRewards,
tokenPrice: setting?.token_price,
quantity: nonCompliantBPs.length,
})
setItems(nonCompliantBPs)
}, [producers, setting])
Expand Down
8 changes: 5 additions & 3 deletions webapp/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"/block-producers>sidebar": "Block Producers",
"/block-producers>title": "Block Producers - EOSIO Network Dashboard",
"/block-producers>heading": "Block Producers",
"/non-compliant-bps>sidebar": "Non-compliant BPs",
"/non-compliant-bps>sidebar": "Non-compliant Producers",
"/non-compliant-bps>title": "Non-compliant Blocks Producers - EOSIO Network Dashboard",
"/non-compliant-bps>heading": "Non-compliant Blocks Producers",
"/rewards-distribution>sidebar": "Rewards Distribution",
Expand Down Expand Up @@ -156,7 +156,8 @@
"exchangeRate": "Exchange Rate",
"country": "Country",
"rewards": "Rewards",
"rewardsPercentage": "Percentage of rewards"
"rewardsPercentage": "Percentage of rewards",
"viewList": "View full list"
},
"nodesRoute": {},
"nodesDistributionRoute": {},
Expand Down Expand Up @@ -259,7 +260,8 @@
"average": "average rating",
"ratings": "ratings",
"lastClaimTime": "Last time claimed",
"noInfo": "No info provided"
"noInfo": "No info provided",
"dailyRewards": "Daily Rewards"
},
"nodeCardComponent": {
"features": "Features",
Expand Down
9 changes: 6 additions & 3 deletions webapp/src/language/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"/block-producers>sidebar": "Productores de Bloques",
"/block-producers>title": "Productores de Bloques - Panel",
"/block-producers>heading": "Productores de Bloques",
"/non-compliant-bps>sidebar": "BPs incumplidores",
"/non-compliant-bps>sidebar": "Productores incumplidores",
"/non-compliant-bps>title": "Productores de Bloques incumplidores - Panel",
"/non-compliant-bps>heading": "Productores de Bloques incumplidores",
"/rewards-distribution>sidebar": "Distribución de recompensas",
Expand Down Expand Up @@ -161,7 +161,9 @@
"highestRewards": "Recompensas Más Altas",
"exchangeRate": "Tipo De Cambio",
"country": "País",
"rewardsPercentage": "Porcentaje de recompensas"
"rewards": "Recompensas",
"rewardsPercentage": "Porcentaje de recompensas",
"viewList": "Ver lista completa"
},
"nodesRoute": {},
"nodesDistributionRoute": {},
Expand Down Expand Up @@ -265,7 +267,8 @@
"average": "calificación promedio",
"ratings": "calificaciones",
"lastClaimTime": "Último reclamo",
"noInfo": "No provee información"
"noInfo": "No provee información",
"dailyRewards": "Recompensas diarias"
},
"nodeCardComponent": {
"features": "Características",
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/layouts/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default (theme) => ({
appContent: {
display: 'flex',
flexDirection: 'column',
maxWidth: '100%',
width: '100%',
overflow: 'hidden',
[theme.breakpoints.up('md')]: {
flex: 1,
Expand Down
65 changes: 65 additions & 0 deletions webapp/src/routes/NonCompliantBPs/RewardsStats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* eslint camelcase: 0 */
import React, { memo } from 'react'
import { makeStyles } from '@mui/styles'
import { useTranslation } from 'react-i18next'
import Typography from '@mui/material/Typography'

import { eosConfig } from '../../config'
import { formatWithThousandSeparator } from '../../utils'

import styles from './styles'

const useStyles = makeStyles(styles)

const RewardsStats = ({ stats }) => {
const classes = useStyles()
const { t } = useTranslation('rewardsDistributionRoute')

return (
<>
<div className={`${classes.cardHeader} ${classes.cardShadow}`}>
<div className={classes.rewardsCards}>
<Typography variant="h6">{t('paidProducers')}</Typography>
<Typography variant="h3" className={classes.statsText}>
{stats.quantity || 0}
</Typography>
</div>
</div>
<div className={`${classes.cardHeader} ${classes.cardShadow}`}>
<div className={classes.rewardsCards}>
<Typography variant="h6">{`${t('dailyRewards')} (USD)`}</Typography>
<Typography variant="h3" className={classes.statsText}>
{`${formatWithThousandSeparator(
stats.dailyRewards * stats.tokenPrice,
0,
)} USD`}
</Typography>
</div>
</div>
<div className={`${classes.cardHeader} ${classes.cardShadow}`}>
<div className={classes.rewardsCards}>
<Typography variant="h6">
{`${t('dailyRewards')} (${eosConfig.tokenSymbol})`}
</Typography>
<Typography variant="h3" className={classes.statsText}>
{`${formatWithThousandSeparator(stats.dailyRewards, 0)} ${
eosConfig.tokenSymbol
}`}
</Typography>
</div>
</div>
<div className={`${classes.cardHeader} ${classes.cardShadow}`}>
<div className={classes.rewardsCards}>
<Typography variant="h6">{t('rewardsPercentage')}</Typography>
<Typography variant="h3" className={classes.statsText}>
{`${stats.percentageRewards?.toFixed(2)}%`}
</Typography>
</div>
</div>
</>
)
}

RewardsStats.propTypes = {}

export default memo(RewardsStats)
Loading

0 comments on commit b74ed21

Please sign in to comment.