import { DollarSign, Flame, FlaskConical, Handshake, Landmark, Palette, Radar, Swords, Users, type LucideIcon, } from 'lucide-react'; import { Badge } from './ui/badge'; import { ScrollArea } from './ui/scroll-area'; import { EVENT_COLORS, OUTCOME_COLORS } from '@/lib/colors'; import { nationColor } from '@shared/protocol'; import type { EventEntry, EventType, Nation } from '@shared/types'; /** One icon per event category, so a type is readable without reading. */ const EVENT_ICONS: Record = { military: Swords, diplomatic: Handshake, economic: DollarSign, political: Landmark, social: Users, disaster: Flame, scientific: FlaskConical, cultural: Palette, }; interface Props { events: EventEntry[]; nations: Record; /** * Render without the outer chrome and the built-in header (the surrounding * floating window provides the border, the "Event feed" title, and the count * badge). Same content, same testids. */ inWindow?: boolean; } /** * A scrolling event log, newest first. Each event is a card with a category * icon, a color-coded outcome badge, a nation-colored accent edge, and the turn * + date it resolved on. New events slide in and flash briefly at the top. */ export default function EventFeed({ events, nations, inWindow = false }: Props) { const latestFirst = [...events].reverse(); const header = inWindow ? null : (

Event feed

{events.length}
); return (
{header}
{latestFirst.length === 0 && (
No events yet. Take an action, send a message, or jump forward to move the world.
)} {latestFirst.map((e) => { const nation = nations[e.nation]; // Accent edge uses the nation's stable choropleth color (falls back to // the type color if the nation is missing — never crashes). const accent = nation ? nationColor(e.nation) : EVENT_COLORS[e.type] ?? '#94a3b8'; const typeColor = EVENT_COLORS[e.type] ?? '#94a3b8'; const outcomeColor = OUTCOME_COLORS[e.outcome] ?? '#94a3b8'; const Icon = EVENT_ICONS[e.type] ?? Landmark; return (
T{e.turn} · {e.date} {e.type}

{e.title}

{e.text}

{nation?.name ?? e.nation} {e.outcome}
); })}
); }