Skip to content
SprecherEast
Issue 814

feat: Closable information banner with an end date, for upcoming meetings

Back to our plan
Done
enhancementfrontendcmsuxpriority: high

Numbering: epic #813; banner #814; lightbox #815; figure #816; Payload block #817; blue tone #818; content edit #819; guidelines #820. Where the text below says 01 to 07, read these numbers (01=#815, 02=#816, 03=#817, 04=#819, 05=#814, 06=#818, 07=#820).

Problem

In plain words: we want a short notice at the top of the I-94 post (and of the event page) saying the related WisDOT virtual public meeting is on Tue 2026-11-10 at 5:30 PM Central. Visitors should be able to close it, and once closed it shouldn't come back on every visit. It should also go away by itself after the meeting. Today's banner block (BannerBlock → Alert, live={false}) can't be closed and has no end date. Event content can't hold a banner at all: EVENT_RICH_TEXT_BLOCKS in src/platform/richtext/blockConfigs.ts offers only mediaBlock and the editorial blocks.

Summary of the owner's request (2026-11-07, Claude in Chrome side panel): an information banner at the top of the content about the upcoming meeting, a bit different from other banners (a blue information look), with a close button, shown once rather than on every page load. He wasn't sure which tones the site has. It has four: info (gray today), success, warning and error (AlertTone in src/platform/ui/Alert.tsx). The blue look is 06.

What can ship first

  • Now, no code (interim): in Admin, an editor places the existing Banner block, style Info, as the first block of the post's body. The text: "WisDOT holds a virtual public meeting on this project on Tue, Nov 10 at 5:30 PM Central." plus a link to the event page. It is gray and can't be closed, and it must be removed by hand after the meeting. First note the post's current version on this issue so it can be restored. The event page can't take it until this issue ships.
  • This issue: closable, with an end date, also on events.
  • Then 06: the blue tone. No content change needed.

Proposed fix

Narrowest option: [DECISION] a sub-issue that #758 builds on, not part of #758. #758 adds a site-wide variant controlled from the CMS, which is a bigger design (a global, placement in the layout, urgency). The deadline needs only the in-article banner to close and expire. #758 then reuses the same closable behavior for its site-wide variant.

  1. Banner block fields (Banner in src/platform/richtext/blockConfigs.ts), added, all optional, so every stored banner keeps working:

    • dismissible (checkbox, default off): shows a close button.
    • showUntil (date and time, site timezone): after it the banner isn't shown. Admin description: "For a meeting, set the meeting's start time."
    • A migration adds the two columns (npx payload migrate:create), then npm run generate:types.
  2. Events may hold a banner: add Banner to EVENT_RICH_TEXT_BLOCKS, and update its comment ("no banner or code" becomes "no code"). Check the live database first for anything that depends on events having no banner (none expected).

  3. Rendering (src/platform/richtext/BannerBlock.tsx):

    • On the server, a banner whose showUntil has passed renders nothing. The check is a pure function in src/platform/lib/ using SITE_TIMEZONE helpers from src/platform/lib/timezone.ts. Pages re-render every 10 minutes (revalidate = 600 on the event and post pages), so it disappears within 10 minutes of the end time.
    • A dismissible banner is wrapped in a small client component, Dismissible (working name), in src/platform/ui/. It holds the close control: the kit's Button (variant="ghost" size="icon"), lucide X with aria-hidden, and aria-label="Close this notice". It hides the banner and remembers that. On the client it also re-checks showUntil, so a cached page doesn't show an expired notice.
    • Focus after closing moves to the start of the article content (the element after the banner), so keyboard users aren't left on a removed element.
  4. [DECISION] How "shown once" works: localStorage.

    OptionKeeps it closed across visitsWorks on cached (ISR) pagesLayout shift (CLS)
    sessionStorageonly within the tab; a new visit shows it again, which isn't what was askedyes (client only)a shift on load for visitors who closed it in this tab
    localStorageyes, on that browseryes (client only)the same shift, only for visitors who already closed it
    Cookie read on the serveryesno: reading cookies makes the page dynamic and drops the 10-minute static cache (revalidate = 600) for every visitornone
    Cookie read on the clientyesyessame as localStorage, plus a request header on every request for no gain
    • Choice: localStorage, key sprecher-east:dismissed-banners, holding the ids of the closed banners (the Lexical block's id) and nothing else: no personal data. It is a strictly functional preference, so no consent banner is needed. It isn't a token, so the security rule against tokens in localStorage doesn't apply.
    • Wrap every read and write in try/catch, as InitTheme.tsx does, so a private window or blocked storage simply shows the banner.
    • Default without scripting, or if storage fails: the banner shows. It never hides content.
    • CLS: the server HTML always contains the banner, so first-time visitors see no shift. Only a visitor who already closed it sees it collapse on hydration. Hide it in a layout effect (before paint where React allows) and measure CLS on the event page in the e2e run. If the shift is visible, the follow-up is a pre-paint check like InitTheme's (a [SCOPE] issue, not this PR).
  5. #758 comment draft:

    [STEP] Closable in-article banner lands first

    Epic 00's sub-issue 05 adds two optional fields to the existing banner block: dismissible (a close button, remembered in localStorage on that browser) and showUntil (hidden after a date and time). It also lets event content hold a banner. It was needed for the WisDOT meeting on 2026-11-10 (owner's request, 2026-11-07, Claude in Chrome side panel). #758's site-wide variant should reuse the same Dismissible wrapper and showUntil rule rather than build its own. Its tone names follow #769, and the blue information tone is 06 under the same epic. #758 isn't parented under epic 00; it stays unscheduled.

Native-first check:

  • (1) Payload: optional checkbox and date fields on the existing block are native config.
  • (1) React and Next: there is no built-in "dismiss and remember". Next's cookies() would make the ISR pages dynamic (see the table).
  • (1) Radix: we have no @radix-ui/react-toast here, and a toast is the wrong pattern for page content anyway.
  • (3) Open source: dismissible-banner libraries bring their own markup and styles. The behavior is one button and one storage key on top of our Alert.
  • Conclusion: configure the block, plus a small shared client wrapper.

Acceptance criteria

  • Not done: Tests come first: failing tests for the showUntil rule (before, at and after the time, in the site timezone, day-boundary safe), for Dismissible (the close button has the label and hides the banner; the closed id is stored; a stored id hides it on the next render; storage that throws still shows it; focus moves on), and for BannerBlock (expired renders nothing; not dismissible has no button), then the code.
  • Not done: Stored banners without the new fields render exactly as before (test with a fixture of today's shape).
  • Not done: The migration adds two nullable columns only, is reviewed for data safety, and src/payload-types.ts and docs/reference/content-types/ are regenerated.
  • Not done: An editor can add a banner to an event's content in Admin and set Close button and Show until.
  • Not done: Without scripting the banner shows, with no close button (the scripted: variant), and nothing is hidden.
  • Not done: An axe check passes, open and after closing. The close button is a kit Button with an accessible name, and the icon has aria-hidden. The tone isn't told by color alone (icon and words).
  • Not done: Keyboard: Tab reaches the close button, Enter or Space closes it, and focus moves to the content after it.
  • Not done: CLS on the event page is measured in e2e for a visitor who already closed the banner, and the number is recorded on the PR.
  • Not done: A gallery entry shows the dismissible banner, and docs/ui/component-set.md has a row for Dismissible. The Alert/banner row mentions the close button and end date.
  • Not done: Checked at 320, 430, 768, 1024, 1280 and 1920 px in light and dark.
  • Not done: Documentation follows behavior: docs/ui/data-types.md's banner row lists the new fields, docs/guidelines/payload-cms.md's block list is still accurate, and the events note src/modules/events/README.md says event content can hold a banner.
  • Not done: #758 has the comment above.
  • Not done: After merge: the banner is placed at the top of the I-94 post and event 12 (each document's version noted first), with showUntil = 2026-11-10 17:30 Central, closable, and checked live. The interim banner, if it was used, is replaced.

Files likely touched

  • src/platform/richtext/blockConfigs.ts, src/platform/richtext/BannerBlock.tsx (+ tests)
  • new src/platform/ui/Dismissible.client.tsx (+ test), new rule in src/platform/lib/ (+ test)
  • src/migrations/, src/payload-types.ts
  • src/app/(frontend)/dev/gallery/LayoutGallery.tsx
  • e2e/ (a CLS and close check on a seeded event)
  • docs/ui/component-set.md, docs/ui/data-types.md, src/modules/events/README.md, docs/reference/ (generated)

Must not touch

  • src/platform/ui/Alert.tsx tone classes, src/platform/theme/tokens.ts, src/themes/ (06)
  • src/app/(frontend)/layout.tsx, header and footer (site-wide is #758)
  • The figure files (01–03)

Area

frontend, cms, ux

Priority

priority: high


Generated by Claude Code, opens in a new tab

See it on GitHub, opens in a new tab