Improve frontend accessibility
This commit is contained in:
1 parent
de1d3d2d63
commit
af7271e2f8
25 files changed
+478
-225
No files matched your search
@@ -20,31 +20,32 @@
|
||||
/>
|
||||
</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="creators-main">
|
||||
<main class="creators-main" id="main-content" tabindex="-1">
|
||||
<div class="creators-header">
|
||||
<h1>Discover Creators</h1>
|
||||
<p>Follow your favorite prompt artists and get inspired.</p>
|
||||
</div>
|
||||
|
||||
<div class="filter-buttons">
|
||||
<button class="filter-btn active" data-sort="popular">
|
||||
<div class="filter-buttons" role="group" aria-label="Sort creators">
|
||||
<button type="button" class="filter-btn active" data-sort="popular" aria-pressed="true">
|
||||
Popular
|
||||
</button>
|
||||
<button class="filter-btn" data-sort="prompts">Rising</button>
|
||||
<button class="filter-btn" data-sort="new">New</button>
|
||||
<button class="filter-btn" data-sort="rating">Top Rated</button>
|
||||
<button type="button" class="filter-btn" data-sort="prompts" aria-pressed="false">Rising</button>
|
||||
<button type="button" class="filter-btn" data-sort="new" aria-pressed="false">New</button>
|
||||
<button type="button" class="filter-btn" data-sort="rating" aria-pressed="false">Top Rated</button>
|
||||
</div>
|
||||
|
||||
<div class="creators-grid" id="creators-grid"></div>
|
||||
<div class="creators-grid" id="creators-grid" aria-live="polite"></div>
|
||||
|
||||
<div id="creators-empty" class="state-empty">
|
||||
<i class="bi bi-people state-icon"></i>
|
||||
<div id="creators-empty" class="state-empty" role="status" aria-live="polite">
|
||||
<i class="bi bi-people state-icon" aria-hidden="true"></i>
|
||||
<h3 id="creators-empty-title" class="state-title">
|
||||
No creators found
|
||||
</h3>
|
||||
@@ -53,8 +54,8 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="creators-error" class="state-error">
|
||||
<i class="bi bi-exclamation-circle state-icon"></i>
|
||||
<div id="creators-error" class="state-error" role="alert" aria-live="assertive">
|
||||
<i class="bi bi-exclamation-circle state-icon" aria-hidden="true"></i>
|
||||
<h3 class="state-title">Could not load creators</h3>
|
||||
<p id="creators-error-msg"></p>
|
||||
</div>
|
||||
@@ -70,11 +71,17 @@
|
||||
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");
|
||||
});
|
||||
const thirdLink = document.querySelectorAll(
|
||||
"#sidebar-container .sidebar li a",
|
||||
)[2];
|
||||
if (thirdLink) thirdLink.classList.add("active");
|
||||
if (thirdLink) {
|
||||
thirdLink.classList.add("active");
|
||||
thirdLink.setAttribute("aria-current", "page");
|
||||
}
|
||||
});
|
||||
fetch("/topbar.html")
|
||||
.then((r) => r.text())
|
||||
@@ -91,25 +98,28 @@
|
||||
}
|
||||
|
||||
function renderCard(c) {
|
||||
const profileHref = `/profile?id=${encodeURIComponent(c.userId)}`;
|
||||
return `
|
||||
<div class="creator-card">
|
||||
<img class="creator-avatar"
|
||||
src="${c.avatarUrl || "../images/content/cat.png"}"
|
||||
alt="${c.displayName}"
|
||||
onclick="location.href='/profile?id=${c.userId}'">
|
||||
<a class="creator-avatar-link" href="${profileHref}" aria-label="Open profile for ${c.displayName}">
|
||||
<img class="creator-avatar"
|
||||
src="${c.avatarUrl || "../images/content/cat.png"}"
|
||||
alt="${c.displayName}">
|
||||
</a>
|
||||
<div class="creator-info">
|
||||
<h3 class="creator-name"
|
||||
onclick="location.href='/profile?id=${c.userId}'">${c.displayName}</h3>
|
||||
<h3 class="creator-name"><a href="${profileHref}">${c.displayName}</a></h3>
|
||||
<div class="creator-handle">@${c.slug}</div>
|
||||
<p class="creator-bio">${c.bio ?? "No bio yet."}</p>
|
||||
<div class="creator-stats">
|
||||
<span><i class="bi bi-puzzle"></i> ${c.promptCount} prompts</span>
|
||||
<span><i class="bi bi-people"></i> ${c.subscribers}</span>
|
||||
<span><i class="bi bi-puzzle" aria-hidden="true"></i> ${c.promptCount} prompts</span>
|
||||
<span><i class="bi bi-people" aria-hidden="true"></i> ${c.subscribers} subscribers</span>
|
||||
${c.averageRating > 0 ? `<span>${renderStars(c.averageRating)}</span>` : ""}
|
||||
</div>
|
||||
<button class="follow-btn ${c.isFollowing ? "following" : ""}"
|
||||
<button type="button" class="follow-btn ${c.isFollowing ? "following" : ""}"
|
||||
data-userid="${c.userId}"
|
||||
data-following="${c.isFollowing}">
|
||||
data-following="${c.isFollowing}"
|
||||
aria-pressed="${c.isFollowing}"
|
||||
aria-label="${c.isFollowing ? "Unfollow" : "Follow"} ${c.displayName}">
|
||||
${c.isFollowing ? "Following" : "Follow"}
|
||||
</button>
|
||||
</div>
|
||||
@@ -136,6 +146,7 @@
|
||||
const nowFollowing = !isFollowing;
|
||||
btn.dataset.following = nowFollowing;
|
||||
btn.textContent = nowFollowing ? "Following" : "Follow";
|
||||
btn.setAttribute("aria-pressed", String(nowFollowing));
|
||||
btn.classList.toggle("following", nowFollowing);
|
||||
}
|
||||
|
||||
@@ -208,8 +219,12 @@
|
||||
btn.addEventListener("click", () => {
|
||||
document
|
||||
.querySelectorAll(".filter-btn")
|
||||
.forEach((b) => b.classList.remove("active"));
|
||||
.forEach((b) => {
|
||||
b.classList.remove("active");
|
||||
b.setAttribute("aria-pressed", "false");
|
||||
});
|
||||
btn.classList.add("active");
|
||||
btn.setAttribute("aria-pressed", "true");
|
||||
loadCreators(btn.dataset.sort);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user