Skip to content

Improve announcements UI - #784

Merged
gaidheal1 merged 4 commits into
developmentfrom
refactor/navbar-announcements-component
Aug 14, 2026
Merged

Improve announcements UI#784
gaidheal1 merged 4 commits into
developmentfrom
refactor/navbar-announcements-component

Conversation

@gaidheal1

@gaidheal1 gaidheal1 commented Aug 14, 2026

Copy link
Copy Markdown
Member

Summary

  • Extracts the desktop popover and mobile dropdown-panel announcement UI out of Navbar.tsx into a new Navbar/Announcements.tsx (AnnouncementsBell, MobileAnnouncements), sharing one internal list-rendering component instead of duplicating the accordion markup twice.
  • Navbar.tsx keeps ownership of the data layer (useAnnouncements, mutations, unread-count sync) and passes it down as props — no duplicated queries/mutations.
  • Styles split out into Announcements.module.scss; Navbar.module.scss shrinks by ~155 lines.
  • Fixes the announcements bell rendering visibly taller than the other nav buttons — it hard-coded a 2.4rem box instead of deriving its height from padding + line-height like its siblings.
  • Renders announcement body as Markdown (react-markdown) instead of plain text.

UX polish

  • Hover effect on list items.
  • "Mark read" is hidden while an item is collapsed, shown only once expanded.
  • Collapsed items show a rotating chevron affordance (points down at rest, rotates to point up when expanded).
  • Removed a stray green focus ring on announcement titles/summaries — no custom focus style, falls back to the site-wide :focus-visible outline.
  • "Mark all read" is hidden entirely (not just disabled) when there are no unread items.
  • Summary text hides once an item is expanded, since the full body is then redundant with it.
  • Backend: Announcement.save() now auto-sets published_at the first time an announcement is saved as published, if it isn't already set (idempotent — won't overwrite an existing value).
  • Frontend: announcement items now display their published date/time (formatPublishedAt, following the existing formatDueAt convention).
  • Django admin: published_at becomes read-only once set, via AnnouncementAdmin.get_readonly_fields — still editable while unset or on a new unsaved announcement.
  • Reduced font sizes throughout the announcements UI (title, header, summary, published date, body text, action buttons) for a more compact list, and fixed a pre-existing bug where .body's font-size was never actually applied to the rendered markdown <p>/<li> elements (a global bare p { } rule was winning over the inherited container size).

Known issue

Testing

  • npx eslint on changed files: clean
  • npx tsc --noEmit: clean
  • npx vitest run src/layout/Navbar/Navbar.test.tsx: 12/12 passing
  • Backend core/tests.py additions (AnnouncementSaveTest, AnnouncementAdminReadonlyFieldsTest) cover the published_at auto-set and admin read-only behavior — not yet run against Docker in this session.

🤖 Generated with Claude Code

gaidheal1 and others added 4 commits August 14, 2026 12:40
Splits the desktop popover and mobile dropdown-panel announcement
markup out of Navbar.tsx into a new Announcements.tsx (AnnouncementsBell,
MobileAnnouncements), sharing one internal list-rendering component
instead of duplicating the accordion markup. Navbar keeps ownership of
the data layer (queries/mutations) and passes it down as props.

Also fixes the announcements bell rendering taller than the other nav
buttons: it hard-coded a 2.4rem box instead of deriving its height from
padding + line-height like its siblings.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Announcement.body is authored free-form in the Django admin; render it
through react-markdown instead of a plain <p> so staff can use bold,
links, and lists. react-markdown converts markdown to React elements
directly (no dangerouslySetInnerHTML), so no sanitizer is needed.

- Announcements.tsx: swap the body <p> for <ReactMarkdown>
- Announcements.module.scss: style the elements markdown can produce
  (p/ul/ol/li/a/code) instead of a single bare <p>
- core/models.py: note Markdown support in the body field's help_text
  (migration 0017, help_text-only)
- Navbar.stories.tsx / Navbar.test.tsx: cover markdown rendering

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Hover effect on announcement items
- Hide "Mark read" while collapsed (was always visible)
- Hide "Mark all read" entirely when there are no unread items
- Replace the (unused) rotating chevron affordance's earlier text hint
  with a CSS-drawn arrow, scoped to each item's own data-state so it no
  longer picks up the popover's data-state="open" instead
- Remove the accordion trigger's green focus-visible outline; falls
  back to the site-wide default
- Hide the summary once an item is expanded (redundant with the body)
- Announcement.save() now sets published_at automatically the first
  time an announcement is published, if not already set
- AnnouncementAdmin makes published_at read-only once set
- Frontend displays each announcement's published date/time
@gaidheal1 gaidheal1 changed the title refactor: extract announcements UI out of Navbar into own component refactor: extract announcements UI out of Navbar into own component + UX polish Aug 14, 2026
@gaidheal1 gaidheal1 changed the title refactor: extract announcements UI out of Navbar into own component + UX polish Improve announcements UI Aug 14, 2026
@gaidheal1
gaidheal1 merged commit f35e7bf into development Aug 14, 2026
2 checks passed
@gaidheal1
gaidheal1 deleted the refactor/navbar-announcements-component branch August 14, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant