Improve frontend accessibility
This commit is contained in:
1 parent
de1d3d2d63
commit
af7271e2f8
25 files changed
+478
-225
No files matched your search
@@ -19,26 +19,27 @@
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<a class="skip-link" href="#main-content">Skip to main content</a>
|
||||
<div class="layout">
|
||||
<div id="sidebar-container"></div>
|
||||
|
||||
<div class="page-body">
|
||||
<div id="topbar-container"></div>
|
||||
|
||||
<main class="post-detail-main">
|
||||
<main class="post-detail-main" id="main-content" tabindex="-1">
|
||||
<div class="post-detail-container" id="detail-content">
|
||||
<!-- Loading -->
|
||||
<div id="detail-loading">
|
||||
<i class="bi bi-hourglass-split state-icon"></i>
|
||||
<i class="bi bi-hourglass-split state-icon" aria-hidden="true"></i>
|
||||
<p>Loading prompt...</p>
|
||||
</div>
|
||||
|
||||
<!-- Error -->
|
||||
<div id="detail-error" class="state-error">
|
||||
<i class="bi bi-exclamation-circle state-icon"></i>
|
||||
<div id="detail-error" class="state-error" role="alert" aria-live="assertive">
|
||||
<i class="bi bi-exclamation-circle state-icon" aria-hidden="true"></i>
|
||||
<h3 id="detail-error-title">Prompt not found</h3>
|
||||
<p id="detail-error-msg"></p>
|
||||
<button onclick="history.back()" class="detail-back-btn">
|
||||
<button type="button" onclick="history.back()" class="detail-back-btn">
|
||||
Go Back
|
||||
</button>
|
||||
</div>
|
||||
@@ -55,7 +56,7 @@
|
||||
</div>
|
||||
<div class="detail-actions-right">
|
||||
<span id="tier-badge"></span>
|
||||
<button id="edit-prompt-btn">Edit</button>
|
||||
<button type="button" id="edit-prompt-btn">Edit</button>
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="post-title" id="prompt-title"></h1>
|
||||
@@ -102,7 +103,7 @@
|
||||
|
||||
<!-- Locked section (shown instead of prompt if no access) -->
|
||||
<div id="locked-section">
|
||||
<i class="bi bi-lock-fill locked-icon"></i>
|
||||
<i class="bi bi-lock-fill locked-icon" aria-hidden="true"></i>
|
||||
<h3 class="locked-title">
|
||||
This prompt requires a subscription
|
||||
</h3>
|
||||
@@ -110,7 +111,7 @@
|
||||
Subscribe to <strong id="locked-creator"></strong> to access
|
||||
this prompt.
|
||||
</p>
|
||||
<button id="locked-subscribe-btn">
|
||||
<button type="button" id="locked-subscribe-btn">
|
||||
Subscribe <span id="locked-tier-name"></span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -128,26 +129,30 @@
|
||||
<div
|
||||
class="review-star-input"
|
||||
id="review-star-input"
|
||||
role="group"
|
||||
aria-label="Select rating"
|
||||
>
|
||||
<button type="button" data-rating="1">☆</button>
|
||||
<button type="button" data-rating="2">☆</button>
|
||||
<button type="button" data-rating="3">☆</button>
|
||||
<button type="button" data-rating="4">☆</button>
|
||||
<button type="button" data-rating="5">☆</button>
|
||||
<button type="button" aria-pressed="false" aria-label="1 star" data-rating="1">☆</button>
|
||||
<button type="button" aria-pressed="false" aria-label="2 stars" data-rating="2">☆</button>
|
||||
<button type="button" aria-pressed="false" aria-label="3 stars" data-rating="3">☆</button>
|
||||
<button type="button" aria-pressed="false" aria-label="4 stars" data-rating="4">☆</button>
|
||||
<button type="button" aria-pressed="false" aria-label="5 stars" data-rating="5">☆</button>
|
||||
</div>
|
||||
<textarea
|
||||
id="review-comment"
|
||||
maxlength="200"
|
||||
rows="3"
|
||||
placeholder="Write a short comment..."
|
||||
aria-label="Review comment"
|
||||
aria-describedby="review-comment-hint"
|
||||
></textarea>
|
||||
<p id="review-comment-hint" class="sr-only">Optional comment, maximum 200 characters.</p>
|
||||
<button type="button" id="submit-review-btn">
|
||||
Submit Review
|
||||
</button>
|
||||
<p id="review-message"></p>
|
||||
<p id="review-message" role="status" aria-live="polite"></p>
|
||||
</div>
|
||||
<div class="reviews-list" id="reviews-list">
|
||||
<div class="reviews-list" id="reviews-list" aria-live="polite">
|
||||
<p class="detail-loading-text">Loading reviews...</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -164,7 +169,10 @@
|
||||
document.getElementById("sidebar-container").innerHTML = data;
|
||||
document
|
||||
.querySelectorAll("#sidebar-container .sidebar a")
|
||||
.forEach((l) => l.classList.remove("active"));
|
||||
.forEach((l) => {
|
||||
l.classList.remove("active");
|
||||
l.removeAttribute("aria-current");
|
||||
});
|
||||
});
|
||||
fetch("/topbar.html")
|
||||
.then((r) => r.text())
|
||||
@@ -229,8 +237,8 @@
|
||||
p.description;
|
||||
document.getElementById("prompt-body").textContent = p.content;
|
||||
document.getElementById("prompt-rating-stat").innerHTML =
|
||||
`<i class="bi ${p.isLiked ? "bi-heart-fill" : "bi-heart"} detail-heart-icon"></i> ${p.likeCount || 0} likes
|
||||
<span class="detail-bookmark-span"><i class="bi ${p.isSaved ? "bi-bookmark-fill" : "bi-bookmark"} detail-bookmark-icon"></i> ${p.saveCount || 0} saves</span>`;
|
||||
`<i class="bi ${p.isLiked ? "bi-heart-fill" : "bi-heart"} detail-heart-icon" aria-hidden="true"></i> ${p.likeCount || 0} likes
|
||||
<span class="detail-bookmark-span"><i class="bi ${p.isSaved ? "bi-bookmark-fill" : "bi-bookmark"} detail-bookmark-icon" aria-hidden="true"></i> ${p.saveCount || 0} saves</span>`;
|
||||
renderExamples(p);
|
||||
renderOwnerActions(p);
|
||||
setupReviewSection(p);
|
||||
@@ -242,7 +250,7 @@
|
||||
const price = p.tierMonthlyPrice == null
|
||||
? ""
|
||||
: ` - $${Number(p.tierMonthlyPrice).toFixed(2)}/mo`;
|
||||
badge.innerHTML = `<span class="tier-badge-tier"><i class="bi bi-lock-fill"></i> ${p.tierName}${price}</span>`;
|
||||
badge.innerHTML = `<span class="tier-badge-tier"><i class="bi bi-lock-fill" aria-hidden="true"></i> ${p.tierName}${price}</span>`;
|
||||
} else {
|
||||
badge.innerHTML = `<span class="tier-badge-free">Free</span>`;
|
||||
}
|
||||
@@ -255,9 +263,9 @@
|
||||
<span class="rating-value">${p.averageRating.toFixed(1)}</span>
|
||||
<span class="rating-count">/ 5.0 (${p.reviewCount || 0} ${(p.reviewCount || 0) === 1 ? "review" : "reviews"})</span>`;
|
||||
document.getElementById("prompt-rating-stat").innerHTML =
|
||||
`<i class="bi ${p.isLiked ? "bi-heart-fill" : "bi-heart"} detail-heart-icon"></i> ${p.likeCount || 0} likes
|
||||
<span class="detail-bookmark-span"><i class="bi ${p.isSaved ? "bi-bookmark-fill" : "bi-bookmark"} detail-bookmark-icon"></i> ${p.saveCount || 0} saves</span>
|
||||
<span class="detail-bookmark-span"><i class="bi bi-star-fill detail-bookmark-icon"></i> ${p.averageRating.toFixed(1)} (${p.reviewCount || 0})</span>`;
|
||||
`<i class="bi ${p.isLiked ? "bi-heart-fill" : "bi-heart"} detail-heart-icon" aria-hidden="true"></i> ${p.likeCount || 0} likes
|
||||
<span class="detail-bookmark-span"><i class="bi ${p.isSaved ? "bi-bookmark-fill" : "bi-bookmark"} detail-bookmark-icon" aria-hidden="true"></i> ${p.saveCount || 0} saves</span>
|
||||
<span class="detail-bookmark-span"><i class="bi bi-star-fill detail-bookmark-icon" aria-hidden="true"></i> ${p.averageRating.toFixed(1)} (${p.reviewCount || 0})</span>`;
|
||||
} else {
|
||||
document.getElementById("rating-display").innerHTML =
|
||||
'<span class="rating-none">No ratings yet</span>';
|
||||
@@ -334,6 +342,8 @@
|
||||
.forEach((button) => {
|
||||
const value = Number(button.dataset.rating);
|
||||
button.textContent = value <= rating ? "★" : "☆";
|
||||
button.setAttribute("aria-pressed", String(value === rating));
|
||||
button.setAttribute("aria-label", `${value} ${value === 1 ? "star" : "stars"}${value === rating ? ", selected" : ""}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user