feat: Add leaderboard with grid display and tab navigation
This commit is contained in:
1 parent
475aa1caf2
commit
330a79e6e3
1 file changed
+134
-88
+134
-88
@@ -1,98 +1,144 @@
|
|||||||
{% comment %} --- Static Demo Data --- {% endcomment %}
|
<div class="max-w-screen-lg mx-auto px-4 py-8">
|
||||||
{% assign demo_users = "" | split: "," %}
|
<h1 class="text-3xl font-bold text-text-title mb-6 pb-4 border-b border-gray-200">Leaderboard</h1>
|
||||||
{% assign user1 = '{"username": "chair_enthusiast2025", "merits": 152, "posts": 15, "comments": 45, "joined": "2024-11-01"}' | parse_json %}
|
|
||||||
{% assign user2 = '{"username": "desk_ninja", "merits": 121, "posts": 8, "comments": 72, "joined": "2025-01-15"}' | parse_json %}
|
|
||||||
{% assign user3 = '{"username": "cable_conqueror", "merits": 98, "posts": 25, "comments": 30, "joined": "2024-12-20"}' | parse_json %}
|
|
||||||
{% assign user4 = '{"username": "ergonomic_explorer", "merits": 85, "posts": 12, "comments": 55, "joined": "2025-03-10"}' | parse_json %}
|
|
||||||
{% assign user5 = '{"username": "monitor_maven", "merits": 77, "posts": 5, "comments": 60, "joined": "2025-04-22"}' | parse_json %}
|
|
||||||
{% assign user6 = '{"username": "keyboard_king", "merits": 65, "posts": 18, "comments": 28, "joined": "2025-02-05"}' | parse_json %}
|
|
||||||
{% assign user7 = '{"username": "plant_parent_pro", "merits": 50, "posts": 3, "comments": 40, "joined": "2025-05-01"}' | parse_json %}
|
|
||||||
{% assign user8 = '{"username": "snack_strategist", "merits": 42, "posts": 22, "comments": 15, "joined": "2025-04-18"}' | parse_json %}
|
|
||||||
{% assign user9 = '{"username": "focus_finder", "merits": 30, "posts": 10, "comments": 20, "joined": "2025-03-28"}' | parse_json %}
|
|
||||||
{% assign user10 = '{"username": "newbie_navigator", "merits": 15, "posts": 2, "comments": 8, "joined": "2025-05-04"}' | parse_json %}
|
|
||||||
|
|
||||||
{% assign demo_users = demo_users | push: user1 | push: user2 | push: user3 | push: user4 | push: user5 | push: user6 | push: user7 | push: user8 | push: user9 | push: user10 %}
|
<!-- Tabs Navigation -->
|
||||||
|
<div class="mb-4 border-b border-gray-200">
|
||||||
{% comment %} Sort Users for Leaderboards {% endcomment %}
|
<nav class="-mb-px flex space-x-8" aria-label="Tabs">
|
||||||
{% assign top_merits_users = demo_users | sort: "merits" | reverse %}
|
<a href="#tab-merits" class="group whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
{% assign top_posters = demo_users | sort: "posts" | reverse %}
|
border-primary text-primary [&:not(:target):not(:has(~:target))]:border-primary [&:not(:target):not(:has(~:target))]:text-primary
|
||||||
{% assign top_commenters = demo_users | sort: "comments" | reverse %}
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
{% assign new_users = demo_users | sort: "joined" | reverse %}
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
|
Merits
|
||||||
|
</a>
|
||||||
{% comment %} --- Leaderboard Display --- {% endcomment %}
|
<a href="#tab-new-users" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
<div class="leaderboard space-y-10">
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
<!-- Top Merits -->
|
New Users
|
||||||
<section>
|
</a>
|
||||||
<h2 class="text-2xl font-bold text-primary mb-4 font-action flex items-center">
|
<a href="#tab-most-posts" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
<i class="fas fa-trophy text-yellow-500 mr-3 fa-fw"></i> Top Merits (All-Time)
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
</h2>
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
<ol class="list-none space-y-3">
|
Most Posts
|
||||||
{% for user in top_merits_users limit:10 %}
|
</a>
|
||||||
<li class="flex items-center justify-between p-3 bg-bg-footer rounded-md shadow-sm border border-gray-200">
|
<a href="#tab-most-comments" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
<div class="flex items-center">
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
<span class="text-lg font-bold text-text-muted w-8 text-right mr-4">{{ forloop.index }}</span>
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
<a href="/user/{{ user.username }}/" class="text-primary font-action hover:underline font-medium">{{ user.username }}</a>
|
Most Comments
|
||||||
|
</a>
|
||||||
|
<a href="#tab-most-votes" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
|
Most Votes
|
||||||
|
</a>
|
||||||
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
<span class="text-primary font-bold font-action">{{ user.merits }} Merits</span>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Most Posts -->
|
<!-- Sub-Tabs Navigation -->
|
||||||
<section>
|
<div class="mb-4 border-b border-gray-200">
|
||||||
<h2 class="text-2xl font-bold text-primary mb-4 font-action flex items-center">
|
<nav class="-mb-px flex space-x-8" aria-label="Sub-Tabs">
|
||||||
<i class="fas fa-file-alt text-purple-500 mr-3 fa-fw"></i> Most Posts Submitted
|
<a href="#sub-tab-week" class="group whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
</h2>
|
border-primary text-primary [&:not(:target):not(:has(~:target))]:border-primary [&:not(:target):not(:has(~:target))]:text-primary
|
||||||
<ol class="list-none space-y-3">
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
{% for user in top_posters limit:10 %}
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
<li class="flex items-center justify-between p-3 bg-bg-footer rounded-md shadow-sm border border-gray-200">
|
Week
|
||||||
<div class="flex items-center">
|
</a>
|
||||||
<span class="text-lg font-bold text-text-muted w-8 text-right mr-4">{{ forloop.index }}</span>
|
<a href="#sub-tab-month" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
<a href="/user/{{ user.username }}/" class="text-primary font-action hover:underline font-medium">{{ user.username }}</a>
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
|
Month
|
||||||
|
</a>
|
||||||
|
<a href="#sub-tab-quarter" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
|
Quarter
|
||||||
|
</a>
|
||||||
|
<a href="#sub-tab-year" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
|
Year
|
||||||
|
</a>
|
||||||
|
<a href="#sub-tab-all-time" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
|
All-time
|
||||||
|
</a>
|
||||||
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
<span class="text-primary font-bold font-action">{{ user.posts }} Posts</span>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Most Comments -->
|
<!-- Tab Content Panes -->
|
||||||
<section>
|
<div class="space-y-6">
|
||||||
<h2 class="text-2xl font-bold text-primary mb-4 font-action flex items-center">
|
<div id="tab-merits" class="block [&:not(:target)]:hidden [&:not(:target):not(:has(~:target))]:block space-y-6">
|
||||||
<i class="fas fa-comments text-blue-500 mr-3 fa-fw"></i> Most Comments Submitted
|
<div id="sub-tab-week" class="block [&:not(:target)]:hidden [&:not(:target):not(:has(~:target))]:block space-y-6">
|
||||||
</h2>
|
<!-- Users Grid for Merits - Week -->
|
||||||
<ol class="list-none space-y-3">
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
{% for user in top_commenters limit:10 %}
|
<!-- Example User Card -->
|
||||||
<li class="flex items-center justify-between p-3 bg-bg-footer rounded-md shadow-sm border border-gray-200">
|
<div class="bg-white p-4 rounded-md shadow-md">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center space-x-4">
|
||||||
<span class="text-lg font-bold text-text-muted w-8 text-right mr-4">{{ forloop.index }}</span>
|
<img src="/assets/images/default-avatar.png" alt="User Avatar" class="w-12 h-12 rounded-full">
|
||||||
<a href="/user/{{ user.username }}/" class="text-primary font-action hover:underline font-medium">{{ user.username }}</a>
|
<div>
|
||||||
|
<h3 class="text-lg font-bold text-text-title">User1</h3>
|
||||||
|
<p class="text-sm text-text-muted">Merits: 150</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Add more user cards as needed -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="sub-tab-month" class="hidden [&:target]:block space-y-6">
|
||||||
|
<!-- Users Grid for Merits - Month -->
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
<!-- Example User Card -->
|
||||||
|
<div class="bg-white p-4 rounded-md shadow-md">
|
||||||
|
<div class="flex items-center space-x-4">
|
||||||
|
<img src="/assets/images/default-avatar.png" alt="User Avatar" class="w-12 h-12 rounded-full">
|
||||||
|
<div>
|
||||||
|
<h3 class="text-lg font-bold text-text-title">User2</h3>
|
||||||
|
<p class="text-sm text-text-muted">Merits: 300</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Add more user cards as needed -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Add more sub-tabs for Merits as needed -->
|
||||||
</div>
|
</div>
|
||||||
<span class="text-primary font-bold font-action">{{ user.comments }} Comments</span>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- New Users -->
|
<div id="tab-new-users" class="hidden [&:target]:block space-y-6">
|
||||||
<section>
|
<div id="sub-tab-week" class="block [&:not(:target)]:hidden [&:not(:target):not(:has(~:target))]:block space-y-6">
|
||||||
<h2 class="text-2xl font-bold text-primary mb-4 font-action flex items-center">
|
<!-- Users Grid for New Users - Week -->
|
||||||
<i class="fas fa-user-plus text-green-500 mr-3 fa-fw"></i> Newest Members
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
</h2>
|
<!-- Example User Card -->
|
||||||
<ol class="list-none space-y-3">
|
<div class="bg-white p-4 rounded-md shadow-md">
|
||||||
{% for user in new_users limit:10 %}
|
<div class="flex items-center space-x-4">
|
||||||
<li class="flex items-center justify-between p-3 bg-bg-footer rounded-md shadow-sm border border-gray-200">
|
<img src="/assets/images/default-avatar.png" alt="User Avatar" class="w-12 h-12 rounded-full">
|
||||||
<div class="flex items-center">
|
<div>
|
||||||
<span class="text-lg font-bold text-text-muted w-8 text-right mr-4">{{ forloop.index }}</span>
|
<h3 class="text-lg font-bold text-text-title">NewUser1</h3>
|
||||||
<a href="/user/{{ user.username }}/" class="text-primary font-action hover:underline font-medium">{{ user.username }}</a>
|
<p class="text-sm text-text-muted">Joined: 2 days ago</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Add more user cards as needed -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="sub-tab-month" class="hidden [&:target]:block space-y-6">
|
||||||
|
<!-- Users Grid for New Users - Month -->
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
<!-- Example User Card -->
|
||||||
|
<div class="bg-white p-4 rounded-md shadow-md">
|
||||||
|
<div class="flex items-center space-x-4">
|
||||||
|
<img src="/assets/images/default-avatar.png" alt="User Avatar" class="w-12 h-12 rounded-full">
|
||||||
|
<div>
|
||||||
|
<h3 class="text-lg font-bold text-text-title">NewUser2</h3>
|
||||||
|
<p class="text-sm text-text-muted">Joined: 1 month ago</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Add more user cards as needed -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Add more sub-tabs for New Users as needed -->
|
||||||
</div>
|
</div>
|
||||||
<span class="text-sm text-text-muted font-action">Joined {{ user.joined | date: "%b %d, %Y" }}</span>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
<!-- Add more tabs for Most Posts, Most Comments, Most Votes as needed -->
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
Reference in new issue
Block a user