|
1 | 1 | {% extends "base.html" %} |
2 | 2 | {% block content %} |
3 | 3 | {% include "includes/sidenav.html" %} |
4 | | - <div class="text-center mx-auto my-5 p-5 bg-gray-100 rounded-lg max-w-4xl shadow-md"> |
5 | | - <h2 class="text-xl font-bold">Single User Challenges</h2> |
6 | | - {% if challenges %} |
7 | | - <div> |
8 | | - {% for challenge in challenges %} |
9 | | - <div class="my-4 p-4 bg-white rounded-lg border border-gray-300 text-left cursor-pointer shadow-sm hover:shadow-md transition-shadow duration-300" |
10 | | - onclick="toggleDetails({{ challenge.id }})"> |
11 | | - <div class="flex justify-between items-center"> |
12 | | - <span class="text-lg font-bold flex-grow">{{ challenge.title }}</span> |
13 | | - <span class="text-sm text-gray-500 font-bold mr-1">{{ challenge.points }} pts</span> |
14 | | - <span id="dropdown-icon-{{ challenge.id }}" |
15 | | - class="fas fa-chevron-down text-base transition-transform duration-300"></span> |
16 | | - </div> |
17 | | - <div id="challenge-details-{{ challenge.id }}" |
18 | | - class="hidden mt-2 text-sm text-gray-600"> |
19 | | - <p>{{ challenge.description }}</p> |
20 | | - </div> |
21 | | - <!-- Progress Bar always visible --> |
22 | | - <div class="relative w-full bg-gray-300 rounded mt-2 h-5"> |
23 | | - <div class="h-full bg-red-600 rounded transition-all duration-500" |
24 | | - id="progress-bar-{{ challenge.id }}" |
25 | | - data-progress="{{ challenge.progress }}"></div> |
26 | | - <span class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 font-bold text-gray-800">{{ challenge.progress|floatformat:0 }}%</span> |
27 | | - </div> |
| 4 | + <div class="container mx-auto px-4 py-8"> |
| 5 | + <div class="max-w-4xl mx-auto"> |
| 6 | + <!-- Header Section --> |
| 7 | + <div class="bg-white rounded-2xl shadow-lg p-8 mb-8"> |
| 8 | + <div class="flex items-center gap-6"> |
| 9 | + <div class="w-16 h-16 bg-[#e74c3c] rounded-full flex items-center justify-center"> |
| 10 | + <i class="fas fa-user-check text-2xl text-white"></i> |
28 | 11 | </div> |
29 | | - {% endfor %} |
| 12 | + <div> |
| 13 | + <h1 class="text-3xl font-bold text-gray-800">Individual Challenges</h1> |
| 14 | + <p class="text-gray-600 mt-2">Complete personal challenges to earn points, BACON tokens, and showcase your skills</p> |
| 15 | + </div> |
| 16 | + </div> |
30 | 17 | </div> |
31 | | - {% else %} |
32 | | - <p class="text-gray-700">No challenges available.</p> |
33 | | - {% endif %} |
| 18 | + {% if challenges %} |
| 19 | + <div class="space-y-4"> |
| 20 | + {% for challenge in challenges %} |
| 21 | + <div class="bg-white rounded-xl shadow-md hover:shadow-lg transition-all duration-300 overflow-hidden" |
| 22 | + x-data="{ open: false }"> |
| 23 | + <!-- Challenge Header --> |
| 24 | + <div class="p-6 cursor-pointer" @click="open = !open"> |
| 25 | + <div class="flex items-center justify-between"> |
| 26 | + <div class="flex items-center gap-4"> |
| 27 | + <div class="w-12 h-12 bg-[#e74c3c] bg-opacity-10 rounded-lg flex items-center justify-center"> |
| 28 | + <i class="fas fa-medal text-[#e74c3c] text-xl"></i> |
| 29 | + </div> |
| 30 | + <div> |
| 31 | + <h3 class="text-lg font-bold text-gray-800">{{ challenge.title }}</h3> |
| 32 | + <div class="flex items-center gap-4 mt-1"> |
| 33 | + <span class="text-sm font-medium text-[#e74c3c]">{{ challenge.points }} points</span> |
| 34 | + <div class="flex items-center gap-1"> |
| 35 | + <i class="fas fa-bacon text-[#e74c3c] text-sm"></i> |
| 36 | + <span class="text-sm font-medium text-[#e74c3c]">{{ challenge.bacon_reward }} BACON</span> |
| 37 | + </div> |
| 38 | + {% if challenge.progress >= 100 %} |
| 39 | + <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800"> |
| 40 | + <i class="fas fa-check-circle mr-1"></i> |
| 41 | + Completed |
| 42 | + </span> |
| 43 | + {% endif %} |
| 44 | + </div> |
| 45 | + </div> |
| 46 | + </div> |
| 47 | + <div class="flex items-center gap-4"> |
| 48 | + <!-- Progress Circle --> |
| 49 | + <div class="relative w-12 h-12"> |
| 50 | + <svg class="w-12 h-12 transform -rotate-90"> |
| 51 | + <circle class="text-gray-200" stroke-width="3" stroke="currentColor" fill="transparent" r="20" cx="24" cy="24" /> |
| 52 | + <circle class="text-[#e74c3c]" stroke-width="3" stroke-linecap="round" stroke="currentColor" fill="transparent" r="20" cx="24" cy="24" style="stroke-dasharray: {{ challenge.stroke_dasharray }}; stroke-dashoffset: {{ challenge.stroke_dashoffset }}" /> |
| 53 | + </svg> |
| 54 | + <span class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-sm font-medium"> |
| 55 | + {{ challenge.progress|floatformat:0 }}% |
| 56 | + </span> |
| 57 | + </div> |
| 58 | + <i class="fas fa-chevron-down text-gray-400 transform transition-transform duration-300" |
| 59 | + :class="{ 'rotate-180': open }"></i> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + </div> |
| 63 | + <!-- Challenge Details --> |
| 64 | + <div class="overflow-hidden transition-all duration-300 max-h-0" |
| 65 | + x-ref="content" |
| 66 | + x-bind:style="open ? 'max-height: ' + $refs.content.scrollHeight + 'px' : ''"> |
| 67 | + <div class="p-6 pt-0 border-t border-gray-100"> |
| 68 | + <p class="text-gray-600">{{ challenge.description }}</p> |
| 69 | + <div class="mt-4 flex items-center justify-between"> |
| 70 | + <div class="flex items-center gap-2"> |
| 71 | + <div class="w-8 h-8 bg-gray-100 rounded-full flex items-center justify-center"> |
| 72 | + <i class="fas fa-user text-gray-400"></i> |
| 73 | + </div> |
| 74 | + <span class="text-sm font-medium text-gray-700">Personal Challenge</span> |
| 75 | + </div> |
| 76 | + {% if challenge.progress < 100 %} |
| 77 | + <button class="px-4 py-2 bg-[#e74c3c] text-white rounded-lg hover:bg-[#c0392b] transition-colors duration-300"> |
| 78 | + Start Challenge |
| 79 | + </button> |
| 80 | + {% else %} |
| 81 | + <div class="px-4 py-2 bg-green-100 text-green-800 rounded-lg"> |
| 82 | + <i class="fas fa-trophy mr-2"></i> |
| 83 | + Challenge Completed! |
| 84 | + </div> |
| 85 | + {% endif %} |
| 86 | + </div> |
| 87 | + </div> |
| 88 | + </div> |
| 89 | + </div> |
| 90 | + {% endfor %} |
| 91 | + </div> |
| 92 | + {% else %} |
| 93 | + <!-- No Challenges State --> |
| 94 | + <div class="bg-white rounded-xl shadow-md p-8 text-center"> |
| 95 | + <div class="w-16 h-16 mx-auto mb-4 bg-gray-100 rounded-full flex items-center justify-center"> |
| 96 | + <i class="fas fa-clipboard-list text-2xl text-gray-400"></i> |
| 97 | + </div> |
| 98 | + <h3 class="text-xl font-semibold text-gray-800 mb-2">No Challenges Available</h3> |
| 99 | + <p class="text-gray-600">There are no individual challenges available at the moment. Check back later!</p> |
| 100 | + </div> |
| 101 | + {% endif %} |
| 102 | + </div> |
34 | 103 | </div> |
35 | | - <script> |
36 | | -document.addEventListener('DOMContentLoaded', function() { |
37 | | - // Set progress bar widths based on data-progress attribute |
38 | | - const progressBars = document.querySelectorAll('[data-progress]'); |
39 | | - progressBars.forEach(bar => { |
40 | | - const progress = bar.getAttribute('data-progress'); |
41 | | - bar.style.width = progress + '%'; |
42 | | - }); |
43 | | -}); |
44 | | - |
45 | | -function toggleDetails(challengeId) { |
46 | | - const detailsElement = document.getElementById(`challenge-details-${challengeId}`); |
47 | | - const iconElement = document.getElementById(`dropdown-icon-${challengeId}`); |
48 | | - |
49 | | - if (detailsElement.classList.contains("hidden")) { |
50 | | - detailsElement.classList.remove("hidden"); |
51 | | - iconElement.classList.add("transform", "rotate-180"); |
52 | | - } else { |
53 | | - detailsElement.classList.add("hidden"); |
54 | | - iconElement.classList.remove("transform", "rotate-180"); |
55 | | - } |
56 | | -} |
57 | | - </script> |
| 104 | + <!-- Alpine.js for animations --> |
| 105 | + <script src=" https://unpkg.com/[email protected]/dist/cdn.min.js" ></script> |
58 | 106 | {% endblock content %} |
0 commit comments