Skip to content

Commit

Permalink
[Upd #70] Recycle Bin is shown only when comment is hovered
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope committed Jan 27, 2022
1 parent fb3f8d2 commit 40e0460
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/components/comment/CommentView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const UNKNOWN_AUTHOR = "Unknown author";
const CommentView = (props) => {
const { options } = useContext(ConfigurationContext);
const [showIRI, setShowIRI] = useState(false);
const [showRecycleBin, setShowRecycleBin] = useState(false);

TimeAgo.addLocale(en);
const time = new TimeAgo('en-US');
Expand Down Expand Up @@ -79,24 +80,30 @@ const CommentView = (props) => {
setShowIRI(!showIRI);
}

const onMouseRecycleBinEventHandler = () => {
setShowRecycleBin(!showRecycleBin)
}

const onClickDeleteCommentHandler = () => {
props.onClickDeleteComment(props.index);
}

return (
<div className="comment-content">
<div className="comment-content" onMouseEnter={onMouseRecycleBinEventHandler} onMouseLeave={onMouseRecycleBinEventHandler}>
<div className="row">
<div className="col-auto comment-author" onMouseEnter={onMouseAuthorEventHandler} onMouseLeave={onMouseAuthorEventHandler}>
{renderAuthor()}
</div>
<div className="col-auto text-muted comment-timestamp">{renderTimeAgo()}</div>
<motion.div
className="comment-delete"
whileHover={{scale: 1.2}}
whileTap={{scale: 0.9}}
onClick={onClickDeleteCommentHandler}>
<RecycleBin/>
</motion.div>
{showRecycleBin ?
<motion.div
className="comment-delete emphasise-on-relevant-icon"
whileHover={{scale: 1.2}}
whileTap={{scale: 0.9}}
onClick={onClickDeleteCommentHandler}>
<RecycleBin/>
</motion.div>
: null }
</div>
<div className="row">
<div className="col comment-value">{props.commentValue}</div>
Expand Down

0 comments on commit 40e0460

Please sign in to comment.