NGU-Web/src/components/Banner.tsx
Zaldimmar de17da7dc8 Accessibility: reader view and full palette swaps; version v1.12.1-accessibility
- Reading mode is now a reader view (ReaderView.tsx): the page renders
  hidden and its headings, paragraphs, links and described pictures
  are written out in one column, with no header, backdrop or footer.
- Color blind modes swap all three color families (teal, green,
  amber); palette hexes in components and CSS are now
  var(--pal-<family>-<shade>) so the modes reach them.
- CLAUDE.md and docs/updating-data-in-code.md describe both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 16:10:57 -05:00

63 lines
2 KiB
TypeScript

import { X } from "@phosphor-icons/react";
import { useState, useEffect } from "react";
import { Link } from "react-router-dom";
import { SITE_BANNER } from "../data/bannerConfig.ts";
export default function Banner() {
const [visible, setVisible] = useState(false);
const storageKey = `site-banner-dismissed:${SITE_BANNER.id}`;
useEffect(() => {
if (!SITE_BANNER.enabled) return;
if (!SITE_BANNER.dismissible) return setVisible(true);
try {
if (!localStorage.getItem(storageKey)) setVisible(true);
} catch {
setVisible(true); // storage blocked, show it anyway
}
}, [storageKey]);
const dismiss = () => {
setVisible(false);
try { localStorage.setItem(storageKey, "1"); } catch {}
};
if (!visible) return null;
const linkClass =
"underline underline-offset-4 decoration-[var(--pal-green-2)] hover:text-white transition-colors";
return (
<div
className="relative w-full py-2.5 pr-12 pl-4 text-center sm:px-12"
style={{ background: "rgba(0, 16, 17, 0.95)" }}
role="region"
aria-label="Site announcement"
>
<p className="text-xs text-white/85 sm:text-sm">
{SITE_BANNER.content.map((part, i) => {
if (!part.href) return <span key={i}>{part.text}</span>;
return part.external ? (
<a key={i} href={part.href} target="_blank" rel="noopener noreferrer" className={linkClass}>
{part.text}
</a>
) : (
<Link key={i} to={part.href} className={linkClass}>
{part.text}
</Link>
);
})}
</p>
{SITE_BANNER.dismissible && (
<button
onClick={dismiss}
aria-label="Dismiss announcement"
className="absolute right-1 top-1/2 -translate-y-1/2 p-3 text-white/50 hover:text-white hover:bg-white/10 transition-colors"
>
<X className="w-4 h-4" weight="bold" aria-hidden="true" />
</button>
)}
</div>
);
}