hmaras commited on
Commit
92ff83d
Β·
verified Β·
1 Parent(s): f0f7d41

<div id="build-rating" class="hidden">

Browse files

<h3>Your Build Rating</h3>

<div class="rating-row" data-category="overallRating">
<label>Overall Utility</label>
<span class="star">β˜†</span>
<span class="star">β˜†</span>
<span class="star">β˜†</span>
<span class="star">β˜†</span>
<span class="star">β˜†</span>
<input type="hidden" name="overallRating" value="0">
</div>

<div class="rating-row" data-category="easeOfUseRating">
<label>Ease of Use</label>
<span class="star">β˜†</span>
<span class="star">β˜†</span>
<span class="star">β˜†</span>
<span class="star">β˜†</span>
<span class="star">β˜†</span>
<input type="hidden" name="easeOfUseRating" value="0">
</div>

</div>

Files changed (3) hide show
  1. build-calculator.html +7 -7
  2. script.js +19 -4
  3. style.css +14 -3
build-calculator.html CHANGED
@@ -98,14 +98,14 @@
98
  <div class="space-y-4">
99
  <div class="rating-row" data-category="overallRating">
100
  <label class="block text-gray-700 mb-1">Overall Utility</label>
101
- <div class="flex space-x-1">
102
- <span class="star text-2xl cursor-pointer" data-value="1">β˜†</span>
103
- <span class="star text-2xl cursor-pointer" data-value="2">β˜†</span>
104
- <span class="star text-2xl cursor-pointer" data-value="3">β˜†</span>
105
- <span class="star text-2xl cursor-pointer" data-value="4">β˜†</span>
106
- <span class="star text-2xl cursor-pointer" data-value="5">β˜†</span>
107
  </div>
108
- <input type="hidden" name="overallRating" value="0">
109
  </div>
110
 
111
  <div class="rating-row" data-category="easeRating">
 
98
  <div class="space-y-4">
99
  <div class="rating-row" data-category="overallRating">
100
  <label class="block text-gray-700 mb-1">Overall Utility</label>
101
+ <div class="flex">
102
+ <span class="star" data-value="1">β˜†</span>
103
+ <span class="star" data-value="2">β˜†</span>
104
+ <span class="star" data-value="3">β˜†</span>
105
+ <span class="star" data-value="4">β˜†</span>
106
+ <span class="star" data-value="5">β˜†</span>
107
  </div>
108
+ <input type="hidden" name="overallRating" value="0">
109
  </div>
110
 
111
  <div class="rating-row" data-category="easeRating">
script.js CHANGED
@@ -1,10 +1,25 @@
1
 
2
  // Build Calculator and Utility Handling
3
  document.addEventListener('DOMContentLoaded', function() {
4
- // Initialize star ratings
5
- setupStarRatings('build-rating');
6
-
7
- const buildForm = document.getElementById('build-form');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  const previewElements = {
9
  toon: document.getElementById('preview-toon'),
10
  buildName: document.getElementById('preview-build-name'),
 
1
 
2
  // Build Calculator and Utility Handling
3
  document.addEventListener('DOMContentLoaded', function() {
4
+ // Star Rating Functionality
5
+ document.addEventListener('click', function(e) {
6
+ if (e.target.classList.contains('star')) {
7
+ const stars = e.target.parentElement.querySelectorAll('.star');
8
+ const rating = parseInt(e.target.getAttribute('data-value'));
9
+ const hiddenInput = e.target.parentElement.nextElementSibling;
10
+
11
+ stars.forEach((star, index) => {
12
+ if (index < rating) {
13
+ star.classList.add('active');
14
+ } else {
15
+ star.classList.remove('active');
16
+ }
17
+ });
18
+
19
+ hiddenInput.value = rating;
20
+ }
21
+ });
22
+ const buildForm = document.getElementById('build-form');
23
  const previewElements = {
24
  toon: document.getElementById('preview-toon'),
25
  buildName: document.getElementById('preview-build-name'),
style.css CHANGED
@@ -27,19 +27,30 @@ body {
27
  background: #2563EB;
28
  }
29
  /* Star Rating */
 
 
 
 
 
 
 
 
 
30
  .star {
31
  transition: all 0.2s ease;
32
  color: #d1d5db; /* gray-300 */
 
 
 
33
  }
34
  .star:hover,
35
- .star.rated {
36
  color: #f59e0b; /* yellow-500 */
37
  transform: scale(1.2);
38
  }
39
  .star:hover ~ .star {
40
- color: #d1d5db; /* gray-300 */
41
  }
42
-
43
  /* Animation classes */
44
  .fade-in {
45
  animation: fadeIn 0.5s ease-in-out;
 
27
  background: #2563EB;
28
  }
29
  /* Star Rating */
30
+ .rating-row {
31
+ margin-bottom: 1rem;
32
+ }
33
+ .rating-row label {
34
+ display: block;
35
+ margin-bottom: 0.5rem;
36
+ font-weight: 500;
37
+ color: #374151;
38
+ }
39
  .star {
40
  transition: all 0.2s ease;
41
  color: #d1d5db; /* gray-300 */
42
+ cursor: pointer;
43
+ font-size: 1.5rem;
44
+ margin-right: 0.25rem;
45
  }
46
  .star:hover,
47
+ .star.active {
48
  color: #f59e0b; /* yellow-500 */
49
  transform: scale(1.2);
50
  }
51
  .star:hover ~ .star {
52
+ color: #d1d5db;
53
  }
 
54
  /* Animation classes */
55
  .fade-in {
56
  animation: fadeIn 0.5s ease-in-out;