Skip to content
Snippets Groups Projects
Commit e3d9b0aa authored by xaralis's avatar xaralis
Browse files

feat: improve score highlighting

parent a55ca24f
No related branches found
No related tags found
No related merge requests found
...@@ -240,8 +240,8 @@ const Post = ({ ...@@ -240,8 +240,8 @@ const Post = ({
)} )}
<PostScore <PostScore
className="ml-2" className="ml-2"
score={ranking.score} postType={type}
hasDislikes={ranking.dislikes > 0} ranking={ranking}
rankingReadonly={!thumbsVisible} rankingReadonly={!thumbsVisible}
supportThreshold={supportThreshold} supportThreshold={supportThreshold}
/> />
......
...@@ -2,27 +2,31 @@ import React from "react"; ...@@ -2,27 +2,31 @@ import React from "react";
import classNames from "classnames"; import classNames from "classnames";
const PostScore = ({ const PostScore = ({
score, postType,
hasDislikes, ranking,
supportThreshold, supportThreshold,
rankingReadonly, rankingReadonly,
className, className,
}) => { }) => {
const coloring = rankingReadonly const { score, dislikes } = ranking;
? "bg-grey-125 text-grey-200" const highlight = postType === "procedure-proposal" && !rankingReadonly;
: { const coloring = highlight
? {
"bg-red-600 text-white": score < 0, "bg-red-600 text-white": score < 0,
"bg-grey-125 text-grey-200": score === 0 && score < supportThreshold, "bg-grey-125 text-grey-200": score === 0 && score < supportThreshold,
"bg-yellow-400 text-grey-300": "bg-yellow-400 text-grey-300":
score > 0 && hasDislikes && score < supportThreshold, score > 0 && dislikes > 0 && score < supportThreshold,
"bg-green-400 text-white": "bg-green-400 text-white":
score >= supportThreshold || (score > 0 && !hasDislikes), score >= supportThreshold || (score > 0 && dislikes <= 0),
}; }
: "bg-grey-125 text-grey-200";
let title; let title;
if (!rankingReadonly) { if (postType === "procedure-proposal") {
if (hasDislikes) { if (rankingReadonly) {
title = `Návrh postupu získal podporu ${score} hlasů.`;
} else if (dislikes > 0) {
if (score < supportThreshold) { if (score < supportThreshold) {
title = `Aktuální podpora je ${score} hlasů, pro získání podpory skupiny členů chybí ještě ${ title = `Aktuální podpora je ${score} hlasů, pro získání podpory skupiny členů chybí ještě ${
supportThreshold - score supportThreshold - score
...@@ -48,14 +52,7 @@ const PostScore = ({ ...@@ -48,14 +52,7 @@ const PostScore = ({
title={title} title={title}
> >
<i className="ico--power" /> <i className="ico--power" />
<span className="font-bold"> <span className="font-bold">{score}</span>
{!rankingReadonly && hasDislikes && (
<span>
{score} z {supportThreshold}
</span>
)}
{!(!rankingReadonly && hasDislikes) && score.toString()}
</span>
</span> </span>
); );
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment