notes update
All checks were successful
Build Org Website / build (push) Successful in 51s

This commit is contained in:
2026-05-09 15:07:29 +01:00
parent fb3a474738
commit ca82878edf
13 changed files with 311 additions and 69 deletions

View File

@@ -3,6 +3,8 @@
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;
@@ -34,6 +36,53 @@
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>";
@@ -42,16 +91,9 @@
if (!res.ok) throw new Error("Failed to fetch notes");
const notes = await res.json();
wall.innerHTML = "";
if (notes.length === 0) {
wall.innerHTML = "<p>No notes yet.</p>";
return;
}
notes.forEach(note => {
wall.appendChild(renderNote(note));
});
notesCache = notes;
populateAuthorFilter(notesCache);
renderNotes();
} catch (err) {
console.error(err);
wall.innerHTML = "<p>Could not load notes.</p>";
@@ -98,5 +140,9 @@
form.addEventListener("submit", submitNote);
}
if (authorFilter) {
authorFilter.addEventListener("change", renderNotes);
}
loadNotes();
})();

View File

@@ -443,6 +443,38 @@ 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));
@@ -458,7 +490,9 @@ body.no-sidenotes {
.note {
position: relative;
padding: 1rem 1rem 0.9rem;
background: --code-bg;
background: var(--surface);
color: var(--fg);
border: 1px solid var(--border);
border-radius: 8px;
box-shadow:
0 2px 6px rgba(0, 0, 0, 0.08),
@@ -466,7 +500,9 @@ body.no-sidenotes {
transform: rotate(var(--note-tilt, 0deg));
transition:
transform 0.15s ease,
box-shadow 0.15s ease;
box-shadow 0.15s ease,
background-color 0.2s ease,
border-color 0.2s ease;
}
@@ -511,7 +547,7 @@ body.no-sidenotes {
align-items: baseline;
font-size: 0.7rem;
margin-bottom: 0.5rem;
color: #555;
color: var(--muted);
}
.note-author {
@@ -533,7 +569,7 @@ body.no-sidenotes {
font-size: 0.95rem;
line-height: 1.45;
white-space: pre-wrap;
color: --fg;
color: var(--fg);
}
/* =========================
@@ -545,6 +581,11 @@ body.no-sidenotes {
grid-template-columns: 1fr;
}
#notes-tools {
align-items: stretch;
flex-direction: column;
}
.note {
transform: none;
}
@@ -567,7 +608,9 @@ body.no-sidenotes {
#notes-form {
width: 100%;
max-width: 420px;
background: --bg;
background: var(--surface);
color: var(--fg);
border: 1px solid var(--border);
padding: 1.25rem 1.25rem 1.1rem;
border-radius: 10px;
box-shadow:
@@ -600,7 +643,7 @@ body.no-sidenotes {
font-size: 0.7rem;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #666;
color: var(--muted);
margin-bottom: 0.25rem;
}
@@ -613,12 +656,13 @@ 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 #ddd;
border-bottom: 1px solid var(--border);
}
#notes-form textarea {
@@ -630,12 +674,12 @@ body.no-sidenotes {
#notes-form input:focus,
#notes-form textarea:focus {
outline: none;
border-bottom-color: #999;
border-bottom-color: var(--accent);
}
/* placeholder */
#notes-form ::placeholder {
color: #aaa;
color: var(--muted);
}
/* =========================
@@ -651,14 +695,15 @@ body.no-sidenotes {
text-transform: uppercase;
border-radius: 999px;
border: none;
background: #222;
color: #fff;
background: var(--fg);
color: var(--bg);
cursor: pointer;
float: right;
}
#notes-form button:hover {
background: #000;
background: var(--accent);
color: var(--surface);
}
#notes-form button:disabled {