Skip to content

Commit

Permalink
refactor: heartbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias authored Dec 21, 2017
2 parents cf77457 + 3cdb684 commit d479424
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
26 changes: 10 additions & 16 deletions src/js/components/view/heartbeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,25 @@ const icyLogo = resolve(join(__dirname, '../../../img/ipfs-logo-ice.png'))
const blackLogo = resolve(join(__dirname, '../../../img/ipfs-logo-black.png'))

export default function Heartbeat (props) {
if (props.running === null) {
if (props.dead) {
return (
<img src={`file://${icyLogo}`} className='heartbeat' />
<img onClick={props.onClickDead} src={`file://${blackLogo}`} />
)
}

if (props.running) {
} else {
return (
<img onClick={props.stopDaemon} src={`file://${icyLogo}`} className='heartbeat-btn heartbeat' />
<img onClick={props.onClickAlive} src={`file://${icyLogo}`} className='heartbeat' />
)
}

return (
<img onClick={props.startDaemon} src={`file://${blackLogo}`} className='heartbeat-btn ' />
)
}

Heartbeat.propTypes = {
running: PropTypes.bool,
startDaemon: PropTypes.func,
stopDaemon: PropTypes.func
dead: PropTypes.bool,
onClickAlive: PropTypes.func,
onClickDead: PropTypes.func
}

Heartbeat.defaultProps = {
running: null,
startDaemon: null,
stopDaemon: null
dead: false,
onClickAlive: () => {},
onClickDead: () => {}
}
6 changes: 3 additions & 3 deletions src/js/screens/menu/node-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export default function NodeScreen (props) {
<div className={`node` + (props.running ? '' : ' translucent')}>
<Header title='Your Node'>
<Heartbeat
running={props.running}
stopDaemon={stopDaemon}
startDaemon={startDaemon} />
dead={!props.running}
onClickAlive={stopDaemon}
onClickDead={startDaemon} />
</Header>

<div className='main'>
Expand Down
2 changes: 1 addition & 1 deletion src/styles/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ input[type="text"] {
}
}

.heartbeat-btn {
.header img {
cursor: pointer;
width: 1.15em;
}
Expand Down

0 comments on commit d479424

Please sign in to comment.