restyling 2
This commit is contained in:
1 parent
20a93c927c
commit
e3e72d8376
3 files changed
+96
-22
No files matched your search
@@ -84,6 +84,9 @@
|
||||
<!-- Comments feed -->
|
||||
<div id="comments-list"></div>
|
||||
|
||||
<!-- Pagination -->
|
||||
<div id="comments-pagination" class="steam-pagination"></div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
+44
-8
@@ -107,21 +107,57 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
firebase.initializeApp(FIREBASE_CONFIG);
|
||||
const db = firebase.firestore();
|
||||
|
||||
// ── Real-time feed ───────────────────────────────────────────
|
||||
// ── Real-time feed & Pagination ──────────────────────────────
|
||||
let allComments = [];
|
||||
let currentPage = 1;
|
||||
const COMMENTS_PER_PAGE = 5;
|
||||
const paginationEl = document.getElementById('comments-pagination');
|
||||
|
||||
function renderPage() {
|
||||
listEl.innerHTML = '';
|
||||
if (paginationEl) paginationEl.innerHTML = '';
|
||||
|
||||
if (allComments.length === 0) {
|
||||
listEl.innerHTML = '<p class="no-comments">No messages yet — be the first!</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
const totalPages = Math.ceil(allComments.length / COMMENTS_PER_PAGE);
|
||||
if (currentPage > totalPages) currentPage = totalPages;
|
||||
if (currentPage < 1) currentPage = 1;
|
||||
|
||||
const start = (currentPage - 1) * COMMENTS_PER_PAGE;
|
||||
const end = start + COMMENTS_PER_PAGE;
|
||||
const slice = allComments.slice(start, end);
|
||||
|
||||
slice.forEach(data => listEl.appendChild(buildBubble(data)));
|
||||
|
||||
// Build pagination controls
|
||||
if (totalPages > 1 && paginationEl) {
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
const btn = document.createElement('button');
|
||||
btn.className = 'steam-page-btn' + (i === currentPage ? ' active' : '');
|
||||
btn.textContent = i;
|
||||
btn.onclick = () => {
|
||||
currentPage = i;
|
||||
renderPage();
|
||||
};
|
||||
paginationEl.appendChild(btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
db.collection(COLLECTION)
|
||||
.orderBy('timestamp', 'desc')
|
||||
.onSnapshot(snap => {
|
||||
listEl.innerHTML = '';
|
||||
|
||||
if (titleEl) {
|
||||
titleEl.textContent = snap.size > 0 ? `(${snap.size})` : '';
|
||||
}
|
||||
|
||||
if (snap.empty) {
|
||||
listEl.innerHTML = '<p class="no-comments">No messages yet — be the first!</p>';
|
||||
return;
|
||||
}
|
||||
snap.forEach(doc => listEl.appendChild(buildBubble(doc.data())));
|
||||
allComments = [];
|
||||
snap.forEach(doc => allComments.push(doc.data()));
|
||||
|
||||
renderPage();
|
||||
|
||||
}, err => {
|
||||
console.error(err);
|
||||
|
||||
+49
-14
@@ -270,24 +270,26 @@
|
||||
|
||||
/* Steam "Post Comment" button */
|
||||
#comment-submit {
|
||||
background: linear-gradient(to bottom, #4e7d10, #3a5e0c);
|
||||
color: #d2e885;
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
padding: 6px 16px;
|
||||
font-size: 0.8rem;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
background: #02e3ff;
|
||||
border: 1px solid #00c0d8;
|
||||
color: #000000;
|
||||
padding: 6px 12px;
|
||||
border-radius: 4px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
letter-spacing: 0.5px;
|
||||
transition: filter 0.15s;
|
||||
text-shadow: 1px 1px 0 rgba(0,0,0,0.4);
|
||||
box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
|
||||
transition: background 0.15s, transform 0.1s;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
text-transform: uppercase;
|
||||
box-shadow: 0 0 10px rgba(2, 227, 255, 0.4);
|
||||
}
|
||||
|
||||
#comment-submit:hover:not(:disabled) { filter: brightness(1.15); }
|
||||
#comment-submit:active:not(:disabled) { filter: brightness(0.9); }
|
||||
#comment-submit:disabled { opacity: 0.4; cursor: not-allowed; }
|
||||
#comment-submit:hover:not(:disabled) {
|
||||
background: #ffffff;
|
||||
box-shadow: 0 0 15px rgba(2, 227, 255, 0.8);
|
||||
transform: scale(1.05);
|
||||
}
|
||||
#comment-submit:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
|
||||
|
||||
/* Comment count next to header */
|
||||
.comment-count-badge {
|
||||
@@ -351,3 +353,36 @@
|
||||
.pfp-clear:hover {
|
||||
color: #ff7070;
|
||||
}
|
||||
|
||||
/* ── Pagination ──────────────────────────────────────────── */
|
||||
.steam-pagination {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 5px;
|
||||
margin-top: 20px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.steam-page-btn {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
color: #c6d4df;
|
||||
padding: 6px 12px;
|
||||
border-radius: 2px;
|
||||
font-size: 0.8rem;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
.steam-page-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.steam-page-btn.active {
|
||||
background: #02e3ff;
|
||||
border-color: #00c0d8;
|
||||
color: #000;
|
||||
font-weight: bold;
|
||||
}
|
||||
Reference in new issue
Block a user