This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 71 KiB |
@@ -3,8 +3,6 @@
|
||||
const form = document.getElementById("notes-form");
|
||||
const authorInput = document.getElementById("note-author");
|
||||
const contentInput = document.getElementById("note-content");
|
||||
const authorFilter = document.getElementById("notes-author-filter");
|
||||
let notesCache = [];
|
||||
|
||||
if (!wall) return;
|
||||
|
||||
@@ -36,53 +34,6 @@
|
||||
return el;
|
||||
}
|
||||
|
||||
function normaliseAuthor(author) {
|
||||
return (author || "").trim();
|
||||
}
|
||||
|
||||
function populateAuthorFilter(notes) {
|
||||
if (!authorFilter) return;
|
||||
|
||||
const previousValue = authorFilter.value;
|
||||
const authors = Array.from(
|
||||
new Set(notes.map(note => normaliseAuthor(note.author_name)).filter(Boolean))
|
||||
).sort((a, b) => a.localeCompare(b, undefined, { sensitivity: "base" }));
|
||||
|
||||
authorFilter.innerHTML = '<option value="">All authors</option>';
|
||||
|
||||
authors.forEach(author => {
|
||||
const option = document.createElement("option");
|
||||
option.value = author;
|
||||
option.textContent = author;
|
||||
authorFilter.appendChild(option);
|
||||
});
|
||||
|
||||
authorFilter.value = authors.includes(previousValue) ? previousValue : "";
|
||||
}
|
||||
|
||||
function renderNotes() {
|
||||
wall.innerHTML = "";
|
||||
|
||||
const selectedAuthor = authorFilter ? authorFilter.value : "";
|
||||
const notes = selectedAuthor
|
||||
? notesCache.filter(note => normaliseAuthor(note.author_name) === selectedAuthor)
|
||||
: notesCache;
|
||||
|
||||
if (notesCache.length === 0) {
|
||||
wall.innerHTML = "<p>No notes yet.</p>";
|
||||
return;
|
||||
}
|
||||
|
||||
if (notes.length === 0) {
|
||||
wall.innerHTML = "<p>No notes for this author.</p>";
|
||||
return;
|
||||
}
|
||||
|
||||
notes.forEach(note => {
|
||||
wall.appendChild(renderNote(note));
|
||||
});
|
||||
}
|
||||
|
||||
async function loadNotes() {
|
||||
wall.innerHTML = "<p>Loading notes…</p>";
|
||||
|
||||
@@ -91,9 +42,16 @@
|
||||
if (!res.ok) throw new Error("Failed to fetch notes");
|
||||
|
||||
const notes = await res.json();
|
||||
notesCache = notes;
|
||||
populateAuthorFilter(notesCache);
|
||||
renderNotes();
|
||||
wall.innerHTML = "";
|
||||
|
||||
if (notes.length === 0) {
|
||||
wall.innerHTML = "<p>No notes yet.</p>";
|
||||
return;
|
||||
}
|
||||
|
||||
notes.forEach(note => {
|
||||
wall.appendChild(renderNote(note));
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
wall.innerHTML = "<p>Could not load notes.</p>";
|
||||
@@ -140,9 +98,5 @@
|
||||
form.addEventListener("submit", submitNote);
|
||||
}
|
||||
|
||||
if (authorFilter) {
|
||||
authorFilter.addEventListener("change", renderNotes);
|
||||
}
|
||||
|
||||
loadNotes();
|
||||
})();
|
||||
|
||||
@@ -443,38 +443,6 @@ body.no-sidenotes {
|
||||
NOTES BOARD
|
||||
========================= */
|
||||
|
||||
#notes-tools {
|
||||
display: flex;
|
||||
align-items: end;
|
||||
justify-content: flex-end;
|
||||
gap: 0.65rem;
|
||||
margin: 1.25rem 0 0;
|
||||
}
|
||||
|
||||
#notes-tools label {
|
||||
color: var(--muted);
|
||||
font-size: 0.75rem;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
#notes-author-filter {
|
||||
min-width: min(220px, 100%);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
background: var(--surface);
|
||||
color: var(--fg);
|
||||
font: inherit;
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.2;
|
||||
padding: 0.45rem 0.65rem;
|
||||
}
|
||||
|
||||
#notes-author-filter:focus {
|
||||
outline: 2px solid color-mix(in oklab, var(--accent) 45%, transparent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
#notes-wall {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
@@ -490,9 +458,7 @@ body.no-sidenotes {
|
||||
.note {
|
||||
position: relative;
|
||||
padding: 1rem 1rem 0.9rem;
|
||||
background: var(--surface);
|
||||
color: var(--fg);
|
||||
border: 1px solid var(--border);
|
||||
background: --code-bg;
|
||||
border-radius: 8px;
|
||||
box-shadow:
|
||||
0 2px 6px rgba(0, 0, 0, 0.08),
|
||||
@@ -500,9 +466,7 @@ body.no-sidenotes {
|
||||
transform: rotate(var(--note-tilt, 0deg));
|
||||
transition:
|
||||
transform 0.15s ease,
|
||||
box-shadow 0.15s ease,
|
||||
background-color 0.2s ease,
|
||||
border-color 0.2s ease;
|
||||
box-shadow 0.15s ease;
|
||||
|
||||
}
|
||||
|
||||
@@ -547,7 +511,7 @@ body.no-sidenotes {
|
||||
align-items: baseline;
|
||||
font-size: 0.7rem;
|
||||
margin-bottom: 0.5rem;
|
||||
color: var(--muted);
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.note-author {
|
||||
@@ -569,7 +533,7 @@ body.no-sidenotes {
|
||||
font-size: 0.95rem;
|
||||
line-height: 1.45;
|
||||
white-space: pre-wrap;
|
||||
color: var(--fg);
|
||||
color: --fg;
|
||||
}
|
||||
|
||||
/* =========================
|
||||
@@ -581,11 +545,6 @@ body.no-sidenotes {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
#notes-tools {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.note {
|
||||
transform: none;
|
||||
}
|
||||
@@ -608,9 +567,7 @@ body.no-sidenotes {
|
||||
#notes-form {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
background: var(--surface);
|
||||
color: var(--fg);
|
||||
border: 1px solid var(--border);
|
||||
background: --bg;
|
||||
padding: 1.25rem 1.25rem 1.1rem;
|
||||
border-radius: 10px;
|
||||
box-shadow:
|
||||
@@ -643,7 +600,7 @@ body.no-sidenotes {
|
||||
font-size: 0.7rem;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
color: #666;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
@@ -656,13 +613,12 @@ body.no-sidenotes {
|
||||
width: 100%;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--fg);
|
||||
font-family: inherit;
|
||||
font-size: 0.95rem;
|
||||
line-height: 1.45;
|
||||
padding: 0.3rem 0;
|
||||
margin-bottom: 0.9rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
#notes-form textarea {
|
||||
@@ -674,12 +630,12 @@ body.no-sidenotes {
|
||||
#notes-form input:focus,
|
||||
#notes-form textarea:focus {
|
||||
outline: none;
|
||||
border-bottom-color: var(--accent);
|
||||
border-bottom-color: #999;
|
||||
}
|
||||
|
||||
/* placeholder */
|
||||
#notes-form ::placeholder {
|
||||
color: var(--muted);
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
/* =========================
|
||||
@@ -695,15 +651,14 @@ body.no-sidenotes {
|
||||
text-transform: uppercase;
|
||||
border-radius: 999px;
|
||||
border: none;
|
||||
background: var(--fg);
|
||||
color: var(--bg);
|
||||
background: #222;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
float: right;
|
||||
}
|
||||
|
||||
#notes-form button:hover {
|
||||
background: var(--accent);
|
||||
color: var(--surface);
|
||||
background: #000;
|
||||
}
|
||||
|
||||
#notes-form button:disabled {
|
||||
|
||||
Reference in New Issue
Block a user