Skip to content

Commit

Permalink
refactor(webapp): add EmptyState component
Browse files Browse the repository at this point in the history
  • Loading branch information
Torresmorah committed Dec 7, 2022
1 parent ec5f8b3 commit aa6e1c7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
28 changes: 28 additions & 0 deletions webapp/src/components/InformationCard/EmptyState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { memo } from 'react'
import PropTypes from 'prop-types'

const EmptyState = ({ classes, t }) => {
return (
<div className={`${classes.centerWrapper} ${classes.borderLine}`}>
<div className={classes.emptyState}>
<img
className={classes.imgError}
src="/empty-states/Error.webp"
alt=""
/>
<span>{t('emptyState')}</span>
</div>
</div>
)
}

EmptyState.propTypes = {
classes: PropTypes.object,
t: PropTypes.func,
}

EmptyState.defaultProps = {
classes: {},
}

export default memo(EmptyState)
17 changes: 3 additions & 14 deletions webapp/src/components/InformationCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { eosConfig } from '../../config'
import ProducerHealthIndicators from '../ProducerHealthIndicators'
import NodesCard from '../NodeCard/NodesCard'

import EmptyState from './EmptyState'
import ProducerInformation from './ProducerInformation'
import Nodes from './Nodes'
import Social from './Social'
Expand Down Expand Up @@ -59,20 +60,8 @@ const InformationCard = ({ producer, rank, type }) => {
}

const BlockProducerInfo = () => {
if (producerOrg.healthStatus?.length <= 1) {
return (
<div className={`bodyWrapper ${classes.borderLine}`}>
<div className={classes.emptyState}>
<img
className={classes.imgError}
src="/empty-states/Error.webp"
alt=""
/>
<span>{t('emptyState')}</span>
</div>
</div>
)
}
if (producerOrg.healthStatus?.length <= 1)
return <EmptyState classes={classes} t={t}/>

return (
<div className="bodyWrapper">
Expand Down
11 changes: 8 additions & 3 deletions webapp/src/components/InformationCard/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default (theme) => ({
flexDirection: 'row',
'& .bodyWrapper': {
flexDirection: 'row',
justifyContent: 'space-evenly',
justifyContent: 'space-between',
width: '100%',
},
'& .MuiTypography-overline': {
Expand Down Expand Up @@ -75,8 +75,8 @@ export default (theme) => ({
},
[theme.breakpoints.up('lg')]: {
padding: theme.spacing(0, 6),
width: 300,
maxWidth: 300,
width: 250,
minWidth: 250,
justifyContent: 'center',
},
},
Expand Down Expand Up @@ -323,6 +323,11 @@ export default (theme) => ({
marginLeft: theme.spacing(1),
},
},
centerWrapper: {
width: '100%',
display: 'flex',
justifyContent: 'center',
},
emptyState: {
display: 'flex',
flexDirection: 'column',
Expand Down

0 comments on commit aa6e1c7

Please sign in to comment.