import { ArrowDownRight, ArrowUpRight } from 'lucide-react'; import Link from 'next/link'; import { t } from '@/i18n'; import { cn } from '@/lib/cn'; import { formatValue, grouped } from '@/lib/format'; import { routes } from '@/lib/site'; import type { PulseItem, PulseResponse } from '@/lib/types-analytics'; /** * World Pulse: a dense editorial list of what is changing globally, one row per headline/featured indicator. * Direction uses the neutral increase/decrease colours (--inc/--dec); "improvement" tones apply only when the * indicator declares a direction. Share bar = countries up vs down; right column = biggest mover. */ export function WorldPulse({ data, limit = 14 }: { data: PulseResponse; limit?: number }) { const items = [...data.items].sort((a, b) => Math.max(b.share_up, b.share_down) - Math.max(a.share_up, a.share_down)).slice(0, limit); return (
    {items.map((it) => ( ))}

{t('home.pulse.footnote', { year: data.year_reference, n: grouped(data.summary.n_countries_reporting) })} {t('semantics.note')}

); } function PulseRow({ it }: { it: PulseItem }) { const up = it.share_up >= it.share_down; const Icon = up ? ArrowUpRight : ArrowDownRight; const spec = { format: it.indicator.format, unit: it.indicator.unit, unit_short: it.indicator.unit_short, precision: it.indicator.precision }; const mover = up ? it.top_up : it.top_down; const total = it.n_up + it.n_down + it.n_flat || 1; return (
  • {it.indicator.short_name ?? it.indicator.name}

    {it.headline}

    ↑ {it.n_up} ↓ {it.n_down} {it.record_highs ? · {t('home.pulse.records', { n: it.record_highs })} : null}
    {mover ? ( {up ? t('home.pulse.largestRise') : t('home.pulse.largestFall')} {mover.country.flag} {mover.country.name} {formatValue(mover.value, spec)} ) : null}
  • ); }