From 004be9b038f6f850e6db4223b44de1c4455e45d7 Mon Sep 17 00:00:00 2001 From: vickydotbat Date: Fri, 17 Jul 2026 16:43:12 +0000 Subject: [PATCH] Topbar unread drawer (#28) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds an Unread dropdown to the topbar utilities (before notifications), per docs/superpowers/plans/2026-07-17-topbar-unread-drawer.md. - New partial `templates/partials/header/unread-drawer.tpl`: toggle with live `component="unread/count"` badge (core socket updates), server-rendered empty/footer rows. - `public/client.js`: on dropdown open, fetches `GET /api/unread` and injects up to 10 topic rows (titles/categories via textContent only); fetch failure falls back to the empty state. - Mobile burger drawer gets an Unread row with the same badge. - SCSS: unread dropdown joins the shared dropdown width rule; flex row styles for topic items. Deviations from the plan's example code, found by live verification against the dev forum: - Plan's `api.get('/unread')` hits the v3 write API and 404s → replaced with a fetch of the `/api/unread` read route. - NodeBB 4 has no global `window.require`, so runtime translation of the static `[[unread:...]]` strings never ran → those strings are now server-rendered in the template (also removes the plan's translate-over-innerHTML step, which would have re-parsed untrusted titles as HTML). Verified: full plain-node test suite passes; Playwright against the dev container passed all checks (badge count, item ordering before notifications, dropdown topic links + navigation, /unread footer link, mobile drawer badge at 390px). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Reviewed-on: https://git.westgate.pw/ShadowsOverWestgate/sow-nodebb-theme/pulls/28 Co-authored-by: vickydotbat Co-committed-by: vickydotbat --- .../plans/2026-07-17-topbar-unread-drawer.md | 346 ++++++++++++++++++ .../2026-07-17-topbar-unread-drawer-design.md | 75 ++++ public/client.js | 69 ++++ scss/westgate/_topbar.scss | 15 +- templates/partials/header/topbar.tpl | 5 + templates/partials/header/unread-drawer.tpl | 9 + tests/global-topbar-contract.test.js | 32 ++ tests/unread-drawer-client.test.js | 24 ++ 8 files changed, 574 insertions(+), 1 deletion(-) create mode 100644 docs/superpowers/plans/2026-07-17-topbar-unread-drawer.md create mode 100644 docs/superpowers/specs/2026-07-17-topbar-unread-drawer-design.md create mode 100644 templates/partials/header/unread-drawer.tpl create mode 100644 tests/unread-drawer-client.test.js diff --git a/docs/superpowers/plans/2026-07-17-topbar-unread-drawer.md b/docs/superpowers/plans/2026-07-17-topbar-unread-drawer.md new file mode 100644 index 0000000..40c3568 --- /dev/null +++ b/docs/superpowers/plans/2026-07-17-topbar-unread-drawer.md @@ -0,0 +1,346 @@ +# Topbar Unread Drawer Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Add an "Unread" dropdown to the topbar utilities (next to notifications) with a live unread-topic count badge and a fetched list of unread topics. + +**Architecture:** A new template partial imported by `topbar.tpl` gives the button + badge (core's `component="unread/count"` socket updates make the badge live for free). A small addition to `public/client.js` fetches `/api/unread` on dropdown open and renders topic links with plain DOM building. SCSS reuses the existing `.wg-topbar__dropdown` vocabulary. + +**Tech Stack:** NodeBB templates (benchpress `.tpl`), jQuery/Bootstrap 5 dropdown events, NodeBB client `api` module, SCSS. Tests are plain-Node assert scripts in `tests/` (run with `node tests/.test.js`). + +## Global Constraints + +- NixOS host: no global installs; run tests with plain `node`. +- One branch, one PR: all commits go on the existing `feat/topbar-unread-drawer` branch. +- Verification against the dev container in `../sow-nodebb` (`make dev`, `make dev-build`), forum at http://localhost:4567. Theme edits need `make dev-build` before they show up. +- Titles from the API must be inserted with `textContent` (never HTML strings) — trust boundary. + +--- + +### Task 1: Unread drawer template + mobile drawer link + +**Files:** +- Create: `templates/partials/header/unread-drawer.tpl` +- Modify: `templates/partials/header/topbar.tpl` (logged-in utility list, before the notifications `
  • `; and the drawer-actions block) +- Test: `tests/global-topbar-contract.test.js` (append assertions) + +**Interfaces:** +- Produces: `
  • ` containing a dropdown toggle and `