-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from berzniz/toggle
Add hide button
- Loading branch information
Showing
4 changed files
with
59 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,42 @@ | ||
import React from 'react' | ||
import Branch from './branch.jsx' | ||
|
||
export default ({ root }) => { | ||
return ( | ||
<div> | ||
{root.list.map(node => ( | ||
<span key={node.nodeLabel}> | ||
<Branch {...node} /> | ||
</span> | ||
))} | ||
</div> | ||
) | ||
class Tree extends React.Component { | ||
constructor (props) { | ||
super(props) | ||
|
||
this.onClose = this.onClose.bind(this) | ||
|
||
this.state = { | ||
show: true | ||
} | ||
} | ||
|
||
onClose () { | ||
const show = false | ||
this.setState({ show }) | ||
document.body.classList.toggle('enable_better_github_pr', show) | ||
} | ||
|
||
render () { | ||
const { root } = this.props | ||
const { show } = this.state | ||
|
||
if (!show) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div> | ||
<button onClick={this.onClose} className='close_button'>✖</button> | ||
{root.list.map(node => ( | ||
<span key={node.nodeLabel}> | ||
<Branch {...node} /> | ||
</span> | ||
))} | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default Tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters