show Collapse button on hover
This commit is contained in:
parent
a485873544
commit
77a714dac9
@ -2,7 +2,12 @@ import React from 'react'
|
|||||||
|
|
||||||
const ExpandedComment = props => {
|
const ExpandedComment = props => {
|
||||||
return (
|
return (
|
||||||
<li className="" key={props.id}>
|
<li
|
||||||
|
className=""
|
||||||
|
key={props.id}
|
||||||
|
onMouseEnter={() => props.showCollapse(props.id, true)}
|
||||||
|
onMouseLeave={() => props.showCollapse(props.id, false)}
|
||||||
|
>
|
||||||
<div className="media bg bg-dark">
|
<div className="media bg bg-dark">
|
||||||
<img alt="profile" src={props.user.avatar} height={64} />
|
<img alt="profile" src={props.user.avatar} height={64} />
|
||||||
|
|
||||||
@ -20,6 +25,7 @@ const ExpandedComment = props => {
|
|||||||
fontVariant: 'small-caps',
|
fontVariant: 'small-caps',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
|
display: props.displayCollapse || 'none',
|
||||||
}}
|
}}
|
||||||
onClick={() => props.toggleCollapse(props.id)}
|
onClick={() => props.toggleCollapse(props.id)}
|
||||||
>
|
>
|
||||||
|
@ -6,6 +6,16 @@ class ThreadList extends React.Component {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
this.toggleCollapse = this.toggleCollapse.bind(this)
|
this.toggleCollapse = this.toggleCollapse.bind(this)
|
||||||
|
this.showCollapse = this.showCollapse.bind(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
showCollapse(id, state) {
|
||||||
|
this.setState({ displayCollapse: 'block' })
|
||||||
|
const otherComments = this.props.comments.filter(c => c.id !== id)
|
||||||
|
const comment = this.props.comments.find(c => c.id === id)
|
||||||
|
comment['displayCollapse'] = state
|
||||||
|
//console.log('displayed collapse for: ', comment)
|
||||||
|
this.setState({ comments: otherComments.concat(comment) })
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleCollapse(id) {
|
toggleCollapse(id) {
|
||||||
@ -37,6 +47,7 @@ class ThreadList extends React.Component {
|
|||||||
<div className="ml-3" key={uuid()}>
|
<div className="ml-3" key={uuid()}>
|
||||||
<SingleComment
|
<SingleComment
|
||||||
threadLevel={this.props.threadLevel}
|
threadLevel={this.props.threadLevel}
|
||||||
|
showCollapse={this.showCollapse}
|
||||||
toggleCollapse={this.toggleCollapse}
|
toggleCollapse={this.toggleCollapse}
|
||||||
{...comment}
|
{...comment}
|
||||||
/>
|
/>
|
||||||
@ -47,16 +58,16 @@ class ThreadList extends React.Component {
|
|||||||
<div className="ml-3" key={uuid()}>
|
<div className="ml-3" key={uuid()}>
|
||||||
<SingleComment
|
<SingleComment
|
||||||
threadLevel={this.props.threadLevel}
|
threadLevel={this.props.threadLevel}
|
||||||
|
showCollapse={this.showCollapse}
|
||||||
toggleCollapse={this.toggleCollapse}
|
toggleCollapse={this.toggleCollapse}
|
||||||
{...comment}
|
{...comment}
|
||||||
/>
|
/>
|
||||||
{!comment.collapsed ? (
|
{!comment.collapsed && (
|
||||||
<ThreadList
|
<ThreadList
|
||||||
threadLevel={comment.id}
|
threadLevel={comment.id}
|
||||||
|
showCollapse={this.showCollapse}
|
||||||
comments={this.props.comments}
|
comments={this.props.comments}
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
''
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user