don't rerender on hover for collapse/expand link

This commit is contained in:
data 2019-07-14 15:03:12 +02:00
parent e212b52f9b
commit 03311238e8
3 changed files with 14 additions and 20 deletions

View File

@ -1,3 +1,15 @@
.replies {
margin-left: 1em;
}
a:hover {
text-decoration: none;
color: #007bff;
}
.comment-meta a {
display: none;
}
.comment-meta:hover a {
display: inline;
text-decoration: none;
color: #007bff;
}

View File

@ -3,18 +3,13 @@ import CommentReply from './CommentReply'
const ExpandedComment = props => {
return (
<li
className=""
key={props.id}
onMouseEnter={() => props.showCollapseLink(props.id, true)}
onMouseLeave={() => props.showCollapseLink(props.id, false)}
>
<li key={props.id}>
<div id="media-image" className="media bg bg-dark">
<img alt="profile" src="anon.jpeg" height={64} />
<div id="media-body" className="media-body ml-3 my-auto">
<a href="#user">username</a>
<div className="text-white-50">
<div className="comment-meta text-white-50">
<small>{props.createdAt}</small>
{props.replies.length > 0 ? (
<a
@ -22,7 +17,6 @@ const ExpandedComment = props => {
className="ml-3"
style={{
fontVariant: 'small-caps',
display: props.displayCollapse || 'none',
}}
onClick={() =>
props.toggleCollapse(props.id, !props.collapsedThread)

View File

@ -7,19 +7,9 @@ class ThreadList extends React.Component {
super()
this.state = { activeReplyId: null }
this.toggleCollapse = this.toggleCollapse.bind(this)
this.showCollapseLink = this.showCollapseLink.bind(this)
this.showReply = this.showReply.bind(this)
}
showCollapseLink(id, collapsed) {
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'] = collapsed
//console.log('displayed collapse for: ', comment)
this.setState({ comments: otherComments.concat(comment) })
}
toggleCollapse(id, collapsed) {
const otherComments = this.props.comments.filter(c => c.id !== id)
var parent = this.props.comments.find(c => c.id === id)
@ -70,7 +60,6 @@ class ThreadList extends React.Component {
<div className="ml-3" key={uuid()}>
<SingleComment
threadLevel={this.props.threadLevel}
showCollapseLink={this.showCollapseLink}
toggleCollapse={this.toggleCollapse}
showReply={this.showReply}
submitComment={this.props.submitComment}
@ -80,7 +69,6 @@ class ThreadList extends React.Component {
{comment.replies && (
<ThreadList
threadLevel={comment.id}
showCollapseLink={this.showCollapseLink}
comments={this.props.comments}
submitComment={this.props.submitComment}
/>