diff --git a/web/admin.html b/web/admin.html index 55c576a..c62a577 100644 --- a/web/admin.html +++ b/web/admin.html @@ -120,7 +120,7 @@
-
+
+
+ + +
`; + const starIcon = isActive ? '⭐' : '☆'; // filled star vs outline star + const color = isActive ? '#fbbf24' : '#9ca3af'; // yellow-400 : gray-400 + return ``; }).join(""); } + addStarHoverBehavior(promptId) { + const starButtons = document.querySelectorAll(`[data-prompt-id="${promptId}"].star-btn`); + const ratingElement = document.querySelector(`[data-id="${promptId}"][data-rating]`); + const currentRating = parseInt(ratingElement?.dataset.rating || 0); + + starButtons.forEach((starBtn, index) => { + const starNum = index + 1; + + starBtn.addEventListener('mouseenter', () => { + // Light up all stars up to this one on hover + starButtons.forEach((btn, i) => { + if (i < starNum) { + btn.textContent = '⭐'; + btn.style.color = '#fcd34d'; // bright yellow on hover + } else { + btn.textContent = '☆'; + btn.style.color = '#9ca3af'; // gray + } + }); + }); + + starBtn.addEventListener('mouseleave', () => { + // Reset to current rating + starButtons.forEach((btn, i) => { + if (i < currentRating) { + btn.textContent = '⭐'; + btn.style.color = '#fbbf24'; // yellow + } else { + btn.textContent = '☆'; + btn.style.color = '#9ca3af'; // gray + } + }); + }); + }); + } + escapeHtml(text) { const div = document.createElement("div"); div.textContent = text; @@ -1376,6 +1467,8 @@ if (ratingElement) { ratingElement.dataset.rating = rating; ratingElement.innerHTML = this.renderStars(rating, promptId); + // Add hover behavior to new stars + this.addStarHoverBehavior(promptId); } try {