add world opinions project
All checks were successful
Test and deploy staging / staging (push) Successful in 1m49s

World map with switchable layers (what "liberal" means, what left vs right
is about, traditional/secular and survival/self-expression values), country
cards, a shared-scale party compass, a values scatter and national
narratives of major events.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-24 16:24:40 +00:00
parent 499dd94cbb
commit afb1f191df
16 changed files with 2338 additions and 2 deletions

View File

@@ -11,6 +11,7 @@
{ name: 'osu! map finder', href: '/projects/spotify-beatmap-finder', external: false },
{ name: 'game tracker', href: '/projects/game-tracker', external: false },
{ name: 'money tracker', href: '/projects/money-tracker', external: false },
{ name: 'world opinions', href: '/projects/world-opinions', external: false },
{ name: 'vash esports', href: 'https://esports.vash.software', external: true },
{ name: 'beerio kart', href: 'https://beeriokart.stanrunge.dev', external: true }
] as const;

View File

@@ -0,0 +1,118 @@
<script lang="ts">
import './world-opinions.css';
import CountryPanel from '$lib/world-opinions/CountryPanel.svelte';
import CultureMap from '$lib/world-opinions/CultureMap.svelte';
import PartyCompass from '$lib/world-opinions/PartyCompass.svelte';
import WorldMap, { type MapMode } from '$lib/world-opinions/WorldMap.svelte';
import { countries, countryById, narratives, sources } from '$lib/world-opinions/data';
const modes: { id: MapMode; label: string }[] = [
{ id: 'liberal', label: 'what "liberal" means' },
{ id: 'divide', label: 'what left vs right is about' },
{ id: 'tradition', label: 'traditional ↔ secular' },
{ id: 'expression', label: 'survival ↔ self-expression' }
];
const sorted = [...countries].sort((a, b) => a.name.localeCompare(b.name));
let mode = $state<MapMode>('liberal');
let countryId = $state('us');
let eventIndex = $state(0);
let narrative = $derived(narratives[eventIndex]);
function select(id: string) {
countryId = id;
document.getElementById('country')?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}
</script>
<div class="wo mx-auto max-w-6xl px-4 py-12 sm:px-6 sm:py-16">
<header class="mb-8">
<h1 class="mb-3 text-4xl font-semibold tracking-tight sm:text-5xl">world opinions</h1>
<p class="text-lg text-[var(--site-muted)]">
Same words, different politics. Hover the map, click a country.
</p>
</header>
<section aria-label="World map">
<div class="mb-4 flex flex-wrap gap-2" role="tablist" aria-label="Map layer">
{#each modes as item (item.id)}
<button
class="wo-chip"
role="tab"
aria-selected={mode === item.id}
onclick={() => (mode = item.id)}>{item.label}</button
>
{/each}
</div>
<WorldMap {mode} selected={countryId} onselect={select} />
</section>
<section id="country" class="scroll-mt-20 pt-10" aria-label="Country">
<label class="mb-3 block max-w-xs text-sm">
<span class="sr-only">Country</span>
<select
bind:value={countryId}
class="w-full rounded-md border border-[var(--site-border)] bg-[var(--site-surface)] px-3 py-2"
>
{#each sorted as country (country.id)}
<option value={country.id}>{country.name}</option>
{/each}
</select>
</label>
<CountryPanel id={countryId} />
</section>
<section class="border-t border-[var(--site-border)] mt-12 py-10">
<h2 class="mb-1 text-2xl font-semibold">party compass</h2>
<p class="mb-5 text-[var(--site-muted)]">Every party on one shared scale.</p>
<PartyCompass focus={countryId} />
</section>
<section class="border-t border-[var(--site-border)] py-10">
<h2 class="mb-1 text-2xl font-semibold">values map</h2>
<p class="mb-5 text-[var(--site-muted)]">Both value axes at once.</p>
<CultureMap selected={countryId} onselect={select} />
</section>
<section class="border-t border-[var(--site-border)] py-10">
<h2 class="mb-4 text-2xl font-semibold">one event, many stories</h2>
<div class="mb-5 flex flex-wrap gap-2" role="tablist" aria-label="Event">
{#each narratives as item, index (item.event)}
<button
class="wo-chip"
role="tab"
aria-selected={eventIndex === index}
onclick={() => (eventIndex = index)}
>{item.event.toLowerCase()} <span class="opacity-60">{item.years}</span></button
>
{/each}
</div>
<div role="tabpanel">
<ul class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
{#each narrative.views as view (view.country)}
<li>
<button class="wo-card wo-quote w-full text-left" onclick={() => select(view.country)}>
<span class="text-sm text-[var(--site-muted)]"
>{countryById.get(view.country)?.name}</span
>
<span class="block text-lg">“{view.story}”</span>
</button>
</li>
{/each}
</ul>
</div>
</section>
<footer class="border-t border-[var(--site-border)] pt-6 text-sm text-[var(--site-muted)]">
<p class="mb-2">Approximate, hand-placed positions for comparison. Based on:</p>
<p class="flex flex-wrap gap-x-4 gap-y-1">
{#each sources as source (source.href)}
<a
class="underline underline-offset-2 hover:text-[var(--site-text)]"
href={source.href}
rel="external">{source.name}</a
>
{/each}
</p>
</footer>
</div>

View File

@@ -0,0 +1,302 @@
.wo {
--wo-s1: #3987e5;
--wo-s2: #d95926;
--wo-s3: #199e70;
--wo-dot: #6b6b68;
--wo-dot-dim: #3a3a38;
--wo-grid: #1c1c1b;
--wo-axis: #3a3a38;
}
:root[data-theme='light'] .wo {
--wo-s1: #2a78d6;
--wo-s2: #eb6834;
--wo-s3: #1baf7a;
--wo-dot: #9a9994;
--wo-dot-dim: #dcdbd6;
--wo-grid: #f0efec;
--wo-axis: #cfcec9;
}
.wo-chip {
display: inline-flex;
align-items: center;
gap: 0.4rem;
border: 1px solid var(--site-border);
border-radius: 999px;
padding: 0.3rem 0.8rem;
font-size: 0.875rem;
color: var(--site-muted);
}
.wo-chip:hover:not(:disabled) {
background: var(--site-hover);
color: var(--site-text);
}
.wo-chip[aria-pressed='true'],
.wo-chip[aria-selected='true'] {
border-color: var(--site-text);
color: var(--site-text);
}
.wo-chip:disabled {
opacity: 0.4;
cursor: not-allowed;
}
.wo-swatch {
display: inline-block;
width: 0.65rem;
height: 0.65rem;
border-radius: 999px;
}
.wo-link {
font-size: 0.875rem;
color: var(--site-muted);
text-decoration: underline;
text-underline-offset: 3px;
}
.wo-link:hover {
color: var(--site-text);
}
.wo-chart svg text {
font-family: inherit;
}
.wo-grid {
stroke: var(--wo-grid);
stroke-width: 1;
}
.wo-axis {
stroke: var(--wo-axis);
stroke-width: 1;
}
.wo-axis-label {
fill: var(--site-muted);
font-size: 12px;
}
.wo-label {
fill: var(--site-muted);
font-size: 11px;
}
.wo-label-strong {
fill: var(--site-text);
font-size: 12px;
font-weight: 600;
}
.wo-dot {
fill: var(--wo-dot);
stroke: var(--site-bg);
stroke-width: 2;
}
.wo-dot-dim {
fill: var(--wo-dot-dim);
stroke: var(--site-bg);
stroke-width: 2;
}
.wo-dot-active {
fill: var(--wo-s1);
stroke: var(--site-bg);
stroke-width: 2;
}
.wo-ring {
stroke: var(--site-bg);
stroke-width: 2;
}
.wo-chart g:focus-visible circle:last-of-type {
stroke: var(--site-text);
}
.wo-tooltip {
position: absolute;
transform: translate(-50%, calc(-100% - 14px));
display: flex;
flex-direction: column;
gap: 0.1rem;
pointer-events: none;
border: 1px solid var(--site-border);
border-radius: 0.5rem;
background: var(--site-surface);
padding: 0.5rem 0.7rem;
font-size: 0.8rem;
color: var(--site-muted);
white-space: nowrap;
z-index: 10;
}
.wo-tooltip strong {
color: var(--site-text);
}
.wo-tooltip .max-w-64 {
white-space: normal;
width: 16rem;
}
.wo-table {
width: 100%;
font-size: 0.875rem;
border-collapse: collapse;
}
.wo-table th,
.wo-table td {
border-top: 1px solid var(--site-border);
padding: 0.4rem 0.5rem 0.4rem 0;
text-align: left;
}
.wo-table th {
color: var(--site-muted);
font-weight: 500;
}
.wo-card {
border: 1px solid var(--site-border);
border-radius: 0.75rem;
background: var(--site-surface);
padding: 1rem 1.1rem;
}
.wo {
--wo-pos: #3987e5;
--wo-neg: #d95926;
--wo-mid: #4a4a47;
--wo-none: #7a7a76;
--wo-nodata: #161615;
}
:root[data-theme='light'] .wo {
--wo-pos: #2a78d6;
--wo-neg: #eb6834;
--wo-mid: #d9d8d3;
--wo-none: #a3a29c;
--wo-nodata: #f1f1ef;
}
.wo-country {
stroke: var(--site-bg);
stroke-width: 0.5;
transition: opacity 120ms;
}
.wo-country-hover {
stroke: var(--site-text);
stroke-width: 1;
}
.wo-country-selected {
fill: none;
stroke: var(--site-text);
stroke-width: 1.75;
pointer-events: none;
}
.wo-tooltip-note {
margin-top: 0.2rem;
width: 15rem;
white-space: normal;
}
.wo-gradient {
display: inline-block;
width: 9rem;
height: 0.6rem;
border-radius: 999px;
background: linear-gradient(to right, var(--wo-neg), var(--wo-mid), var(--wo-pos));
}
.wo-swatch-nodata {
background: var(--wo-nodata);
outline: 1px solid var(--site-border);
}
.wo-gauge {
position: relative;
height: 0.5rem;
border-radius: 999px;
background: linear-gradient(to right, var(--wo-neg), var(--wo-mid), var(--wo-pos));
}
.wo-gauge-marker {
position: absolute;
top: 50%;
width: 1rem;
height: 1rem;
border-radius: 999px;
transform: translate(-50%, -50%);
background: var(--site-text);
border: 3px solid var(--site-surface);
transition: left 300ms ease;
}
.wo-tag {
display: inline-flex;
align-items: center;
gap: 0.4rem;
border-radius: 999px;
background: var(--site-hover);
padding: 0.2rem 0.7rem;
font-size: 0.875rem;
}
.wo-tag-dashed {
background: transparent;
border: 1px dashed var(--site-border);
color: var(--site-muted);
}
.wo-timeline {
display: grid;
grid-auto-flow: column;
grid-auto-columns: minmax(0, 1fr);
position: relative;
}
.wo-timeline::before {
content: '';
position: absolute;
left: 0;
right: 0;
top: 1.85rem;
border-top: 1px solid var(--site-border);
}
.wo-timeline li {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
gap: 0.35rem;
padding: 0 0.25rem;
}
.wo-timeline-year {
font-weight: 600;
font-variant-numeric: tabular-nums;
}
.wo-timeline-dot {
position: relative;
width: 0.6rem;
height: 0.6rem;
border-radius: 999px;
background: var(--site-text);
}
.wo-timeline-label {
font-size: 0.8rem;
color: var(--site-muted);
}
@media (max-width: 640px) {
.wo-timeline {
grid-auto-flow: row;
gap: 0.6rem;
}
.wo-timeline::before {
display: none;
}
.wo-timeline li {
flex-direction: row;
text-align: left;
}
.wo-timeline-year {
width: 3.2rem;
}
}
.wo-quote:hover {
background: var(--site-hover);
}
.wo-tag-label {
display: inline-flex;
align-items: center;
gap: 0.35rem;
margin-right: 0.25rem;
font-size: 0.8rem;
color: var(--site-muted);
}