Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions components/RatingTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,16 @@ const maxValues = computed(() => {
{{ userRating.score7days }}
</td>
<td class="px-6 py-4 bg-gray-50 dark:bg-gray-800">
{{ userRating.score24hours }}
<ScoreWithChange
v-if="userRating.score24hours"
Copy link
Member

@yurijmikhalevich yurijmikhalevich Oct 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need v-if here? The score should always be defined, right?

Suggested change
v-if="userRating.score24hours"

:score="userRating.score24hours"
/>
</td>
<td class="px-6 py-4">
{{ userRating.score1hour }}
<ScoreWithChange
v-if="userRating.score1hour"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

:score="userRating.score1hour"
/>
</td>
<td class="px-6 py-4 bg-gray-50 dark:bg-gray-800">
{{ userRating.wins }}
Expand Down
37 changes: 37 additions & 0 deletions components/ScoreWithChange.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<script setup lang="ts">
const props = defineProps<{
score: {
value: number;
change: number | null;
};
}>();

const changeColorClass = computed(() => {
if (props.score.change === null || props.score.change === 0) {
return "text-gray-500 dark:text-gray-400";
}
return props.score.change > 0 ? "text-green-500" : "text-red-500";
});

const formattedChange = computed(() => {
if (props.score.change === null) {
return "new"; // Display for changes from 0
}
const sign = props.score.change > 0 ? "+" : "";
// Use toFixed(0) for cleaner percentages unless you need decimals
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Use toFixed(0) for cleaner percentages unless you need decimals

return `${sign}${props.score.change.toFixed(0)}%`;
});
</script>

<template>
<div class="flex items-center gap-2 justify-start">
<span>{{ score.value }}</span>
<span
v-if="score.change !== 0"
:class="changeColorClass"
class="text-xs font-semibold"
>
({{ formattedChange }})
</span>
</div>
</template>
Loading
Loading