Skip to content

Add announcements collection with banners and popups#1078

Draft
busbyk wants to merge 9 commits into
mainfrom
feat/announcements-collection
Draft

Add announcements collection with banners and popups#1078
busbyk wants to merge 9 commits into
mainfrom
feat/announcements-collection

Conversation

@busbyk
Copy link
Copy Markdown
Collaborator

@busbyk busbyk commented May 13, 2026

Awaiting feedback, hold review.


Description

Adds a new Announcements collection supporting two display types: banners (collapsible bar at the top of the page) and popups (modal dialog with configurable display frequency).

Related Issues

Closes #82

Key Changes

  • New announcements collection with fields for type (banner/popup), display frequency, page scope, device targeting, and date range scheduling
  • Banner component — collapsible announcement bar with auto-expand for unseen banners, localStorage-based seen tracking, and animated height transitions
  • Popup component — modal dialog with configurable display frequency (once, every visit, every N visits), page scope (all pages or homepage only), and device targeting
  • "Don't show this again" button on popups — absolutely positioned in the dialog padding for a subtle, non-intrusive dismiss that permanently suppresses the popup
  • Seed data with sample banner, popup, and expired banner announcements for DVAC and NWAC (figured we might not want this for all tenants)
  • Cache revalidation via announcements-${tenant.slug} tag on document change/delete

How to test

  1. Run pnpm seed to populate test announcements
  2. Visit nwac.localhost:3000 — a banner should appear at the top, and a popup should show after 1 second
  3. Collapse/expand the banner using the buttons
  4. Dismiss the popup via the X button or "Don't show this again"
  5. Reload to verify "Don't show this again" permanently suppresses the popup
  6. Visit /blog to confirm the homepage-only popup does not appear there
  7. Check the admin panel at /admin/collections/announcements to manage announcements

Screenshots / Demo video

TBD

Migration Explanation

New collection only — no destructive changes. Migration adds the announcements table and related index/relationship tables.

Future enhancements / Questions

  • Consider adding analytics tracking for popup impressions and dismissals
  • Could add more granular page targeting beyond homepage-only vs all pages

busbyk and others added 5 commits May 13, 2026 11:13
Introduces a multi-tenant announcements system with time-windowed scheduling,
configurable display frequency for popups, and client-side banner collapse state.
Includes seed data, revalidation hooks, cached query, and unit tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests banner visibility, collapse/expand, expiry filtering, cross-page
rendering, popup display with homepage-only scope, and popup dismissal.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Removes the dedicated CTA group field from announcements — buttons are
now added via the ButtonBlock already available in the rich text editor.
Adds click-to-close on popup links, overrides banner button styling to
respect callout theme colors, and tightens banner layout spacing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add SponsorsBlock to announcement content editor blocks
- Add "Don't show this again" button to popup announcements
- Improve banner divider visibility with callout-foreground color
- Check dismissed state for all display frequencies, not just 'once'

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Migration Safety Check

Found 4 potential issues:

20260513_201340_announcements.ts

Warning (line 22): DELETE keyword detected - review for data loss

FOREIGN KEY (\`tenant_id\`) REFERENCES \`tenants\`(\`id\`) ON UPDATE no action ON DELETE set null

Warning (line 54): DELETE keyword detected - review for data loss

FOREIGN KEY (\`parent_id\`) REFERENCES \`announcements\`(\`id\`) ON UPDATE no action ON DELETE set null,

Warning (line 55): DELETE keyword detected - review for data loss

FOREIGN KEY (\`version_tenant_id\`) REFERENCES \`tenants\`(\`id\`) ON UPDATE no action ON DELETE set null

Warning (line 83): ALTER keyword detected - review for data loss

sql`ALTER TABLE \`payload_locked_documents_rels\` ADD \`announcements_id\` integer REFERENCES announcements(id);`,

Review these patterns and add backup/restore logic if needed. See docs/migration-safety.md for guidance.

@github-actions
Copy link
Copy Markdown
Contributor

- Only show one popup at a time (most recently published)
- Fix collapsed banner expand button hidden behind mobile header
- Change "every visit" popup to once per browser session via sessionStorage
- Prevent auto-focus on "Don't show this again" button when dialog opens
- Rename "Every visit" to "Once per visit" in admin UI

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
busbyk and others added 2 commits May 20, 2026 11:13
Lifts banner collapsed/expanded state into a context provider so the
mobile nav can show a megaphone toggle button and the desktop expand
button is hidden on mobile. Header is now a child of Announcements
to share provider context.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Announcements

1 participant