Enhances user experience with dark‑mode detection, responsive layout, and streamlined role selection workflow
145 lines
8.3 KiB
HTML
145 lines
8.3 KiB
HTML
{% load static %}
|
|
<div class="mb-6 flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
|
<div>
|
|
<h1 class="text-2xl font-bold">Leaderboard</h1>
|
|
<p class="text-gray-500 dark:text-gray-400 text-sm mt-1">
|
|
{% if days == 7 %}Last 7 Days{% else %}Last 30 Days{% endif %} · Top {{ top_n }} Contributors
|
|
</p>
|
|
</div>
|
|
<div class="flex items-center gap-3">
|
|
<select hx-get="/dashboard/leaderboard/" hx-target="#main-content" hx-swap="innerHTML" name="days" class="text-sm border border-gray-200 dark:border-gray-600 rounded-lg px-3 py-2 bg-white dark:bg-gray-950">
|
|
<option value="7" {% if days == 7 %}selected{% endif %}>Last 7 Days</option>
|
|
<option value="30" {% if days == 30 %}selected{% endif %}>Last 30 Days</option>
|
|
</select>
|
|
<select hx-get="/dashboard/leaderboard/" hx-target="#main-content" hx-swap="innerHTML" name="top" class="text-sm border border-gray-200 dark:border-gray-600 rounded-lg px-3 py-2 bg-white dark:bg-gray-950">
|
|
<option value="5" {% if top_n == 5 %}selected{% endif %}>Top 5</option>
|
|
<option value="10" {% if top_n == 10 %}selected{% endif %}>Top 10</option>
|
|
<option value="20" {% if top_n == 20 %}selected{% endif %}>Top 20</option>
|
|
<option value="50" {% if top_n == 50 %}selected{% endif %}>Top 50</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="space-y-3">
|
|
{% for entry in leaderboard %}
|
|
<div class="rounded-lg bg-white dark:bg-gray-950 p-4 sm:p-6 shadow-sm ring-1 ring-gray-950/5 dark:ring-white/10 hover:shadow-md transition-shadow">
|
|
{# Mobile layout #}
|
|
<div class="block sm:hidden">
|
|
<div class="flex items-center gap-3 mb-4">
|
|
<div class="flex-shrink-0">
|
|
<div class="flex items-center justify-center w-10 h-10 rounded-full {% if forloop.counter0 == 0 %}bg-yellow-100 dark:bg-yellow-900{% elif forloop.counter0 == 1 %}bg-gray-100 dark:bg-gray-800{% elif forloop.counter0 == 2 %}bg-orange-100 dark:bg-orange-900{% else %}bg-gray-100 dark:bg-gray-800{% endif %} font-bold text-lg">
|
|
<span class="text-lg">{% if forloop.counter0 == 0 %}🥇{% elif forloop.counter0 == 1 %}🥈{% elif forloop.counter0 == 2 %}🥉{% else %}🏅{% endif %}</span>
|
|
</div>
|
|
<div class="text-center mt-1">
|
|
<span class="text-xs font-medium text-gray-500 dark:text-gray-400">#{{ forloop.counter }}</span>
|
|
</div>
|
|
</div>
|
|
<div class="flex-1 min-w-0">
|
|
<div class="flex items-center gap-2 mb-1">
|
|
{% with name=entry.user.get_full_name|default:entry.user.username %}
|
|
<div class="flex items-center justify-center text-white font-medium rounded-full h-8 w-8 text-xs" style="background-color:{{ entry.avatar_color }}">
|
|
{{ name|make_list|first|upper }}
|
|
</div>
|
|
{% endwith %}
|
|
<div class="min-w-0">
|
|
<h4 class="text-base font-semibold text-gray-900 dark:text-white truncate">{{ entry.user.get_full_name|default:entry.user.username }}</h4>
|
|
</div>
|
|
</div>
|
|
<p class="text-sm text-gray-500 dark:text-gray-400">
|
|
Total Score: <span class="font-bold text-blue-600 dark:text-blue-400">{{ entry.score|floatformat:0 }}</span>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-3">
|
|
<div class="text-center p-3 bg-gray-50 dark:bg-gray-800 rounded-lg">
|
|
<p class="text-lg font-bold text-gray-900 dark:text-white">{{ entry.tickets_created }}</p>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 font-medium">Tickets</p>
|
|
</div>
|
|
<div class="text-center p-3 bg-gray-50 dark:bg-gray-800 rounded-lg">
|
|
<p class="text-lg font-bold text-gray-900 dark:text-white">{{ entry.status_changes }}</p>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 font-medium">Updates</p>
|
|
</div>
|
|
<div class="text-center p-3 bg-gray-50 dark:bg-gray-800 rounded-lg">
|
|
<p class="text-lg font-bold text-gray-900 dark:text-white">{{ entry.comments_made }}</p>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 font-medium">Comments</p>
|
|
</div>
|
|
<div class="text-center p-3 bg-gray-50 dark:bg-gray-800 rounded-lg">
|
|
<p class="text-lg font-bold text-gray-900 dark:text-white">{{ entry.active_days }}</p>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 font-medium">Active Days</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{# Desktop layout #}
|
|
<div class="hidden sm:flex items-center justify-between gap-6">
|
|
<div class="flex items-center gap-4 flex-1 min-w-0">
|
|
<div class="flex-shrink-0">
|
|
<div class="flex items-center justify-center w-12 h-12 rounded-full {% if forloop.counter0 == 0 %}bg-yellow-100 dark:bg-yellow-900{% elif forloop.counter0 == 1 %}bg-gray-100 dark:bg-gray-800{% elif forloop.counter0 == 2 %}bg-orange-100 dark:bg-orange-900{% else %}bg-gray-100 dark:bg-gray-800{% endif %} font-bold text-lg">
|
|
<span class="text-xl">{% if forloop.counter0 == 0 %}🥇{% elif forloop.counter0 == 1 %}🥈{% elif forloop.counter0 == 2 %}🥉{% else %}🏅{% endif %}</span>
|
|
</div>
|
|
<div class="text-center mt-1">
|
|
<span class="text-xs font-medium text-gray-500 dark:text-gray-400">#{{ forloop.counter }}</span>
|
|
</div>
|
|
</div>
|
|
<div class="flex-1 min-w-0">
|
|
<div class="flex items-center gap-3 mb-2">
|
|
{% with name=entry.user.get_full_name|default:entry.user.username %}
|
|
<div class="flex items-center justify-center text-white font-medium rounded-full h-10 w-10 text-sm" style="background-color:{{ entry.avatar_color }}">
|
|
{{ name|make_list|first|upper }}
|
|
</div>
|
|
{% endwith %}
|
|
<div>
|
|
<h4 class="text-lg font-semibold text-gray-900 dark:text-white truncate">{{ entry.user.get_full_name|default:entry.user.username }}</h4>
|
|
<p class="text-sm text-gray-500 dark:text-gray-400">
|
|
Total Score: <span class="font-bold text-blue-600 dark:text-blue-400 text-lg">{{ entry.score|floatformat:0 }}</span>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="flex items-center gap-6 flex-shrink-0">
|
|
<div class="text-center">
|
|
<p class="text-xl font-bold text-gray-900 dark:text-white">{{ entry.tickets_created }}</p>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 font-medium">Tickets</p>
|
|
</div>
|
|
<div class="text-center">
|
|
<p class="text-xl font-bold text-gray-900 dark:text-white">{{ entry.status_changes }}</p>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 font-medium">Updates</p>
|
|
</div>
|
|
<div class="text-center">
|
|
<p class="text-xl font-bold text-gray-900 dark:text-white">{{ entry.comments_made }}</p>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 font-medium">Comments</p>
|
|
</div>
|
|
<div class="text-center">
|
|
<p class="text-xl font-bold text-gray-900 dark:text-white">{{ entry.active_days }}</p>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 font-medium">Active Days</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% empty %}
|
|
<div class="text-center py-12 text-gray-400">
|
|
<span class="text-4xl block mb-4">🏆</span>
|
|
<p class="text-lg font-medium text-gray-900 dark:text-white mb-2">No Contributors Found</p>
|
|
<p class="text-sm text-gray-500 dark:text-gray-400">No user activity found for the selected time period.</p>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<div class="rounded-lg bg-white dark:bg-gray-950 shadow-sm ring-1 ring-gray-950/5 dark:ring-white/10 mt-6">
|
|
<div class="flex items-center gap-3 px-6 py-4 border-b border-gray-100 dark:border-gray-600">
|
|
<div>
|
|
<h3 class="text-base font-semibold text-gray-900 dark:text-white">📊 Scoring System</h3>
|
|
<p class="text-sm text-gray-500 dark:text-gray-400">How contribution scores are calculated</p>
|
|
</div>
|
|
</div>
|
|
<div class="p-6">
|
|
<div class="p-4 bg-gray-50 dark:bg-gray-800 rounded-lg">
|
|
<h4 class="text-sm font-semibold text-gray-900 dark:text-white mb-2">📐 Score Calculation Formula:</h4>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 font-mono">
|
|
Total Score = (Status Changes × 5) + (Tickets Created × 2) + (Comments Made × 2) + (Active Days × 1)
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|