Add colour to score

This commit is contained in:
Dave Gallant
2022-12-23 21:43:04 -05:00
parent e69d0f632e
commit dd7e73b497
3 changed files with 17 additions and 2 deletions

View File

@@ -100,7 +100,6 @@ func (a *App) refreshTopics() {
func (a *App) updateScores(t []Topic) []Topic { func (a *App) updateScores(t []Topic) []Topic {
for i := range t { for i := range t {
t[i].Score = t[i].Votes.Up - t[i].Votes.Down t[i].Score = t[i].Votes.Up - t[i].Votes.Down
log.Debug().Msgf("Added score: %d", t[i].Score)
} }
return t return t
} }

View File

@@ -38,7 +38,15 @@
v-html="highlightMatches(topic.title)" v-html="highlightMatches(topic.title)"
></a> ></a>
</td> </td>
<td scope="col">{{ topic.score }}</td> <td v-if="topic.score > 0" scope="col" class="green-score">
+{{ topic.score }}
</td>
<td v-if="topic.score < 0" scope="col" class="red-score">
{{ topic.score }}
</td>
<td v-if="topic.score == 0" scope="col">
{{ topic.score }}
</td>
<td scope="col">{{ topic.total_views }}</td> <td scope="col">{{ topic.total_views }}</td>
<td scope="col">{{ formatDate(topic.last_post_time) }}</td> <td scope="col">{{ formatDate(topic.last_post_time) }}</td>
</tr> </tr>

View File

@@ -199,3 +199,11 @@ footer {
.footer-right { .footer-right {
float: right; float: right;
} }
.green-score {
color: rgb(22, 120, 63);
}
.red-score {
color: rgb(175, 21, 21);
}