From aad3026999cde16aac8f4e2b1890c7468044b821 Mon Sep 17 00:00:00 2001 From: xaralis <filip.varecha@fragaria.cz> Date: Tue, 29 Dec 2020 18:32:18 +0100 Subject: [PATCH] feat: only allow thumbs where it makes sense --- src/components/Thumbs.jsx | 10 ++++++---- src/components/posts/Post.jsx | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/Thumbs.jsx b/src/components/Thumbs.jsx index 52cac18..024baab 100644 --- a/src/components/Thumbs.jsx +++ b/src/components/Thumbs.jsx @@ -8,9 +8,10 @@ const Thumbs = ({ likes, dislikes, myVote, onLike, onDislike, readOnly }) => { <button className={classNames("flex items-center space-x-1", { "cursor-pointer": !readOnly, - "cursor-default": readOnly, + "cursor-not-allowed": readOnly, "text-blue-300": myVote === "like", - "text-grey-200 hover:text-blue-300": myVote !== "like", + "text-grey-200 ": myVote !== "like", + "hover:text-blue-300": myVote !== "like" && !readOnly, })} disabled={readOnly} onClick={onLike} @@ -21,9 +22,10 @@ const Thumbs = ({ likes, dislikes, myVote, onLike, onDislike, readOnly }) => { <button className={classNames("flex items-center space-x-1", { "cursor-pointer": !readOnly, - "cursor-default": readOnly, + "cursor-not-allowed": readOnly, "text-red-600": myVote === "dislike", - "text-grey-200 hover:text-red-600": myVote !== "dislike", + "text-grey-200": myVote !== "dislike", + "hover:text-red-600": myVote !== "dislike" && !readOnly, })} disabled={readOnly} onClick={onDislike} diff --git a/src/components/posts/Post.jsx b/src/components/posts/Post.jsx index 1631446..3e3a5e6 100644 --- a/src/components/posts/Post.jsx +++ b/src/components/posts/Post.jsx @@ -159,6 +159,9 @@ const Post = ({ __html: content, }; + const thumbsEnabled = + canThumb && !archived && (type === "post" || state === "announced"); + return ( <div className={wrapperClassName} ref={ref}> <img @@ -196,7 +199,7 @@ const Post = ({ <Thumbs likes={ranking.likes} dislikes={ranking.dislikes} - readOnly={!canThumb} + readOnly={!thumbsEnabled} onLike={onLike} onDislike={onDislike} myVote={ranking.myVote} -- GitLab