6 Commits

Author SHA1 Message Date
haerikimmm
500ad347ee changed the collapsible panel to top centered layout with consistent ui style 2026-06-15 17:15:51 +09:00
haerikimmm
4c219abab4 changed to centered layout 2026-06-15 16:43:32 +09:00
haerikimmm
6cee6095ed added sharable stats 2026-06-15 10:20:55 +09:00
Haeri Kim
8422c6e34f changed app name, added new journal entry from map and timeline 2026-06-14 10:59:59 +09:00
Haeri Kim
cdf3643622 added edit page and revised edit form 2026-06-14 10:47:21 +09:00
Haeri Kim
aadc80b7a8 added firebase & changed main tab color, uyear stand out 2026-06-14 10:24:45 +09:00
25 changed files with 3205 additions and 1295 deletions

View File

@@ -3,6 +3,7 @@
"configurations": [ "configurations": [
{ {
"name": "Map-Jurnal", "name": "Map-Jurnal",
"cwd": "/Users/haerikim/Desktop/SP Map Journal/Map-Jurnal",
"runtimeExecutable": "npm", "runtimeExecutable": "npm",
"runtimeArgs": ["run", "dev"], "runtimeArgs": ["run", "dev"],
"port": 5173, "port": 5173,

6
.env Normal file
View File

@@ -0,0 +1,6 @@
VITE_FIREBASE_API_KEY=AIzaSyC_hZf9TpIIb4H7y7umUeYtFKD-guN_iR0
VITE_FIREBASE_AUTH_DOMAIN=map-jurnal.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=map-jurnal
VITE_FIREBASE_STORAGE_BUCKET=map-jurnal.firebasestorage.app
VITE_FIREBASE_MESSAGING_SENDER_ID=922587077950
VITE_FIREBASE_APP_ID=1:922587077950:web:9f140f84468e306152606f

View File

@@ -4,7 +4,7 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>map-journal</title> <title>Journi</title>
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

1354
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -9,13 +9,14 @@
"preview": "vite preview" "preview": "vite preview"
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/vite-plugin-svelte": "^7.1.2", "@sveltejs/vite-plugin-svelte": "^5.0.3",
"svelte": "^5.55.5", "svelte": "^5.55.5",
"vite": "^8.0.12" "vite": "^6.3.5"
}, },
"dependencies": { "dependencies": {
"d3": "^7.9.0", "d3": "^7.9.0",
"flag-icons": "^7.5.0", "flag-icons": "^7.5.0",
"html-to-image": "^1.11.13",
"topojson-client": "^3.1.0", "topojson-client": "^3.1.0",
"world-atlas": "^2.0.2" "world-atlas": "^2.0.2"
} }

View File

@@ -5,18 +5,29 @@
import TimelineView from './lib/timeline/TimelineView.svelte'; import TimelineView from './lib/timeline/TimelineView.svelte';
let screen = $state('worldmap'); let screen = $state('worldmap');
let inDetail = $state(false);
let pendingCountry = $state('');
function handleCountryClick(name) {
pendingCountry = name;
screen = 'timeline';
}
</script> </script>
<Layout {screen} onNavigate={(s) => (screen = s)}> <Layout {screen} onNavigate={(s) => (screen = s)} hideTopBar={inDetail}>
{#if screen === 'worldmap'} {#if screen === 'worldmap'}
<div class="worldmap-page"> <div class="worldmap-page">
<div class="map-area"> <div class="map-area">
<WorldMap /> <WorldMap onCountryClick={handleCountryClick} />
</div> </div>
<StatsPanel /> <StatsPanel />
</div> </div>
{:else} {:else}
<TimelineView /> <TimelineView
onDetailChange={(v) => (inDetail = v)}
{pendingCountry}
onNewEntryClear={() => (pendingCountry = '')}
/>
{/if} {/if}
</Layout> </Layout>
@@ -27,6 +38,7 @@
flex-direction: row; flex-direction: row;
min-width: 0; min-width: 0;
height: 100%; height: 100%;
position: relative;
} }
.map-area { .map-area {

View File

@@ -1,4 +1,4 @@
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,200;12..96,300;12..96,400&display=swap'); @import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,300;12..96,400;12..96,500&display=swap');
/* ── Color tokens ─────────────────────────────────────────── */ /* ── Color tokens ─────────────────────────────────────────── */
:root { :root {

View File

@@ -1,16 +1,16 @@
<script> <script>
import TopBar from './TopBar.svelte'; import TopBar from './TopBar.svelte';
import Footer from './Footer.svelte';
let { screen, onNavigate, children } = $props(); let { screen, onNavigate, hideTopBar = false, children } = $props();
</script> </script>
<div class="layout"> <div class="layout" class:no-topbar={hideTopBar}>
<TopBar {screen} {onNavigate} /> {#if !hideTopBar}
<TopBar {screen} {onNavigate} />
{/if}
<main class="main"> <main class="main">
{@render children()} {@render children()}
</main> </main>
<Footer />
</div> </div>
<style> <style>
@@ -18,9 +18,12 @@
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
display: grid; display: grid;
grid-template-rows: auto 1fr auto; grid-template-rows: auto 1fr;
overflow: hidden; overflow: hidden;
} }
.layout.no-topbar {
grid-template-rows: 1fr;
}
.main { .main {
overflow: hidden; overflow: hidden;

View File

@@ -3,7 +3,9 @@
</script> </script>
<nav class="topbar"> <nav class="topbar">
<span class="logo">Map Journal</span> <div class="logo-area">
<span class="logo">Journi</span>
</div>
<div class="nav-links"> <div class="nav-links">
<button class="nav-btn" class:active={screen === 'worldmap'} onclick={() => onNavigate('worldmap')}>Map</button> <button class="nav-btn" class:active={screen === 'worldmap'} onclick={() => onNavigate('worldmap')}>Map</button>
<button class="nav-btn" class:active={screen === 'timeline'} onclick={() => onNavigate('timeline')}>Journal</button> <button class="nav-btn" class:active={screen === 'timeline'} onclick={() => onNavigate('timeline')}>Journal</button>
@@ -23,12 +25,18 @@
z-index: 10; z-index: 10;
} }
.logo-area {
display: flex;
align-items: center;
gap: 8px;
}
.logo { .logo {
font-family: var(--heading); font-family: var(--heading);
font-size: 14px; font-size: 22px;
font-weight: 400; font-weight: 600;
color: var(--text-h); color: var(--text-h);
letter-spacing: 0.01em; letter-spacing: -0.5px;
} }
.nav-links { .nav-links {
@@ -58,8 +66,8 @@
} }
.nav-btn:hover { color: var(--text-h); } .nav-btn:hover { color: var(--text-h); }
.nav-btn.active { .nav-btn.active {
background: var(--bg); background: #7c3aed;
color: var(--text-h); color: #fff;
box-shadow: 0 1px 4px rgba(0,0,0,0.08); box-shadow: 0 1px 4px rgba(124,58,237,0.25);
} }
</style> </style>

View File

@@ -0,0 +1,128 @@
<script>
/**
* Searchable combobox input.
* @type {{ id?: string, value: string, options: string[], placeholder?: string, required?: boolean, onchange?: (v: string) => void }}
*/
let { id, value = $bindable(), options, placeholder = '', required = false, onselect } = $props();
let query = $state(value);
let open = $state(false);
let focused = $state(-1);
let filtered = $derived(
query.trim() === ''
? options
: options.filter(o => o.toLowerCase().includes(query.toLowerCase()))
);
function select(opt) {
query = opt;
value = opt;
open = false;
focused = -1;
onselect?.(opt);
}
function onInput(e) {
query = e.currentTarget.value;
value = query;
open = true;
focused = -1;
}
function onKeydown(e) {
if (!open) { if (e.key === 'ArrowDown') { open = true; } return; }
if (e.key === 'ArrowDown') { e.preventDefault(); focused = Math.min(focused + 1, filtered.length - 1); }
else if (e.key === 'ArrowUp') { e.preventDefault(); focused = Math.max(focused - 1, 0); }
else if (e.key === 'Enter') { e.preventDefault(); if (focused >= 0) { select(filtered[focused]); } else if (query.trim()) { select(query.trim()); } }
else if (e.key === 'Escape') { open = false; focused = -1; }
}
function onBlur() {
setTimeout(() => { open = false; focused = -1; }, 150);
}
// Keep query in sync if value is changed externally
$effect(() => { query = value; });
</script>
<div class="combo">
<input
{id}
{required}
{placeholder}
class="combo-input"
type="text"
autocomplete="off"
value={query}
oninput={onInput}
onkeydown={onKeydown}
onfocus={() => open = true}
onblur={onBlur}
/>
{#if open && filtered.length > 0}
<ul class="dropdown" role="listbox">
{#each filtered as opt, i}
<li
class="option"
class:highlighted={i === focused}
role="option"
aria-selected={opt === value}
onmousedown={() => select(opt)}
>{opt}</li>
{/each}
</ul>
{/if}
</div>
<style>
.combo {
position: relative;
width: 100%;
}
.combo-input {
font-family: var(--sans);
font-size: 14px;
font-weight: 300;
color: var(--text-h);
background: var(--bg-subtle);
border: 1px solid var(--border);
border-radius: 8px;
padding: 8px 12px;
outline: none;
transition: border-color 0.15s;
width: 100%;
}
.combo-input:focus { border-color: var(--accent-border); }
.dropdown {
position: absolute;
top: calc(100% + 4px);
left: 0;
right: 0;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
box-shadow: 0 4px 16px rgba(0,0,0,0.1);
list-style: none;
max-height: 200px;
overflow-y: auto;
z-index: 50;
padding: 4px;
}
.option {
font-size: 13px;
font-weight: 300;
color: var(--text);
padding: 7px 10px;
border-radius: 6px;
cursor: pointer;
transition: background 0.1s, color 0.1s;
}
.option:hover, .option.highlighted {
background: var(--accent-bg);
color: var(--accent);
}
</style>

View File

@@ -0,0 +1,25 @@
export const countryCodeMap = {
'Argentina': 'AR', 'Australia': 'AU', 'Austria': 'AT',
'Belgium': 'BE', 'Brazil': 'BR',
'Canada': 'CA', 'Chile': 'CL', 'China': 'CN', 'Croatia': 'HR',
'Czech Republic': 'CZ', 'Denmark': 'DK', 'Egypt': 'EG',
'Finland': 'FI', 'France': 'FR', 'Germany': 'DE', 'Greece': 'GR',
'Hungary': 'HU', 'India': 'IN', 'Indonesia': 'ID', 'Italy': 'IT',
'Japan': 'JP', 'Kenya': 'KE',
'Malaysia': 'MY', 'Mexico': 'MX', 'Morocco': 'MA',
'Netherlands': 'NL', 'New Zealand': 'NZ', 'Norway': 'NO',
'Peru': 'PE', 'Poland': 'PL', 'Portugal': 'PT',
'Singapore': 'SG', 'South Africa': 'ZA', 'South Korea': 'KR',
'Spain': 'ES', 'Sweden': 'SE', 'Switzerland': 'CH',
'Taiwan': 'TW', 'Thailand': 'TH', 'Turkey': 'TR',
'UK': 'GB', 'USA': 'US', 'Vietnam': 'VN',
};
export const countryNames = Object.keys(countryCodeMap).sort();
/** @param {string} country */
export function flagEmoji(country) {
const code = countryCodeMap[country];
if (!code) return '';
return [...code].map(c => String.fromCodePoint(0x1F1E6 - 65 + c.charCodeAt(0))).join('');
}

View File

@@ -5,10 +5,10 @@ import { writable } from 'svelte/store';
* id: string, * id: string,
* title: string, * title: string,
* date: string, * date: string,
* location: { country: string, city: string }, * location: { country: string, cities: string[] },
* photos: string[], * photos: string[],
* song: { title: string, artist: string }, * transport: 'flight' | 'train' | 'bus' | 'car' | 'ship' | 'walk',
* tripType: 'solo' | 'friends', * tripType: 'solo' | 'friends' | 'family',
* days: number, * days: number,
* memo: string * memo: string
* }} JournalEntry * }} JournalEntry
@@ -20,13 +20,13 @@ const mockEntries = [
id: '1', id: '1',
title: 'First Day in Tokyo', title: 'First Day in Tokyo',
date: '2024-03-15', date: '2024-03-15',
location: { country: 'Japan', city: 'Tokyo' }, location: { country: 'Japan', cities: ['Tokyo'] },
photos: [ photos: [
'https://images.unsplash.com/photo-1540959733332-eab4deabeeaf?w=600&q=80', 'https://images.unsplash.com/photo-1540959733332-eab4deabeeaf?w=600&q=80',
'https://images.unsplash.com/photo-1513407030348-c983a97b98d8?w=600&q=80', 'https://images.unsplash.com/photo-1513407030348-c983a97b98d8?w=600&q=80',
'https://images.unsplash.com/photo-1490806843957-31f4c9a91c65?w=600&q=80', 'https://images.unsplash.com/photo-1490806843957-31f4c9a91c65?w=600&q=80',
], ],
song: { title: 'Tokyo', artist: 'Imagine Dragons' }, transport: 'flight',
tripType: 'solo', tripType: 'solo',
days: 5, days: 5,
memo: 'Got completely lost in Shinjuku — stumbled into a tiny ramen shop with no English menu. The chashu just melted. Worth every wrong turn.', memo: 'Got completely lost in Shinjuku — stumbled into a tiny ramen shop with no English menu. The chashu just melted. Worth every wrong turn.',
@@ -35,12 +35,12 @@ const mockEntries = [
id: '2', id: '2',
title: 'Arashiyama Bamboo Grove', title: 'Arashiyama Bamboo Grove',
date: '2024-03-18', date: '2024-03-18',
location: { country: 'Japan', city: 'Kyoto' }, location: { country: 'Japan', cities: ['Kyoto'] },
photos: [ photos: [
'https://images.unsplash.com/photo-1528360983277-13d401cdc186?w=600&q=80', 'https://images.unsplash.com/photo-1528360983277-13d401cdc186?w=600&q=80',
'https://images.unsplash.com/photo-1545569341-9eb8b30979d9?w=600&q=80', 'https://images.unsplash.com/photo-1545569341-9eb8b30979d9?w=600&q=80',
], ],
song: { title: 'Spirited Away Suite', artist: 'Joe Hisaishi' }, transport: 'train',
tripType: 'friends', tripType: 'friends',
days: 3, days: 3,
memo: 'Arrived at 6am before the crowds. Just me and the wind moving through the bamboo. One of those moments you keep coming back to.', memo: 'Arrived at 6am before the crowds. Just me and the wind moving through the bamboo. One of those moments you keep coming back to.',
@@ -49,13 +49,13 @@ const mockEntries = [
id: '3', id: '3',
title: 'Sunset on Montmartre', title: 'Sunset on Montmartre',
date: '2024-06-02', date: '2024-06-02',
location: { country: 'France', city: 'Paris' }, location: { country: 'France', cities: ['Paris'] },
photos: [ photos: [
'https://images.unsplash.com/photo-1502602898657-3e91760cbb34?w=600&q=80', 'https://images.unsplash.com/photo-1502602898657-3e91760cbb34?w=600&q=80',
'https://images.unsplash.com/photo-1499856871958-5b9627545d1a?w=600&q=80', 'https://images.unsplash.com/photo-1499856871958-5b9627545d1a?w=600&q=80',
'https://images.unsplash.com/photo-1511739001486-6bfe10ce785f?w=600&q=80', 'https://images.unsplash.com/photo-1511739001486-6bfe10ce785f?w=600&q=80',
], ],
song: { title: 'La Vie en Rose', artist: 'Édith Piaf' }, transport: 'flight',
tripType: 'solo', tripType: 'solo',
days: 7, days: 7,
memo: 'Watched the whole city turn orange from the steps of Sacré-Cœur. A street musician was playing La Vie en Rose. Cliché, perfect.', memo: 'Watched the whole city turn orange from the steps of Sacré-Cœur. A street musician was playing La Vie en Rose. Cliché, perfect.',
@@ -64,12 +64,12 @@ const mockEntries = [
id: '4', id: '4',
title: 'Inside La Sagrada Família', title: 'Inside La Sagrada Família',
date: '2024-06-10', date: '2024-06-10',
location: { country: 'Spain', city: 'Barcelona' }, location: { country: 'Spain', cities: ['Barcelona'] },
photos: [ photos: [
'https://images.unsplash.com/photo-1523531294919-4bcd7c65e216?w=600&q=80', 'https://images.unsplash.com/photo-1523531294919-4bcd7c65e216?w=600&q=80',
'https://images.unsplash.com/photo-1583422409516-2895a77efded?w=600&q=80', 'https://images.unsplash.com/photo-1583422409516-2895a77efded?w=600&q=80',
], ],
song: { title: 'Spain', artist: 'Chick Corea' }, transport: 'flight',
tripType: 'friends', tripType: 'friends',
days: 4, days: 4,
memo: 'Nothing prepares you for the light inside. The stained glass turns the whole nave into a kaleidoscope. Gaudí was building a forest.', memo: 'Nothing prepares you for the light inside. The stained glass turns the whole nave into a kaleidoscope. Gaudí was building a forest.',
@@ -78,13 +78,13 @@ const mockEntries = [
id: '5', id: '5',
title: 'Central Park in Fall', title: 'Central Park in Fall',
date: '2023-10-20', date: '2023-10-20',
location: { country: 'USA', city: 'New York' }, location: { country: 'USA', cities: ['New York'] },
photos: [ photos: [
'https://images.unsplash.com/photo-1534430480872-3498386e7856?w=600&q=80', 'https://images.unsplash.com/photo-1534430480872-3498386e7856?w=600&q=80',
'https://images.unsplash.com/photo-1485871981521-5b1fd3805345?w=600&q=80', 'https://images.unsplash.com/photo-1485871981521-5b1fd3805345?w=600&q=80',
'https://images.unsplash.com/photo-1522083165195-3424ed129620?w=600&q=80', 'https://images.unsplash.com/photo-1522083165195-3424ed129620?w=600&q=80',
], ],
song: { title: 'New York, New York', artist: 'Frank Sinatra' }, transport: 'car',
tripType: 'friends', tripType: 'friends',
days: 6, days: 6,
memo: 'Peak foliage. Joggers, picnics, a guy playing saxophone near Bethesda Fountain. Hard to believe a city this big wraps around this much quiet.', memo: 'Peak foliage. Joggers, picnics, a guy playing saxophone near Bethesda Fountain. Hard to believe a city this big wraps around this much quiet.',
@@ -93,12 +93,12 @@ const mockEntries = [
id: '6', id: '6',
title: 'Wat Pho Reclining Buddha', title: 'Wat Pho Reclining Buddha',
date: '2024-01-08', date: '2024-01-08',
location: { country: 'Thailand', city: 'Bangkok' }, location: { country: 'Thailand', cities: ['Bangkok'] },
photos: [ photos: [
'https://images.unsplash.com/photo-1563492065599-3520f775eeed?w=600&q=80', 'https://images.unsplash.com/photo-1563492065599-3520f775eeed?w=600&q=80',
'https://images.unsplash.com/photo-1552465011-b4e21bf6e79a?w=600&q=80', 'https://images.unsplash.com/photo-1552465011-b4e21bf6e79a?w=600&q=80',
], ],
song: { title: 'Elephant', artist: 'Tame Impala' }, transport: 'ship',
tripType: 'solo', tripType: 'solo',
days: 2, days: 2,
memo: 'Stood in front of the 45m golden Buddha for a long time. The mother-of-pearl inlay on the soles of the feet is impossibly detailed.', memo: 'Stood in front of the 45m golden Buddha for a long time. The mother-of-pearl inlay on the soles of the feet is impossibly detailed.',
@@ -116,3 +116,8 @@ export function addJournal(entry) {
export function removeJournal(id) { export function removeJournal(id) {
journals.update((entries) => entries.filter((e) => e.id !== id)); journals.update((entries) => entries.filter((e) => e.id !== id));
} }
/** @param {JournalEntry} updated */
export function updateJournal(updated) {
journals.update((entries) => entries.map((e) => e.id === updated.id ? updated : e));
}

View File

@@ -0,0 +1,88 @@
<script>
let { entry, onConfirm, onCancel } = $props();
</script>
<div class="overlay" role="dialog" aria-modal="true">
<div class="dialog">
<h2 class="title">Delete entry?</h2>
<p class="body">
<strong>{entry.location.cities.join(', ')}, {entry.location.country}</strong>{entry.date.slice(0, 4)} will be permanently removed.
</p>
<div class="actions">
<button class="btn btn-cancel" onclick={onCancel}>Cancel</button>
<button class="btn btn-delete" onclick={onConfirm}>Delete</button>
</div>
</div>
</div>
<style>
.overlay {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.4);
z-index: 200;
display: flex;
align-items: center;
justify-content: center;
}
.dialog {
background: var(--bg);
border: 1px solid var(--border);
border-radius: 14px;
padding: 28px 32px;
width: 360px;
box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.title {
font-size: 17px;
font-weight: 400;
color: var(--text-h);
margin-bottom: 10px;
}
.body {
font-size: 14px;
font-weight: 300;
color: var(--text);
line-height: 1.6;
margin-bottom: 24px;
}
.actions {
display: flex;
justify-content: flex-end;
gap: 8px;
}
.btn {
font-family: var(--sans);
font-size: 13px;
font-weight: 300;
padding: 8px 18px;
border-radius: 8px;
border: 1px solid var(--border);
cursor: pointer;
transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-cancel {
background: var(--bg);
color: var(--text);
}
.btn-cancel:hover {
background: var(--bg-subtle);
color: var(--text-h);
}
.btn-delete {
background: #dc2626;
color: #fff;
border-color: #dc2626;
}
.btn-delete:hover {
background: #b91c1c;
border-color: #b91c1c;
}
</style>

View File

@@ -0,0 +1,421 @@
<script>
import { get } from 'svelte/store';
import { journals, addJournal, updateJournal } from '../stores/journalStore.js';
import { countryNames } from '../shared/countries.js';
import SearchInput from '../shared/SearchInput.svelte';
import PhotoEditor from './PhotoEditor.svelte';
/**
* entry = null → "new entry" mode
* entry = {...} → "edit" mode
* @type {{ entry?: import('../stores/journalStore.js').JournalEntry | null, initialCountry?: string, onBack: () => void }}
*/
let { entry = null, initialCountry = '', onBack } = $props();
let isNew = !entry;
let cities = $state([...(entry?.location.cities ?? [])]);
let cityInput = $state('');
let country = $state(entry?.location.country ?? initialCountry);
let date = $state(entry?.date ?? new Date().toISOString().slice(0, 10));
let days = $state(String(entry?.days ?? 1));
let tripType = $state(entry?.tripType ?? 'solo');
let photos = $state([...(entry?.photos ?? [])]);
let memo = $state(entry?.memo ?? '');
let transport = $state(entry?.transport ?? 'flight');
const transportOptions = [
{ value: 'flight', label: '✈ Flight' },
{ value: 'train', label: '🚂 Train' },
{ value: 'bus', label: '🚌 Bus' },
{ value: 'car', label: '🚗 Car' },
{ value: 'ship', label: '🚢 Ship' },
{ value: 'walk', label: '🚶 Walk' },
];
const MEMO_MAX = 100;
let wordCount = $derived(memo.trim() === '' ? 0 : memo.trim().split(/\s+/).length);
let memoOverLimit = $derived(wordCount > MEMO_MAX);
function onMemoInput(e) {
const raw = e.currentTarget.value;
const words = raw.trim() === '' ? [] : raw.trim().split(/\s+/);
if (words.length > MEMO_MAX) {
// keep first 100 words, preserve trailing space if user is mid-word
memo = words.slice(0, MEMO_MAX).join(' ');
e.currentTarget.value = memo;
} else {
memo = raw;
}
}
let cityOptions = $derived(
[...new Set(get(journals).flatMap(e => e.location.cities))].sort()
);
function addCity(val) {
const trimmed = (val ?? cityInput).trim();
if (trimmed && !cities.includes(trimmed)) {
cities = [...cities, trimmed];
}
cityInput = '';
}
function removeCity(c) {
cities = cities.filter(x => x !== c);
}
function save() {
if (isNew) {
addJournal({
title: `${cities.join(', ')}, ${country}`,
date,
days: Number(days),
tripType,
memo,
photos,
transport,
location: { cities, country },
});
} else {
updateJournal({
...entry,
date,
days: Number(days),
tripType,
transport,
memo,
photos,
location: { cities, country },
});
}
onBack();
}
</script>
<div class="edit-layout">
<header class="edit-topbar">
<div class="topbar-left">
<button class="topbar-btn" onclick={onBack}>
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
<path d="M19 12H5M12 5l-7 7 7 7"/>
</svg>
Back
</button>
</div>
<span class="topbar-title">{isNew ? 'New entry' : 'Edit'}</span>
<div class="topbar-right">
<button class="topbar-btn topbar-btn--save" onclick={save}>Save changes</button>
</div>
</header>
<div class="edit-scroll">
<form class="form" onsubmit={(e) => { e.preventDefault(); save(); }}>
<div class="row">
<div class="field">
<label class="label" for="edit-country">Country <span class="req">*</span></label>
<SearchInput id="edit-country" bind:value={country} options={countryNames} required />
</div>
<div class="field">
<label class="label" for="edit-city">Cities <span class="req">*</span></label>
<div class="city-input-row">
<SearchInput id="edit-city" bind:value={cityInput} options={cityOptions} onselect={addCity} />
</div>
{#if cities.length > 0}
<div class="city-tags">
{#each cities as c}
<span class="city-tag">
{c}
<button type="button" class="city-tag-remove" onclick={() => removeCity(c)}>×</button>
</span>
{/each}
</div>
{/if}
</div>
</div>
<div class="row">
<div class="field">
<label class="label" for="edit-date">Date <span class="req">*</span></label>
<input id="edit-date" class="input" type="date" bind:value={date} required />
</div>
<div class="field">
<label class="label" for="edit-days">Days <span class="req">*</span></label>
<input id="edit-days" class="input" type="number" min="1" bind:value={days} required />
</div>
</div>
<div class="field">
<label class="label">Trip type</label>
<div class="toggle-row">
<label class="toggle-opt" class:active={tripType === 'solo'}>
<input type="radio" name="tripType" value="solo" bind:group={tripType} /> Solo
</label>
<label class="toggle-opt" class:active={tripType === 'friends'}>
<input type="radio" name="tripType" value="friends" bind:group={tripType} /> With friends
</label>
<label class="toggle-opt" class:active={tripType === 'family'}>
<input type="radio" name="tripType" value="family" bind:group={tripType} /> With family
</label>
</div>
</div>
<div class="field">
<label class="label">How did you get there?</label>
<div class="transport-grid">
{#each transportOptions as opt}
<label class="transport-opt" class:active={transport === opt.value}>
<input type="radio" name="transport" value={opt.value} bind:group={transport} />
{opt.label}
</label>
{/each}
</div>
</div>
<PhotoEditor {photos} onchange={(p) => (photos = p)} />
<div class="field">
<div class="label-row">
<label class="label" for="edit-memo">How was it?</label>
<span class="char-count" class:over={memoOverLimit}>{wordCount} / {MEMO_MAX} words</span>
</div>
<textarea id="edit-memo" class="input textarea" class:input-over={memoOverLimit} rows="4" value={memo} oninput={onMemoInput}></textarea>
</div>
</form>
</div>
</div>
<style>
.edit-layout {
display: flex;
flex-direction: column;
height: 100%;
overflow: hidden;
background: var(--bg);
}
.edit-topbar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
height: 52px;
flex-shrink: 0;
border-bottom: 1px solid var(--border);
background: var(--bg);
}
.topbar-left, .topbar-right {
display: flex;
align-items: center;
gap: 4px;
min-width: 120px;
}
.topbar-right { justify-content: flex-end; }
.topbar-title {
font-size: 14px;
font-weight: 400;
color: var(--text-h);
}
.topbar-btn {
display: inline-flex;
align-items: center;
gap: 6px;
font-family: var(--sans);
font-size: 13px;
font-weight: 300;
color: var(--text);
background: none;
border: 1px solid transparent;
border-radius: 8px;
padding: 6px 12px;
cursor: pointer;
transition: background 0.15s, color 0.15s, border-color 0.15s;
white-space: nowrap;
}
.topbar-btn:hover {
background: var(--bg-subtle);
border-color: var(--border);
color: var(--text-h);
}
.topbar-btn--save {
background: var(--accent);
color: #fff;
border-color: var(--accent);
}
.topbar-btn--save:hover {
background: var(--accent-dark);
border-color: var(--accent-dark);
color: #fff;
}
.edit-scroll {
flex: 1;
overflow-y: auto;
}
.form {
display: flex;
flex-direction: column;
gap: 18px;
max-width: 560px;
margin: 0 auto;
padding: 36px 48px 80px;
}
.row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 14px;
}
.field {
display: flex;
flex-direction: column;
gap: 6px;
}
.label-row {
display: flex;
align-items: baseline;
justify-content: space-between;
}
.label {
font-size: 11px;
font-weight: 400;
letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--text-sub);
}
.char-count {
font-size: 11px;
font-weight: 300;
color: var(--text-sub);
transition: color 0.15s;
}
.char-count.over { color: #dc2626; }
.input-over { border-color: #fca5a5; }
.req {
color: var(--accent);
font-size: 11px;
}
.input {
font-family: var(--sans);
font-size: 14px;
font-weight: 300;
color: var(--text-h);
background: var(--bg-subtle);
border: 1px solid var(--border);
border-radius: 8px;
padding: 8px 12px;
outline: none;
transition: border-color 0.15s;
width: 100%;
}
.input:focus { border-color: var(--accent-border); }
.textarea {
resize: vertical;
line-height: 1.6;
}
.toggle-row {
display: flex;
gap: 8px;
}
.toggle-opt {
display: flex;
align-items: center;
gap: 6px;
font-size: 13px;
font-weight: 300;
color: var(--text);
padding: 7px 14px;
border-radius: 8px;
border: 1px solid var(--border);
cursor: pointer;
transition: border-color 0.15s, background 0.15s, color 0.15s;
background: var(--bg-subtle);
}
.toggle-opt input { display: none; }
.toggle-opt.active {
border-color: var(--accent-border);
background: var(--accent-bg);
color: var(--accent);
}
.transport-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
}
.transport-opt {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
font-size: 13px;
font-weight: 300;
color: var(--text);
padding: 8px 10px;
border-radius: 8px;
border: 1px solid var(--border);
cursor: pointer;
transition: border-color 0.15s, background 0.15s, color 0.15s;
background: var(--bg-subtle);
white-space: nowrap;
}
.transport-opt input { display: none; }
.transport-opt.active {
border-color: var(--accent-border);
background: var(--accent-bg);
color: var(--accent);
}
.city-input-row {
display: flex;
}
.city-tags {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 4px;
}
.city-tag {
display: inline-flex;
align-items: center;
gap: 4px;
font-size: 12px;
font-weight: 300;
color: var(--accent);
background: var(--accent-bg);
border: 1px solid var(--accent-border);
border-radius: 20px;
padding: 3px 10px 3px 12px;
}
.city-tag-remove {
background: none;
border: none;
color: var(--accent);
font-size: 15px;
line-height: 1;
cursor: pointer;
padding: 0;
opacity: 0.6;
transition: opacity 0.15s;
}
.city-tag-remove:hover { opacity: 1; }
</style>

View File

@@ -1,19 +1,16 @@
<script> <script>
/** @type {{ entry: import('../stores/journalStore.js').JournalEntry, onBack: () => void }} */ import { removeJournal } from '../stores/journalStore.js';
let { entry, onBack } = $props(); import { flagEmoji } from '../shared/countries.js';
import DeleteConfirm from './DeleteConfirm.svelte';
const countryCodeMap = { /** @type {{ entry: import('../stores/journalStore.js').JournalEntry, onBack: () => void, onEdit: () => void }} */
'Japan': 'JP', 'France': 'FR', 'Spain': 'ES', 'USA': 'US', let { entry, onBack, onEdit } = $props();
'Thailand': 'TH', 'Germany': 'DE', 'Italy': 'IT', 'UK': 'GB',
'Australia': 'AU', 'Canada': 'CA', 'China': 'CN', 'India': 'IN', let showDeleteConfirm = $state(false);
'Brazil': 'BR', 'Mexico': 'MX', 'Portugal': 'PT', 'Netherlands': 'NL',
'Greece': 'GR', 'Turkey': 'TR', 'Vietnam': 'VN', 'Indonesia': 'ID', function handleDelete() {
'South Korea': 'KR', 'Singapore': 'SG', 'Taiwan': 'TW', 'New Zealand': 'NZ', removeJournal(entry.id);
}; onBack();
function flagEmoji(country) {
const code = countryCodeMap[country];
if (!code) return '';
return [...code].map(c => String.fromCodePoint(0x1F1E6 - 65 + c.charCodeAt(0))).join('');
} }
function formatDate(iso) { function formatDate(iso) {
@@ -25,6 +22,10 @@
let lightboxSrc = $state(null); let lightboxSrc = $state(null);
</script> </script>
{#if showDeleteConfirm}
<DeleteConfirm {entry} onConfirm={handleDelete} onCancel={() => showDeleteConfirm = false} />
{/if}
<!-- Lightbox --> <!-- Lightbox -->
{#if lightboxSrc} {#if lightboxSrc}
<div class="lightbox" onclick={() => lightboxSrc = null} role="button" tabindex="0" <div class="lightbox" onclick={() => lightboxSrc = null} role="button" tabindex="0"
@@ -35,149 +36,199 @@
<div class="detail-layout"> <div class="detail-layout">
<!-- ── Left: photo grid ── --> <!-- ── Full-width top bar ── -->
<div class="photo-col"> <header class="detail-topbar">
<!-- Country overlay top-left --> <div class="topbar-left">
<div class="photo-country"> <button class="topbar-btn" onclick={onBack}>
<span class="photo-flag">{flagEmoji(entry.location.country)}</span> <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
<div> <path d="M19 12H5M12 5l-7 7 7 7"/>
<p class="photo-city">{entry.location.city}</p> </svg>
<p class="photo-country-name">{entry.location.country}</p> Back
</button>
<div class="topbar-divider"></div>
<span class="topbar-flag">{flagEmoji(entry.location.country)}</span>
<div class="topbar-place">
<span class="topbar-city">{entry.location.cities.join(', ')}</span>
<span class="topbar-country">{entry.location.country}</span>
</div> </div>
</div> </div>
<div class="photo-scroll"> <div class="topbar-right">
{#if entry.photos.length === 0} <button class="topbar-btn" title="Edit entry" onclick={onEdit}>
<div class="no-photos">No photos</div> <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
{:else} <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
<div class="photo-grid"> <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
{#each entry.photos as photo, i} </svg>
<div class="photo-cell" class:cell-wide={i === 0 && entry.photos.length > 1}> Edit
<img src={photo} alt="" </button>
onclick={() => lightboxSrc = photo} <button class="topbar-btn topbar-btn--danger" title="Delete entry" onclick={() => showDeleteConfirm = true}>
onerror={(e) => e.currentTarget.parentElement.classList.add('cell-broken')} /> <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6"/>
</svg>
Delete
</button>
</div>
</header>
<!-- ── Body: photo left + Q&A right ── -->
<div class="detail-body">
<!-- Left: photos -->
<div class="photo-col">
<div class="photo-scroll">
{#if entry.photos.length === 0}
<div class="no-photos">No photos</div>
{:else}
<div class="photo-grid">
{#each entry.photos as photo, i}
<div class="photo-cell" class:cell-wide={i === 0 && entry.photos.length > 1}>
<img src={photo} alt=""
onclick={() => lightboxSrc = photo}
onerror={(e) => e.currentTarget.parentElement.classList.add('cell-broken')} />
</div>
{/each}
</div> </div>
{/each} {/if}
</div> </div>
{/if}
</div> </div>
</div>
<!-- ── Right: Q&A ── --> <!-- Right: Q&A -->
<div class="info-col"> <div class="info-col">
<div class="info-inner"> <div class="info-inner">
<div class="qa-list">
<div class="qa-item">
<div class="qa-list"> <p class="question">When did you go?</p>
<p class="answer">{formatDate(entry.date)}</p>
<div class="qa-item">
<p class="question">When did you go?</p>
<p class="answer">{formatDate(entry.date)}</p>
</div>
<div class="qa-item">
<p class="question">How long did you stay?</p>
<p class="answer">{entry.days} {entry.days === 1 ? 'day' : 'days'}</p>
</div>
<div class="qa-item">
<p class="question">Who did you go with?</p>
<p class="answer">
{#if entry.tripType === 'solo'}
Just me — solo trip
{:else}
With friends
{/if}
</p>
</div>
<div class="qa-item">
<p class="question">How was it?</p>
<p class="answer memo">{entry.memo}</p>
</div>
<div class="qa-item">
<p class="question">Trip soundtrack</p>
<div class="song-answer">
<div class="song-icon">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M9 18V5l12-2v13"/>
<circle cx="6" cy="18" r="3"/>
<circle cx="18" cy="16" r="3"/>
</svg>
</div>
<div>
<p class="song-title">{entry.song.title}</p>
<p class="song-artist">{entry.song.artist}</p>
</div>
</div> </div>
</div>
<div class="qa-item">
<p class="question">How long did you stay?</p>
<p class="answer">{entry.days} {entry.days === 1 ? 'day' : 'days'}</p>
</div>
<div class="qa-item">
<p class="question">Who did you go with?</p>
<p class="answer">
{#if entry.tripType === 'solo'}
Just me — solo trip
{:else if entry.tripType === 'family'}
With family
{:else}
With friends
{/if}
</p>
</div>
<div class="qa-item">
<p class="question">How was it?</p>
<p class="answer memo">{entry.memo}</p>
</div>
</div>
</div> </div>
</div> </div>
</div>
<!-- ── Floating action buttons ── -->
<div class="fab-group">
<button class="fab fab-delete" title="Delete entry">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<path d="M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6"/>
</svg>
</button>
<button class="fab fab-edit" title="Edit entry">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
</svg>
Edit
</button>
</div> </div>
</div> </div>
<style> <style>
/* ── Two-column layout ── */ /* ── Outer layout: column (topbar + body) ── */
.detail-layout { .detail-layout {
display: flex; display: flex;
flex-direction: row; flex-direction: column;
height: 100%; height: 100%;
position: relative; overflow: hidden;
}
/* ── Full-width top bar ── */
.detail-topbar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
height: 52px;
flex-shrink: 0;
background: var(--bg);
border-bottom: 1px solid var(--border);
}
.topbar-left {
display: flex;
align-items: center;
gap: 12px;
}
.topbar-right {
display: flex;
align-items: center;
gap: 4px;
}
.topbar-divider {
width: 1px;
height: 20px;
background: var(--border);
}
.topbar-flag { font-size: 20px; line-height: 1; }
.topbar-place {
display: flex;
align-items: baseline;
gap: 6px;
}
.topbar-city {
font-size: 13px;
font-weight: 300;
color: var(--text-sub);
}
.topbar-country {
font-size: 17px;
font-weight: 400;
color: var(--text-h);
letter-spacing: -0.3px;
}
.topbar-btn {
display: inline-flex;
align-items: center;
gap: 6px;
font-family: var(--sans);
font-size: 13px;
font-weight: 300;
color: var(--text);
background: none;
border: 1px solid transparent;
border-radius: 8px;
padding: 6px 12px;
cursor: pointer;
transition: background 0.15s, color 0.15s, border-color 0.15s;
white-space: nowrap;
}
.topbar-btn:hover {
background: var(--bg-subtle);
border-color: var(--border);
color: var(--text-h);
}
.topbar-btn--danger:hover { color: #dc2626; background: #fff1f1; border-color: #fca5a5; }
/* ── Body row ── */
.detail-body {
flex: 1;
display: flex;
flex-direction: row;
overflow: hidden; overflow: hidden;
} }
/* ── Left: photos ── */ /* ── Left: photos ── */
.photo-col { .photo-col {
flex: 1; flex: 1;
display: flex;
flex-direction: column;
overflow: hidden; overflow: hidden;
background: #f0f0f0; background: #f0f0f0;
}
/* Country bar at top of photo column */
.photo-country {
display: flex; display: flex;
align-items: center; flex-direction: column;
gap: 10px;
padding: 12px 16px;
background: var(--bg);
border-bottom: 1px solid var(--border);
flex-shrink: 0;
}
.photo-flag { font-size: 20px; line-height: 1; }
.photo-city {
font-size: 11px;
font-weight: 300;
color: var(--text-sub);
letter-spacing: 0.08em;
text-transform: uppercase;
}
.photo-country-name {
font-size: 15px;
font-weight: 400;
color: var(--text-h);
letter-spacing: -0.2px;
line-height: 1.2;
} }
.photo-scroll { .photo-scroll {
@@ -199,7 +250,6 @@
border-radius: 4px; border-radius: 4px;
cursor: zoom-in; cursor: zoom-in;
} }
/* First photo spans full width when there are multiple */
.photo-cell.cell-wide { .photo-cell.cell-wide {
grid-column: 1 / -1; grid-column: 1 / -1;
grid-row: span 2; grid-row: span 2;
@@ -239,36 +289,12 @@
} }
.info-inner { .info-inner {
padding: 40px 32px 100px; padding: 36px 32px 80px;
} }
/* Heading */
.entry-heading {
margin-bottom: 36px;
padding-bottom: 24px;
border-bottom: 1px solid var(--border);
}
.entry-city {
font-size: 12px;
font-weight: 300;
color: var(--text-sub);
letter-spacing: 0.08em;
text-transform: uppercase;
margin-bottom: 2px;
}
.entry-country {
font-size: 24px;
font-weight: 400;
color: var(--text-h);
letter-spacing: -0.5px;
line-height: 1.1;
}
/* Q&A list */
.qa-list { .qa-list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0;
} }
.qa-item { .qa-item {
@@ -299,80 +325,6 @@
line-height: 1.75; line-height: 1.75;
} }
/* Song answer */
.song-answer {
display: flex;
align-items: center;
gap: 10px;
}
.song-icon {
width: 36px;
height: 36px;
border-radius: 50%;
background: var(--accent-bg);
color: var(--accent);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.song-title {
font-size: 14px;
font-weight: 400;
color: var(--text-h);
}
.song-artist {
font-size: 12px;
font-weight: 300;
color: var(--text-sub);
margin-top: 2px;
}
/* ── Floating action buttons ── */
.fab-group {
position: absolute;
bottom: 32px;
right: 28px;
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 10px;
z-index: 10;
}
.fab {
display: flex;
align-items: center;
gap: 7px;
font-family: var(--sans);
font-size: 13px;
font-weight: 300;
padding: 10px 18px 10px 14px;
border-radius: 40px;
border: 1px solid var(--border);
cursor: pointer;
box-shadow: 0 4px 16px rgba(0,0,0,0.1);
transition: box-shadow 0.15s, transform 0.15s;
letter-spacing: 0.02em;
}
.fab:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.15); transform: translateY(-1px); }
.fab-edit {
background: var(--accent);
color: #fff;
border-color: transparent;
}
.fab-delete {
background: var(--bg);
color: var(--text);
padding: 10px 14px;
border-radius: 50%;
width: 40px;
height: 40px;
justify-content: center;
}
.fab-delete:hover { color: #dc2626; border-color: #fca5a5; }
/* ── Lightbox ── */ /* ── Lightbox ── */
.lightbox { .lightbox {
position: fixed; position: fixed;
@@ -393,9 +345,8 @@
/* ── Responsive ── */ /* ── Responsive ── */
@media (max-width: 700px) { @media (max-width: 700px) {
.detail-layout { flex-direction: column; overflow-y: auto; } .detail-body { flex-direction: column; overflow-y: auto; }
.photo-col { height: 260px; flex: none; } .photo-col { height: 260px; flex: none; }
.info-col { width: 100%; border-left: none; border-top: 1px solid var(--border); } .info-col { width: 100%; border-left: none; border-top: 1px solid var(--border); }
.fab-group { bottom: 20px; right: 16px; }
} }
</style> </style>

View File

@@ -7,209 +7,192 @@
const totalDays = entries.reduce((s, e) => s + e.days, 0); const totalDays = entries.reduce((s, e) => s + e.days, 0);
const countries = [...new Set(entries.map(e => e.location.country))]; const countries = [...new Set(entries.map(e => e.location.country))];
const cities = [...new Set(entries.map(e => e.location.city))]; const cities = [...new Set(entries.flatMap(e => e.location.cities))];
const countryCounts = {}; const years = entries.map(e => new Date(e.date).getFullYear());
for (const e of entries) countryCounts[e.location.country] = (countryCounts[e.location.country] ?? 0) + 1; const minYear = Math.min(...years);
const topCountry = Object.entries(countryCounts).sort((a, b) => b[1] - a[1])[0]; const maxYear = Math.max(...years);
const soloCount = entries.filter(e => e.tripType === 'solo').length;
const soloPct = Math.round(soloCount / entries.length * 100);
const years = entries.map(e => new Date(e.date).getFullYear());
const minYear = Math.min(...years);
const maxYear = Math.max(...years);
const yearRange = minYear === maxYear ? `${minYear}` : `${minYear} ${maxYear}`; const yearRange = minYear === maxYear ? `${minYear}` : `${minYear} ${maxYear}`;
const latest = [...entries].sort((a, b) => b.date.localeCompare(a.date))[0]; return { totalDays, countries, cities, yearRange, tripCount: entries.length };
return { totalDays, countries, cities, topCountry, soloCount, soloPct, yearRange, latest, tripCount: entries.length };
}); });
</script> </script>
{#if stats} {#if stats}
<div class="summary"> <div class="passport">
<!-- diagonal pattern -->
<p class="eyebrow">My Journey</p> <div class="passport-body">
<p class="year-range">{stats.yearRange}</p> <!-- Left -->
<div class="passport-left">
<div class="passport-header">
<svg viewBox="0 0 32 32" fill="none" class="globe">
<circle cx="16" cy="16" r="13" stroke="currentColor" stroke-width="1.3"/>
<ellipse cx="16" cy="16" rx="5.5" ry="13" stroke="currentColor" stroke-width="1.3"/>
<line x1="3" y1="16" x2="29" y2="16" stroke="currentColor" stroke-width="1.3"/>
<line x1="5" y1="9" x2="27" y2="9" stroke="currentColor" stroke-width="1.3"/>
<line x1="5" y1="23" x2="27" y2="23" stroke="currentColor" stroke-width="1.3"/>
</svg>
<span class="issuer">TRAVEL JOURNAL</span>
</div>
<div>
<p class="type">PASSPORT</p>
<p class="years">{stats.yearRange}</p>
</div>
</div>
<div class="divider"></div> <div class="vdivider"></div>
<!-- Big stats --> <!-- Right -->
<div class="stat-stack"> <div class="passport-right">
<div class="stat-row"> <div class="field">
<span class="stat-num">{stats.countries.length}</span> <span class="field-label">TRIPS</span>
<span class="stat-lbl">Countries</span> <span class="field-value">{stats.tripCount}</span>
</div> </div>
<div class="stat-row"> <div class="field">
<span class="stat-num">{stats.cities.length}</span> <span class="field-label">COUNTRIES</span>
<span class="stat-lbl">Cities</span> <span class="field-value">{stats.countries.length}</span>
</div> </div>
<div class="stat-row"> <div class="field">
<span class="stat-num">{stats.totalDays}</span> <span class="field-label">DAYS</span>
<span class="stat-lbl">Days abroad</span> <span class="field-value">{stats.totalDays}</span>
</div> </div>
<div class="stat-row">
<span class="stat-num">{stats.tripCount}</span>
<span class="stat-lbl">Trips</span>
</div> </div>
</div> </div>
<div class="divider"></div> <!-- MRZ -->
<div class="mrz">
<!-- Most visited --> <span>P&lt;JNL{String(stats.tripCount).padStart(2,'0')}&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span>
<div class="insight"> <span>{stats.yearRange.replace(' ','').replace(/\s/g,'')}{'<'.repeat(12)}{String(stats.totalDays).padStart(4,'0')}</span>
<span class="insight-label">Most visited</span>
<span class="insight-value">{stats.topCountry[0]}</span>
<span class="insight-sub">{stats.topCountry[1]} {stats.topCountry[1] === 1 ? 'trip' : 'trips'}</span>
</div> </div>
<!-- Latest trip -->
<div class="insight">
<span class="insight-label">Latest trip</span>
<span class="insight-value">{stats.latest.location.city}</span>
<span class="insight-sub">{stats.latest.location.country}</span>
</div>
<div class="divider"></div>
<!-- Trip style bar -->
<div class="style-section">
<span class="insight-label">Trip style</span>
<div class="style-bar">
<div class="style-fill" style="width: {stats.soloPct}%"></div>
</div>
<div class="style-legend">
<span><span class="dot solo-dot"></span> {stats.soloPct}% Solo</span>
<span><span class="dot friends-dot"></span> {100 - stats.soloPct}% Friends</span>
</div>
</div>
</div> </div>
{/if} {/if}
<style> <style>
.summary { .passport {
background: #1e1b4b;
border-radius: 14px;
overflow: hidden;
color: #e0e7ff;
position: relative;
}
.passport::before {
content: '';
position: absolute;
inset: 0;
background: repeating-linear-gradient(
135deg,
transparent 0px, transparent 20px,
rgba(255,255,255,0.025) 20px, rgba(255,255,255,0.025) 21px
);
pointer-events: none;
}
/* Body: left + divider + right in a row */
.passport-body {
display: flex; display: flex;
flex-direction: column; flex-direction: row;
align-items: stretch;
padding: 20px;
gap: 0; gap: 0;
position: relative;
z-index: 1;
} }
.eyebrow { /* Left column */
font-size: var(--text-xs); .passport-left {
font-weight: 400; flex: 1;
letter-spacing: 0.12em;
text-transform: uppercase;
color: var(--accent);
margin-bottom: 4px;
}
.year-range {
font-size: var(--text-lg);
font-weight: 400;
color: var(--text-h);
letter-spacing: -0.3px;
}
.divider {
height: 1px;
background: var(--border);
margin: 20px 0;
}
/* Stat stack */
.stat-stack {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 14px;
}
.stat-row {
display: flex;
align-items: baseline;
justify-content: space-between; justify-content: space-between;
gap: 16px;
padding-right: 20px;
}
.passport-header {
display: flex;
align-items: center;
gap: 8px; gap: 8px;
} }
.globe {
.stat-num { width: 26px;
font-size: var(--text-2xl); height: 26px;
color: #a5b4fc;
flex-shrink: 0;
}
.issuer {
font-size: 9px;
font-weight: 500;
letter-spacing: 0.18em;
color: #a5b4fc;
line-height: 1.4;
}
.type {
font-size: 10px;
font-weight: 500;
letter-spacing: 0.22em;
color: #818cf8;
margin-bottom: 4px;
}
.years {
font-size: 26px;
font-weight: 400; font-weight: 400;
color: var(--text-h); color: #fff;
letter-spacing: -1px; letter-spacing: -0.8px;
line-height: 1; line-height: 1;
} }
.stat-lbl { /* Divider */
font-size: var(--text-xs); .vdivider {
font-weight: 300; width: 1px;
color: var(--text-sub); background: rgba(255,255,255,0.12);
text-transform: uppercase; flex-shrink: 0;
letter-spacing: 0.06em; align-self: stretch;
text-align: right;
} }
/* Insights */ /* Right column */
.insight { .passport-right {
display: flex;
flex-direction: column;
justify-content: space-between;
gap: 10px;
padding-left: 20px;
}
.field {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 2px; gap: 2px;
margin-bottom: 16px;
} }
.insight:last-of-type { margin-bottom: 0; } .field-label {
font-size: 8px;
.insight-label { font-weight: 500;
font-size: var(--text-xs); letter-spacing: 0.18em;
color: #818cf8;
}
.field-value {
font-size: 22px;
font-weight: 400; font-weight: 400;
text-transform: uppercase; color: #fff;
letter-spacing: 0.08em; letter-spacing: -0.5px;
color: var(--accent); line-height: 1;
} }
.insight-value { /* MRZ strip */
font-size: var(--text-md); .mrz {
font-weight: 400; border-top: 1px solid rgba(255,255,255,0.1);
color: var(--text-h); padding: 9px 20px;
line-height: 1.2; background: rgba(0,0,0,0.18);
display: flex;
flex-direction: column;
gap: 2px;
position: relative;
z-index: 1;
} }
.mrz span {
.insight-sub { font-family: var(--mono);
font-size: var(--text-sm); font-size: 8px;
font-weight: 300; color: #6366f1;
color: var(--text); letter-spacing: 0.06em;
} white-space: nowrap;
/* Trip style */
.style-section { display: flex; flex-direction: column; gap: 8px; }
.style-bar {
height: 6px;
border-radius: 99px;
background: var(--lavender-bg);
overflow: hidden; overflow: hidden;
} }
.style-fill {
height: 100%;
background: linear-gradient(90deg, var(--accent-dark), var(--lavender));
border-radius: 99px;
transition: width 0.4s ease;
}
.style-legend {
display: flex;
justify-content: space-between;
font-size: var(--text-xs);
font-weight: 300;
color: var(--text);
}
.dot {
display: inline-block;
width: 7px;
height: 7px;
border-radius: 50%;
margin-right: 4px;
vertical-align: middle;
}
.solo-dot { background: var(--accent-dark); }
.friends-dot { background: var(--lavender); }
</style> </style>

View File

@@ -0,0 +1,183 @@
<script>
/** @type {{ photos: string[], onchange: (photos: string[]) => void }} */
let { photos, onchange } = $props();
let fileInput;
function remove(index) {
const next = photos.filter((_, i) => i !== index);
onchange(next);
}
async function addFiles(e) {
const files = Array.from(e.currentTarget.files ?? []);
if (!files.length) return;
const dataUrls = await Promise.all(files.map(fileToDataUrl));
onchange([...photos, ...dataUrls]);
// reset so the same file can be picked again
e.currentTarget.value = '';
}
/** @param {File} file */
function fileToDataUrl(file) {
return new Promise((resolve) => {
const reader = new FileReader();
reader.onload = (e) => resolve(/** @type {string} */ (e.target.result));
reader.readAsDataURL(file);
});
}
</script>
<div class="photo-editor">
<div class="label-row">
<span class="label">Photos</span>
<input bind:this={fileInput} type="file" accept="image/*" multiple onchange={addFiles} hidden />
</div>
{#if photos.length === 0}
<button type="button" class="empty-zone" onclick={() => fileInput.click()}>
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.2">
<rect x="3" y="3" width="18" height="18" rx="3"/>
<circle cx="8.5" cy="8.5" r="1.5"/>
<path d="M21 15l-5-5L5 21"/>
</svg>
<span>Click to add photos</span>
</button>
{:else}
<div class="grid">
{#each photos as src, i (src + i)}
<div class="cell">
<img {src} alt="photo {i + 1}" />
<button type="button" class="remove-btn" onclick={() => remove(i)} aria-label="Remove photo">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
<path d="M18 6L6 18M6 6l12 12"/>
</svg>
</button>
</div>
{/each}
<button type="button" class="add-cell" onclick={() => fileInput.click()}>
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round">
<path d="M12 5v14M5 12h14"/>
</svg>
</button>
</div>
{/if}
</div>
<style>
.photo-editor {
display: flex;
flex-direction: column;
gap: 10px;
}
.label-row {
display: flex;
align-items: center;
gap: 10px;
}
.label {
font-size: 11px;
font-weight: 400;
letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--text-sub);
flex: 1;
}
.add-btn {
display: inline-flex;
align-items: center;
gap: 5px;
font-family: var(--sans);
font-size: 12px;
font-weight: 300;
color: var(--accent);
background: var(--accent-bg);
border: 1px solid var(--accent-border);
border-radius: 6px;
padding: 4px 10px;
cursor: pointer;
transition: background 0.15s;
}
.add-btn:hover { background: rgba(124,58,237,0.12); }
.empty-zone {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 10px;
height: 120px;
border: 1.5px dashed var(--border-bright);
border-radius: 10px;
color: var(--text-sub);
font-family: var(--sans);
font-size: 13px;
font-weight: 300;
cursor: pointer;
background: var(--bg-subtle);
transition: border-color 0.15s, color 0.15s;
width: 100%;
}
.empty-zone:hover { border-color: var(--accent-border); color: var(--accent); }
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 6px;
}
.cell {
position: relative;
aspect-ratio: 1;
border-radius: 8px;
overflow: hidden;
background: var(--bg-subtle);
}
.cell img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
.remove-btn {
position: absolute;
top: 5px;
right: 5px;
width: 22px;
height: 22px;
border-radius: 50%;
border: none;
background: rgba(0,0,0,0.55);
color: #fff;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
opacity: 0;
transition: opacity 0.15s, background 0.15s;
}
.cell:hover .remove-btn { opacity: 1; }
.remove-btn:hover { background: rgba(220,38,38,0.85); }
.add-cell {
aspect-ratio: 1;
border-radius: 8px;
border: 1.5px dashed var(--border-bright);
background: var(--bg-subtle);
color: var(--text-sub);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: border-color 0.15s, color 0.15s;
}
.add-cell:hover { border-color: var(--accent-border); color: var(--accent); }
</style>

View File

@@ -0,0 +1,484 @@
<script>
import { toPng } from 'html-to-image';
/** @type {{ entries: import('../stores/journalStore.js').JournalEntry[], onClose: () => void }} */
let { entries, onClose } = $props();
let cardEl = $state(null);
let downloading = $state(false);
const continentMap = {
'Japan': 'Asia', 'South Korea': 'Asia', 'China': 'Asia', 'Thailand': 'Asia',
'Vietnam': 'Asia', 'Indonesia': 'Asia', 'Malaysia': 'Asia', 'Singapore': 'Asia',
'India': 'Asia', 'Taiwan': 'Asia', 'Philippines': 'Asia', 'Cambodia': 'Asia',
'Nepal': 'Asia', 'Bangladesh': 'Asia',
'France': 'Europe', 'Spain': 'Europe', 'Italy': 'Europe', 'Germany': 'Europe',
'UK': 'Europe', 'Netherlands': 'Europe', 'Portugal': 'Europe', 'Greece': 'Europe',
'Sweden': 'Europe', 'Norway': 'Europe', 'Denmark': 'Europe', 'Finland': 'Europe',
'Switzerland': 'Europe', 'Austria': 'Europe', 'Belgium': 'Europe', 'Poland': 'Europe',
'Czech Republic': 'Europe', 'Hungary': 'Europe', 'Croatia': 'Europe', 'Turkey': 'Europe',
'USA': 'N. America', 'Canada': 'N. America', 'Mexico': 'N. America',
'Brazil': 'S. America', 'Argentina': 'S. America', 'Chile': 'S. America',
'Peru': 'S. America', 'Colombia': 'S. America',
'Australia': 'Oceania', 'New Zealand': 'Oceania',
'Morocco': 'Africa', 'Egypt': 'Africa', 'Kenya': 'Africa', 'South Africa': 'Africa',
};
const flightHoursMap = {
'Japan': 13, 'South Korea': 13, 'China': 12, 'Thailand': 11, 'Vietnam': 12,
'Indonesia': 14, 'Malaysia': 11, 'Singapore': 11, 'India': 9, 'Taiwan': 13,
'France': 9, 'Spain': 10, 'Italy': 10, 'Germany': 9, 'UK': 8, 'Netherlands': 9,
'Portugal': 9, 'Greece': 11, 'Sweden': 10, 'Norway': 9, 'Switzerland': 9,
'Turkey': 11, 'Austria': 10, 'Belgium': 9, 'Poland': 10,
'USA': 14, 'Canada': 13, 'Mexico': 13,
'Brazil': 10, 'Argentina': 12, 'Chile': 13,
'Australia': 20, 'New Zealand': 23,
'Morocco': 10, 'Egypt': 12, 'Kenya': 14, 'South Africa': 16,
};
let stats = $derived.by(() => {
if (entries.length === 0) return null;
const totalDays = entries.reduce((s, e) => s + e.days, 0);
const countries = [...new Set(entries.map(e => e.location.country))];
const cities = [...new Set(entries.flatMap(e => e.location.cities))];
// Continent days
const contDays = {};
for (const e of entries) {
const cont = continentMap[e.location.country] ?? 'Other';
contDays[cont] = (contDays[cont] ?? 0) + e.days;
}
const topContinent = Object.entries(contDays).sort((a, b) => b[1] - a[1])[0];
// Longest trip
const longest = [...entries].sort((a, b) => b.days - a.days)[0];
// Date range
const dates = entries.map(e => new Date(e.date));
const firstDate = new Date(Math.min(...dates));
const lastDate = new Date(Math.max(...dates));
const spanDays = Math.round((lastDate - firstDate) / 86400000);
const spanMonths = Math.round(spanDays / 30);
// Flight hours estimate
const flightTrips = entries.filter(e => e.transport === 'flight');
const flightHrs = flightTrips.reduce((s, e) => s + (flightHoursMap[e.location.country] ?? 10), 0);
// Solo vs friends
const soloCount = entries.filter(e => e.tripType === 'solo').length;
const friendCount = entries.filter(e => e.tripType === 'friends').length;
const familyCount = entries.filter(e => e.tripType === 'family').length;
// Most visited country
const countryCounts = {};
for (const e of entries) countryCounts[e.location.country] = (countryCounts[e.location.country] ?? 0) + 1;
const favCountry = Object.entries(countryCounts).sort((a, b) => b[1] - a[1])[0];
const yearStart = firstDate.getFullYear();
const yearEnd = lastDate.getFullYear();
return {
totalDays, countries, cities, contDays, topContinent,
longest, flightHrs, soloCount, friendCount, familyCount,
favCountry, spanMonths, yearStart, yearEnd,
};
});
async function download() {
if (!cardEl) return;
downloading = true;
try {
const dataUrl = await toPng(cardEl, { pixelRatio: 3 });
const a = document.createElement('a');
a.download = 'my-journey.png';
a.href = dataUrl;
a.click();
} finally {
downloading = false;
}
}
function fmtYear(y1, y2) {
return y1 === y2 ? `${y1}` : `${y1} ${y2}`;
}
</script>
<!-- Overlay -->
<div class="overlay" role="dialog" aria-modal="true">
<div class="overlay-inner">
<!-- Controls -->
<div class="controls">
<button class="ctrl-btn" onclick={onClose}>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
<path d="M18 6 6 18M6 6l12 12"/>
</svg>
Close
</button>
<button class="ctrl-btn ctrl-btn--primary" onclick={download} disabled={downloading}>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"/>
</svg>
{downloading ? 'Saving…' : 'Save as PNG'}
</button>
</div>
<!-- The card (Instagram story 9:16) -->
{#if stats}
<div class="card-wrap">
<div class="card" bind:this={cardEl}>
<!-- Background layers -->
<div class="bg-gradient"></div>
<div class="bg-grid"></div>
<!-- Header -->
<div class="card-header">
<span class="card-brand">MAP JOURNAL</span>
<span class="card-year">{fmtYear(stats.yearStart, stats.yearEnd)}</span>
</div>
<!-- Hero stat -->
<div class="hero">
<p class="hero-num">{stats.totalDays}</p>
<p class="hero-label">days of travel</p>
</div>
<!-- Stat grid -->
<div class="stat-grid">
<div class="stat-box">
<p class="stat-num">{stats.countries.length}</p>
<p class="stat-desc">countries</p>
</div>
<div class="stat-box">
<p class="stat-num">{stats.cities.length}</p>
<p class="stat-desc">cities</p>
</div>
<div class="stat-box">
<p class="stat-num">{stats.flightHrs}h</p>
<p class="stat-desc">in the air</p>
</div>
<div class="stat-box">
<p class="stat-num">{Object.keys(stats.contDays).length}</p>
<p class="stat-desc">continents</p>
</div>
</div>
<!-- Fun facts -->
<div class="facts">
{#if stats.topContinent}
<div class="fact">
<span class="fact-icon">🌏</span>
<span class="fact-text">Spent <strong>{stats.topContinent[1]} days</strong> in {stats.topContinent[0]}</span>
</div>
{/if}
{#if stats.longest}
<div class="fact">
<span class="fact-icon">📍</span>
<span class="fact-text">Longest stay: <strong>{stats.longest.days} days</strong> in {stats.longest.location.cities.join(', ')}</span>
</div>
{/if}
{#if stats.flightHrs > 0}
<div class="fact">
<span class="fact-icon">✈️</span>
<span class="fact-text">~<strong>{stats.flightHrs} hrs</strong> crossing skies</span>
</div>
{/if}
{#if stats.favCountry && stats.favCountry[1] > 1}
<div class="fact">
<span class="fact-icon">❤️</span>
<span class="fact-text">Kept coming back to <strong>{stats.favCountry[0]}</strong></span>
</div>
{/if}
<div class="fact">
<span class="fact-icon">{stats.soloCount >= stats.friendCount ? '🧳' : '👥'}</span>
<span class="fact-text">{stats.soloCount} solo{stats.friendCount > 0 ? ` · ${stats.friendCount} with friends` : ''}{stats.familyCount > 0 ? ` · ${stats.familyCount} with family` : ''}</span>
</div>
</div>
<!-- Continent bar -->
{#if Object.keys(stats.contDays).length > 0}
<div class="cont-section">
<div class="cont-bar">
{#each Object.entries(stats.contDays).sort((a,b)=>b[1]-a[1]) as [cont, days]}
<div class="cont-seg" style="flex:{days}; background: var(--cont-{cont.replace('. ','').toLowerCase().replace(' ','-')}, #818cf8)"
title="{cont}: {days}d"></div>
{/each}
</div>
<div class="cont-legend">
{#each Object.entries(stats.contDays).sort((a,b)=>b[1]-a[1]) as [cont, days]}
<span class="cont-item">
<span class="cont-dot" style="background: var(--cont-{cont.replace('. ','').toLowerCase().replace(' ','-')}, #818cf8)"></span>
{cont} {days}d
</span>
{/each}
</div>
</div>
{/if}
<!-- Footer -->
<div class="card-footer">
<span>mapjournal.app</span>
</div>
</div>
</div>
{/if}
</div>
</div>
<style>
/* ── Overlay ── */
.overlay {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.7);
z-index: 200;
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
backdrop-filter: blur(4px);
}
.overlay-inner {
display: flex;
flex-direction: column;
align-items: center;
gap: 16px;
height: 100%;
overflow-y: auto;
}
/* ── Controls ── */
.controls {
display: flex;
gap: 10px;
flex-shrink: 0;
}
.ctrl-btn {
display: inline-flex;
align-items: center;
gap: 7px;
font-family: var(--sans);
font-size: 13px;
font-weight: 400;
padding: 8px 18px;
border-radius: 8px;
border: 1px solid rgba(255,255,255,0.2);
background: rgba(255,255,255,0.1);
color: #fff;
cursor: pointer;
transition: background 0.15s;
}
.ctrl-btn:hover { background: rgba(255,255,255,0.18); }
.ctrl-btn--primary {
background: #7c3aed;
border-color: #7c3aed;
}
.ctrl-btn--primary:hover { background: #6d28d9; }
.ctrl-btn:disabled { opacity: 0.6; cursor: default; }
/* ── Card wrap (scrollable preview) ── */
.card-wrap {
flex-shrink: 0;
}
/* ── Card itself (Instagram story 9:16 → 360×640 preview) ── */
.card {
width: 360px;
min-height: 640px;
border-radius: 20px;
overflow: hidden;
position: relative;
display: flex;
flex-direction: column;
padding: 32px 28px 24px;
gap: 0;
font-family: 'Bricolage Grotesque', system-ui, sans-serif;
background: #0f0a1e;
color: #fff;
/* continent color vars */
--cont-asia: #f87171;
--cont-europe: #818cf8;
--cont-africa: #fb923c;
--cont-namerica: #4ade80;
--cont-n-america: #4ade80;
--cont-samerica: #fbbf24;
--cont-s-america: #fbbf24;
--cont-oceania: #c084fc;
}
/* Backgrounds */
.bg-gradient {
position: absolute;
inset: 0;
background:
radial-gradient(ellipse 60% 40% at 80% 10%, rgba(124,58,237,0.35) 0%, transparent 70%),
radial-gradient(ellipse 50% 50% at 10% 80%, rgba(99,102,241,0.25) 0%, transparent 60%);
pointer-events: none;
}
.bg-grid {
position: absolute;
inset: 0;
background-image:
linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
background-size: 32px 32px;
pointer-events: none;
}
/* Header */
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 36px;
position: relative;
z-index: 1;
}
.card-brand {
font-size: 9px;
font-weight: 500;
letter-spacing: 0.22em;
color: #a5b4fc;
}
.card-year {
font-size: 11px;
font-weight: 300;
color: rgba(255,255,255,0.4);
letter-spacing: 0.06em;
}
/* Hero */
.hero {
position: relative;
z-index: 1;
margin-bottom: 28px;
}
.hero-num {
font-size: 88px;
font-weight: 400;
line-height: 1;
letter-spacing: -4px;
color: #fff;
}
.hero-label {
font-size: 16px;
font-weight: 300;
color: #a5b4fc;
letter-spacing: 0.04em;
margin-top: 4px;
}
/* Stat grid */
.stat-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 8px;
margin-bottom: 24px;
position: relative;
z-index: 1;
}
.stat-box {
background: rgba(255,255,255,0.05);
border: 1px solid rgba(255,255,255,0.08);
border-radius: 10px;
padding: 10px 8px;
text-align: center;
}
.stat-num {
font-size: 22px;
font-weight: 400;
color: #fff;
letter-spacing: -0.5px;
line-height: 1;
margin-bottom: 4px;
}
.stat-desc {
font-size: 9px;
font-weight: 400;
color: rgba(255,255,255,0.4);
text-transform: uppercase;
letter-spacing: 0.1em;
}
/* Facts */
.facts {
display: flex;
flex-direction: column;
gap: 10px;
margin-bottom: 24px;
position: relative;
z-index: 1;
}
.fact {
display: flex;
align-items: center;
gap: 10px;
background: rgba(255,255,255,0.04);
border: 1px solid rgba(255,255,255,0.07);
border-radius: 10px;
padding: 10px 14px;
}
.fact-icon { font-size: 16px; flex-shrink: 0; }
.fact-text {
font-size: 12px;
font-weight: 300;
color: rgba(255,255,255,0.7);
line-height: 1.4;
}
.fact-text strong { color: #fff; font-weight: 400; }
/* Continent bar */
.cont-section {
position: relative;
z-index: 1;
margin-bottom: 20px;
}
.cont-bar {
display: flex;
height: 6px;
border-radius: 3px;
overflow: hidden;
gap: 2px;
margin-bottom: 8px;
}
.cont-seg { border-radius: 3px; min-width: 4px; }
.cont-legend {
display: flex;
flex-wrap: wrap;
gap: 6px 12px;
}
.cont-item {
display: inline-flex;
align-items: center;
gap: 4px;
font-size: 9px;
font-weight: 300;
color: rgba(255,255,255,0.5);
letter-spacing: 0.04em;
}
.cont-dot {
width: 6px;
height: 6px;
border-radius: 50%;
flex-shrink: 0;
}
/* Footer */
.card-footer {
margin-top: auto;
padding-top: 16px;
border-top: 1px solid rgba(255,255,255,0.08);
font-size: 9px;
font-weight: 300;
color: rgba(255,255,255,0.25);
letter-spacing: 0.12em;
text-transform: uppercase;
position: relative;
z-index: 1;
}
</style>

View File

@@ -0,0 +1,235 @@
<script>
/** @type {{ entries: import('../stores/journalStore.js').JournalEntry[], onClick: () => void }} */
let { entries, onClick } = $props();
const continentMap = {
'Japan':'Asia','South Korea':'Asia','China':'Asia','Thailand':'Asia','Vietnam':'Asia',
'Indonesia':'Asia','Malaysia':'Asia','Singapore':'Asia','India':'Asia','Taiwan':'Asia',
'Philippines':'Asia','Cambodia':'Asia','Nepal':'Asia',
'France':'Europe','Spain':'Europe','Italy':'Europe','Germany':'Europe','UK':'Europe',
'Netherlands':'Europe','Portugal':'Europe','Greece':'Europe','Sweden':'Europe',
'Norway':'Europe','Denmark':'Europe','Finland':'Europe','Switzerland':'Europe',
'Austria':'Europe','Belgium':'Europe','Poland':'Europe','Czech Republic':'Europe',
'Hungary':'Europe','Croatia':'Europe','Turkey':'Europe',
'USA':'N. America','Canada':'N. America','Mexico':'N. America',
'Brazil':'S. America','Argentina':'S. America','Chile':'S. America','Peru':'S. America',
'Australia':'Oceania','New Zealand':'Oceania',
'Morocco':'Africa','Egypt':'Africa','Kenya':'Africa','South Africa':'Africa',
};
const continentColors = {
'Asia':'#f87171','Europe':'#818cf8','N. America':'#4ade80',
'S. America':'#fbbf24','Africa':'#fb923c','Oceania':'#c084fc',
};
let stats = $derived.by(() => {
const totalDays = entries.reduce((s, e) => s + e.days, 0);
const countries = [...new Set(entries.map(e => e.location.country))];
const contDays = {};
for (const e of entries) {
const c = continentMap[e.location.country] ?? 'Other';
contDays[c] = (contDays[c] ?? 0) + e.days;
}
const top = Object.entries(contDays).sort((a, b) => b[1] - a[1]);
return { totalDays, countries, contDays, top, trips: entries.length };
});
</script>
<button class="preview-card" onclick={onClick} aria-label="Share your journey">
<div class="pc-bg"></div>
<div class="pc-grid-pattern"></div>
<div class="pc-header">
<span class="pc-brand">MAP JOURNAL</span>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" class="pc-share-icon">
<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/>
<path d="m8.59 13.51 6.83 3.98M15.41 6.51l-6.82 3.98"/>
</svg>
</div>
<div class="pc-hero">
<span class="pc-num">{stats.totalDays}</span>
<span class="pc-label">days traveled</span>
</div>
<div class="pc-row">
<div class="pc-stat">
<span class="pc-stat-num">{stats.countries.length}</span>
<span class="pc-stat-label">countries</span>
</div>
<div class="pc-stat">
<span class="pc-stat-num">{stats.trips}</span>
<span class="pc-stat-label">trips</span>
</div>
<div class="pc-stat">
<span class="pc-stat-num">{Object.keys(stats.contDays).length}</span>
<span class="pc-stat-label">continents</span>
</div>
</div>
{#if stats.top.length > 0}
<div class="pc-bar-wrap">
<div class="pc-bar">
{#each stats.top as [cont, days]}
<div class="pc-seg" style="flex:{days}; background:{continentColors[cont] ?? '#818cf8'}"></div>
{/each}
</div>
<div class="pc-bar-labels">
{#each stats.top.slice(0,3) as [cont, days]}
<span class="pc-bar-label" style="color:{continentColors[cont] ?? '#818cf8'}">{cont}</span>
{/each}
</div>
</div>
{/if}
<div class="pc-cta">Share your journey →</div>
</button>
<style>
.preview-card {
position: sticky;
top: 40px;
width: 100%;
background: #1a1630;
border-radius: 12px;
overflow: hidden;
color: #fff;
cursor: pointer;
border: 1px solid rgba(255,255,255,0.06);
text-align: left;
padding: 16px;
display: flex;
flex-direction: column;
gap: 12px;
transition: transform 0.15s, box-shadow 0.15s;
box-shadow: 0 2px 12px rgba(0,0,0,0.08);
font-family: var(--sans);
}
.preview-card:hover {
transform: translateY(-1px);
box-shadow: 0 4px 20px rgba(124,58,237,0.12);
}
.pc-bg {
position: absolute;
inset: 0;
background:
radial-gradient(ellipse 80% 60% at 90% 0%, rgba(124,58,237,0.2) 0%, transparent 60%),
radial-gradient(ellipse 60% 60% at 0% 100%, rgba(99,102,241,0.1) 0%, transparent 60%);
pointer-events: none;
}
.pc-grid-pattern {
position: absolute;
inset: 0;
background-image:
linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
background-size: 24px 24px;
pointer-events: none;
}
.pc-header {
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
z-index: 1;
}
.pc-brand {
font-size: 8px;
font-weight: 500;
letter-spacing: 0.2em;
color: #a5b4fc;
}
.pc-share-icon { color: #a5b4fc; flex-shrink: 0; }
.pc-hero {
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
gap: 2px;
}
.pc-num {
font-size: 40px;
font-weight: 400;
line-height: 1;
letter-spacing: -1.5px;
color: #fff;
}
.pc-label {
font-size: 11px;
font-weight: 300;
color: #a5b4fc;
letter-spacing: 0.04em;
}
.pc-row {
display: flex;
gap: 0;
position: relative;
z-index: 1;
}
.pc-stat {
flex: 1;
display: flex;
flex-direction: column;
gap: 2px;
padding-right: 12px;
border-right: 1px solid rgba(255,255,255,0.08);
}
.pc-stat:last-child { border-right: none; padding-right: 0; padding-left: 12px; }
.pc-stat:not(:first-child):not(:last-child) { padding-left: 12px; }
.pc-stat-num {
font-size: 16px;
font-weight: 400;
color: #fff;
letter-spacing: -0.5px;
line-height: 1;
}
.pc-stat-label {
font-size: 9px;
font-weight: 300;
color: rgba(255,255,255,0.4);
text-transform: uppercase;
letter-spacing: 0.1em;
}
.pc-bar-wrap {
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
gap: 6px;
}
.pc-bar {
display: flex;
height: 4px;
border-radius: 2px;
overflow: hidden;
gap: 2px;
}
.pc-seg { border-radius: 2px; min-width: 3px; }
.pc-bar-labels {
display: flex;
gap: 10px;
}
.pc-bar-label {
font-size: 9px;
font-weight: 300;
letter-spacing: 0.04em;
}
.pc-cta {
position: relative;
z-index: 1;
font-size: 11px;
font-weight: 400;
color: #a5b4fc;
letter-spacing: 0.04em;
padding-top: 4px;
border-top: 1px solid rgba(255,255,255,0.08);
}
</style>

View File

@@ -1,28 +1,9 @@
<script> <script>
import { flagEmoji } from '../shared/countries.js';
/** @type {{ entry: import('../stores/journalStore.js').JournalEntry, onClick: () => void }} */ /** @type {{ entry: import('../stores/journalStore.js').JournalEntry, onClick: () => void }} */
let { entry, onClick } = $props(); let { entry, onClick } = $props();
/** Convert country name to flag emoji via ISO 3166-1 alpha-2 */
const countryCodeMap = {
'Japan': 'JP', 'France': 'FR', 'Spain': 'ES', 'USA': 'US',
'Thailand': 'TH', 'Germany': 'DE', 'Italy': 'IT', 'UK': 'GB',
'Australia': 'AU', 'Canada': 'CA', 'China': 'CN', 'India': 'IN',
'Brazil': 'BR', 'Mexico': 'MX', 'Portugal': 'PT', 'Netherlands': 'NL',
'Greece': 'GR', 'Turkey': 'TR', 'Vietnam': 'VN', 'Indonesia': 'ID',
'Malaysia': 'MY', 'Singapore': 'SG', 'South Korea': 'KR', 'Taiwan': 'TW',
'New Zealand': 'NZ', 'Argentina': 'AR', 'Chile': 'CL', 'Peru': 'PE',
'Morocco': 'MA', 'Egypt': 'EG', 'Kenya': 'KE', 'South Africa': 'ZA',
'Sweden': 'SE', 'Norway': 'NO', 'Denmark': 'DK', 'Finland': 'FI',
'Switzerland': 'CH', 'Austria': 'AT', 'Belgium': 'BE', 'Poland': 'PL',
'Czech Republic': 'CZ', 'Hungary': 'HU', 'Croatia': 'HR',
};
function flagEmoji(country) {
const code = countryCodeMap[country];
if (!code) return '';
return [...code].map(c => String.fromCodePoint(0x1F1E6 - 65 + c.charCodeAt(0))).join('');
}
function formatDate(/** @type {string} */ iso) { function formatDate(/** @type {string} */ iso) {
return new Date(iso).toLocaleDateString('en-US', { return new Date(iso).toLocaleDateString('en-US', {
month: 'short', day: 'numeric', year: 'numeric', month: 'short', day: 'numeric', year: 'numeric',
@@ -32,6 +13,16 @@
let mainPhoto = $derived(entry.photos[0] ?? null); let mainPhoto = $derived(entry.photos[0] ?? null);
let thumbPhotos = $derived(entry.photos.slice(1, 4)); let thumbPhotos = $derived(entry.photos.slice(1, 4));
let extraCount = $derived(entry.photos.length > 4 ? entry.photos.length - 4 : 0); let extraCount = $derived(entry.photos.length > 4 ? entry.photos.length - 4 : 0);
const transportIcons = {
flight: `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07A19.5 19.5 0 0 1 4.18 10a19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 3.09 0h3a2 2 0 0 1 2 1.72c.127.96.361 1.903.7 2.81a2 2 0 0 1-.45 2.11L7.09 8a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0 1 21 15z"/></svg>`,
train: `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="2" width="16" height="16" rx="2"/><path d="M4 12h16M8 20l-2 2M16 20l2 2M12 12v6"/><circle cx="8.5" cy="7.5" r="1"/><circle cx="15.5" cy="7.5" r="1"/></svg>`,
bus: `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 6v6M15 6v6M2 12h19.6M18 18h2a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h2m0 0v2m8-2v2M6 18h12"/><circle cx="8" cy="18" r="2"/><circle cx="16" cy="18" r="2"/></svg>`,
car: `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M5 17H3a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v9a2 2 0 0 1-2 2h-2"/><circle cx="7.5" cy="17.5" r="2.5"/><circle cx="17.5" cy="17.5" r="2.5"/></svg>`,
ship: `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M2 21c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1 .6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"/><path d="M19.38 20A11.6 11.6 0 0 0 21 14l-9-4-9 4c0 2.9.94 5.34 2.81 7.76"/><path d="M19 13V7a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v6"/><path d="M12 10v4"/><path d="M12 3v4"/></svg>`,
walk: `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="4" r="2"/><path d="m9 22 1-7-2.5-2.5L9 9l6 1-1 4.5L16 22"/><path d="M6.5 11.5 4 12l2 6"/><path d="M17.5 11.5 20 12l-2 6"/></svg>`,
};
let transportLabel = $derived({ flight: 'Flight', train: 'Train', bus: 'Bus', car: 'Car', ship: 'Ship', walk: 'Walk' }[entry.transport] ?? '');
</script> </script>
<li class="v-item"> <li class="v-item">
@@ -51,7 +42,7 @@
<!-- Trip badge — top-right of card, outside photo --> <!-- Trip badge — top-right of card, outside photo -->
<span class="trip-badge trip-badge--{entry.tripType}"> <span class="trip-badge trip-badge--{entry.tripType}">
{entry.tripType === 'solo' ? 'Solo' : 'Friends'} {entry.tripType === 'solo' ? 'Solo' : entry.tripType === 'family' ? 'Family' : 'Friends'}
</span> </span>
<!-- Photos --> <!-- Photos -->
@@ -108,8 +99,15 @@
<!-- Info bar --> <!-- Info bar -->
<div class="card-info"> <div class="card-info">
<span class="city">{entry.location.city}</span> <span class="city">{entry.location.cities.join(', ')}</span>
<div class="meta"> <div class="meta">
{#if entry.transport}
<span class="transport-chip transport-chip--{entry.transport}">
{@html transportIcons[entry.transport] ?? ''}
{transportLabel}
</span>
<span class="dot-sep">·</span>
{/if}
<span>{formatDate(entry.date)}</span> <span>{formatDate(entry.date)}</span>
<span class="dot-sep">·</span> <span class="dot-sep">·</span>
<span>{entry.days} {entry.days === 1 ? 'day' : 'days'}</span> <span>{entry.days} {entry.days === 1 ? 'day' : 'days'}</span>
@@ -126,7 +124,7 @@
display: flex; display: flex;
gap: 14px; gap: 14px;
align-items: flex-start; align-items: flex-start;
padding-bottom: 28px; padding-bottom: 48px;
position: relative; position: relative;
} }
.v-item:last-child { padding-bottom: 0; } .v-item:last-child { padding-bottom: 0; }
@@ -208,6 +206,7 @@
} }
.trip-badge--solo { background: rgba(245,158,11,0.85); color: #fff; } .trip-badge--solo { background: rgba(245,158,11,0.85); color: #fff; }
.trip-badge--friends { background: rgba(124,58,237,0.85); color: #fff; } .trip-badge--friends { background: rgba(124,58,237,0.85); color: #fff; }
.trip-badge--family { background: rgba(16,185,129,0.85); color: #fff; }
/* ── Photo grid — fixed height, always consistent ── */ /* ── Photo grid — fixed height, always consistent ── */
.photo-grid { .photo-grid {
@@ -317,4 +316,23 @@
flex-shrink: 0; flex-shrink: 0;
} }
.dot-sep { color: var(--border-bright); } .dot-sep { color: var(--border-bright); }
.transport-chip {
display: inline-flex;
align-items: center;
gap: 4px;
font-size: 11px;
font-weight: 400;
padding: 2px 7px;
border-radius: 20px;
border: 1px solid var(--border);
background: var(--bg-subtle);
color: var(--text-sub);
}
.transport-chip--flight { color: #7c3aed; background: rgba(124,58,237,0.07); border-color: rgba(124,58,237,0.2); }
.transport-chip--train { color: #0369a1; background: rgba(3,105,161,0.07); border-color: rgba(3,105,161,0.2); }
.transport-chip--bus { color: #15803d; background: rgba(21,128,61,0.07); border-color: rgba(21,128,61,0.2); }
.transport-chip--car { color: #b45309; background: rgba(180,83,9,0.07); border-color: rgba(180,83,9,0.2); }
.transport-chip--ship { color: #0e7490; background: rgba(14,116,144,0.07); border-color: rgba(14,116,144,0.2); }
.transport-chip--walk { color: #65a30d; background: rgba(101,163,13,0.07); border-color: rgba(101,163,13,0.2); }
</style> </style>

View File

@@ -9,34 +9,12 @@
let { sortKey, onSort } = $props(); let { sortKey, onSort } = $props();
</script> </script>
<header class="toolbar"> <div class="toolbar"></div>
<h1 class="page-title">My Journey</h1>
<div class="sort-control">
<select id="sort-select" onchange={(e) => onSort(e.currentTarget.value)}>
{#each sortOptions as opt}
<option value={opt.value} selected={opt.value === sortKey}>{opt.label}</option>
{/each}
</select>
</div>
</header>
<style> <style>
.toolbar { .toolbar {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 16px;
margin-bottom: 32px;
padding-bottom: 24px;
border-bottom: 1px solid var(--border); border-bottom: 1px solid var(--border);
} margin-bottom: 0;
.page-title {
font-size: var(--text-xl);
font-weight: 400;
color: var(--text-h);
letter-spacing: -0.5px;
margin: 0;
} }
select { select {

View File

@@ -4,10 +4,26 @@
import TimelineToolbar from './TimelineToolbar.svelte'; import TimelineToolbar from './TimelineToolbar.svelte';
import TimelineCard from './TimelineCard.svelte'; import TimelineCard from './TimelineCard.svelte';
import JournalDetail from './JournalDetail.svelte'; import JournalDetail from './JournalDetail.svelte';
import JournalSummary from './JournalSummary.svelte'; import EditForm from './EditForm.svelte';
import ShareCard from './ShareCard.svelte';
import SharePreview from './SharePreview.svelte';
/** @type {import('../stores/journalStore.js').JournalEntry|null} */ let { onDetailChange = () => {}, pendingCountry = '', onNewEntryClear = () => {} } = $props();
let selected = $state(null); let selectedId = $state(/** @type {string|null} */(null));
let view = $state(/** @type {'list'|'detail'|'edit'|'new'} */('list'));
let showShare = $state(false);
let newEntryCountry = $state('');
// When App passes a country from the map, capture it locally before clearing
$effect(() => {
if (pendingCountry) {
newEntryCountry = pendingCountry;
selectedId = null;
view = 'new';
onNewEntryClear();
}
});
let selected = $derived(selectedId ? (entries.find(e => e.id === selectedId) ?? null) : null);
let entries = $state(get(journals)); let entries = $state(get(journals));
$effect(() => { $effect(() => {
@@ -36,43 +52,84 @@
<div class="journal-page"> <div class="journal-page">
{#if selected} {#if view === 'new'}
<div class="detail-scroll"> <div class="detail-scroll">
<JournalDetail entry={selected} onBack={() => (selected = null)} /> <EditForm initialCountry={newEntryCountry} onBack={() => { view = 'list'; newEntryCountry = ''; onDetailChange(false); }} />
</div>
{:else if view === 'edit' && selected}
<div class="detail-scroll">
<EditForm entry={selected} onBack={() => { view = 'detail'; }} />
</div>
{:else if view === 'detail' && selected}
<div class="detail-scroll">
<JournalDetail
entry={selected}
onBack={() => { selectedId = null; view = 'list'; onDetailChange(false); }}
onEdit={() => { view = 'edit'; }}
/>
</div> </div>
{:else} {:else}
<aside class="left-panel">
<JournalSummary entries={sortedEntries} />
</aside>
<div class="right-panel"> <div class="right-panel">
<div class="right-inner"> <div class="two-col">
<TimelineToolbar {sortKey} onSort={(k) => (sortKey = k)} /> <!-- Timeline column -->
<div class="timeline-col">
<div class="page-header">
<h1 class="page-title">My Journey</h1>
<button class="new-btn" onclick={() => { view = 'new'; }}>
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round">
<path d="M12 5v14M5 12h14"/>
</svg>
New entry
</button>
</div>
{#if sortedEntries.length === 0} <TimelineToolbar {sortKey} onSort={(k) => (sortKey = k)} />
<p class="empty">No journal entries yet.</p>
{:else} {#if sortedEntries.length === 0}
<ol class="v-list"> <p class="empty">No journal entries yet.</p>
{#each sortedEntries as entry, i (entry.id)} {:else}
{#if i === 0 || getYear(entry.date) !== getYear(sortedEntries[i - 1].date)} <div class="sort-row">
<li class="year-marker" aria-hidden="true"> <span class="sort-label">Sort by</span>
<span class="year-label">{getYear(entry.date)}</span> <select class="sort-select" onchange={(e) => (sortKey = e.currentTarget.value)}>
</li> <option value="date-desc" selected={sortKey === 'date-desc'}>Newest first</option>
{/if} <option value="date-asc" selected={sortKey === 'date-asc'}>Oldest first</option>
<TimelineCard {entry} onClick={() => (selected = entry)} /> <option value="country-asc" selected={sortKey === 'country-asc'}>Country A Z</option>
{/each} <option value="country-desc" selected={sortKey === 'country-desc'}>Country Z A</option>
</ol> </select>
</div>
<ol class="v-list">
{#each sortedEntries as entry, i (entry.id)}
{#if i === 0 || getYear(entry.date) !== getYear(sortedEntries[i - 1].date)}
<li class="year-marker" aria-hidden="true">
<span class="year-label">{getYear(entry.date)}</span>
</li>
{/if}
<TimelineCard {entry} onClick={() => { selectedId = entry.id; view = 'detail'; onDetailChange(true); }} />
{/each}
</ol>
{/if}
<footer class="page-footer">
{sortedEntries.length} {sortedEntries.length === 1 ? 'entry' : 'entries'}
</footer>
</div>
<!-- Share preview column -->
{#if sortedEntries.length > 0}
<div class="share-col">
<SharePreview entries={sortedEntries} onClick={() => (showShare = true)} />
</div>
{/if} {/if}
<footer class="page-footer">
{sortedEntries.length} {sortedEntries.length === 1 ? 'entry' : 'entries'}
</footer>
</div> </div>
</div> </div>
{/if} {/if}
</div> </div>
{#if showShare}
<ShareCard entries={sortedEntries} onClose={() => (showShare = false)} />
{/if}
<style> <style>
.journal-page { .journal-page {
flex: 1; flex: 1;
@@ -83,16 +140,6 @@
overflow: hidden; overflow: hidden;
} }
/* ── Left panel ── */
.left-panel {
width: 260px;
flex-shrink: 0;
overflow-y: auto;
border-right: 1px solid var(--border);
background: var(--bg-raised);
padding: 40px 28px;
}
/* ── Right panel ── */ /* ── Right panel ── */
.right-panel { .right-panel {
flex: 1; flex: 1;
@@ -101,24 +148,30 @@
background: var(--bg); background: var(--bg);
} }
/* Inner container with max-width + generous side padding */ /* ── Two-column layout ── */
.right-inner { .two-col {
max-width: 640px; display: grid;
grid-template-columns: 1fr 240px;
gap: 48px;
max-width: 1020px;
width: 100%;
margin: 0 auto; margin: 0 auto;
padding: 40px 48px 80px; padding: 48px 48px 80px;
align-items: start;
box-sizing: border-box;
} }
.timeline-col { min-width: 0; }
.share-col { padding-top: 60px; }
/* ── Responsive: narrow viewport ── */ /* ── Responsive: narrow viewport ── */
@media (max-width: 700px) { @media (max-width: 860px) {
.journal-page { flex-direction: column; overflow-y: auto; overflow-x: hidden; } .two-col {
.left-panel { grid-template-columns: 1fr;
width: 100%; padding: 32px 24px 60px;
border-right: none;
border-bottom: 1px solid var(--border);
padding: 24px 20px;
} }
.right-panel { overflow-y: unset; } .share-col { padding-top: 0; }
.right-inner { padding: 24px 20px 60px; }
} }
/* ── Detail view ── */ /* ── Detail view ── */
@@ -140,16 +193,15 @@
/* Year marker */ /* Year marker */
.year-marker { .year-marker {
padding: 32px 0 14px; padding: 24px 0 14px;
} }
.year-label { .year-label {
font-size: 13px; font-size: 18px;
font-weight: 400; font-weight: 600;
letter-spacing: 0.1em; letter-spacing: 0.04em;
text-transform: uppercase; color: #7c3aed;
color: var(--text); border-left: 3px solid #7c3aed;
border-left: 2px solid var(--accent); padding-left: 12px;
padding-left: 10px;
} }
.page-footer { .page-footer {
@@ -165,4 +217,106 @@
} }
.empty { text-align: center; color: var(--text-sub); padding: 80px 0; } .empty { text-align: center; color: var(--text-sub); padding: 80px 0; }
.sort-row {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 8px;
margin-bottom: 8px;
padding-top: 20px;
}
.sort-label {
font-size: 11px;
font-weight: 400;
letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--text-sub);
}
.sort-select {
font-family: var(--sans);
font-size: 11px;
font-weight: 300;
letter-spacing: 0.04em;
padding: 4px 24px 4px 10px;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--bg-subtle);
color: var(--text);
cursor: pointer;
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2352525b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 8px center;
}
.sort-select:hover { border-color: var(--border-bright); color: var(--text-h); }
.page-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16px;
}
.page-title {
font-size: var(--text-xl);
font-weight: 400;
color: var(--text-h);
letter-spacing: -0.5px;
margin: 0;
}
.new-btn {
display: inline-flex;
align-items: center;
gap: 6px;
font-family: var(--sans);
font-size: 13px;
font-weight: 300;
color: #fff;
background: var(--accent);
border: 1px solid var(--accent);
border-radius: 8px;
padding: 7px 14px;
cursor: pointer;
transition: background 0.15s;
white-space: nowrap;
flex-shrink: 0;
}
.new-btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.share-nudge {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
padding: 10px 14px;
margin-bottom: 12px;
border-radius: 10px;
border: 1px dashed var(--border-bright);
background: var(--bg-subtle);
cursor: pointer;
transition: border-color 0.15s, background 0.15s;
font-family: var(--sans);
text-align: left;
}
.share-nudge:hover {
border-color: var(--accent-light);
background: var(--accent-bg);
}
.nudge-left {
display: inline-flex;
align-items: center;
gap: 7px;
font-size: 13px;
font-weight: 400;
color: var(--text-h);
}
.nudge-right {
font-size: 11px;
font-weight: 300;
color: var(--text-sub);
letter-spacing: 0.02em;
}
.share-nudge:hover .nudge-right { color: var(--accent); }
</style> </style>

View File

@@ -1,16 +1,16 @@
<script> <script>
import { CONTINENTS, getContinent, continentTotals } from './continents.js'; import { CONTINENTS, getContinent, continentTotals } from './continents.js';
import { getSelected, getTotalCount } from '../layout/selection.svelte.js'; import { getSelected } from '../layout/selection.svelte.js';
let collapsed = $state(false); let hoveredSeg = $state(null);
const continentColors = { const continentColors = {
'Europe': '#3b82f6', 'Europe': '#6366f1',
'Asia': '#ef4444', 'Asia': '#f43f5e',
'Africa': '#f97316', 'Africa': '#fb923c',
'N. America': '#22c55e', 'N. America': '#06b6d4',
'S. America': '#eab308', 'S. America': '#f59e0b',
'Oceania': '#a855f7' 'Oceania': '#8b5cf6'
}; };
let counts = $derived.by(() => { let counts = $derived.by(() => {
@@ -36,11 +36,9 @@
if (angle > 0) { if (angle > 0) {
const startDeg = deg; const startDeg = deg;
const endDeg = deg + angle; const endDeg = deg + angle;
const midDeg = (startDeg + endDeg) / 2;
const rad = (midDeg - 90) * Math.PI / 180;
const sr = (startDeg - 90) * Math.PI / 180; const sr = (startDeg - 90) * Math.PI / 180;
const er = (endDeg - 90) * Math.PI / 180; const er = (endDeg - 90) * Math.PI / 180;
const cx = 90, cy = 90, outerR = 65, innerR = 30; const cx = 50, cy = 50, outerR = 44, innerR = 22;
const x1 = cx + outerR * Math.cos(sr); const x1 = cx + outerR * Math.cos(sr);
const y1 = cy + outerR * Math.sin(sr); const y1 = cy + outerR * Math.sin(sr);
const x2 = cx + outerR * Math.cos(er); const x2 = cx + outerR * Math.cos(er);
@@ -51,9 +49,7 @@
const y4 = cy + innerR * Math.sin(sr); const y4 = cy + innerR * Math.sin(sr);
const largeArc = angle > 180 ? 1 : 0; const largeArc = angle > 180 ? 1 : 0;
const path = `M ${x1} ${y1} A ${outerR} ${outerR} 0 ${largeArc} 1 ${x2} ${y2} L ${x3} ${y3} A ${innerR} ${innerR} 0 ${largeArc} 0 ${x4} ${y4} Z`; const path = `M ${x1} ${y1} A ${outerR} ${outerR} 0 ${largeArc} 1 ${x2} ${y2} L ${x3} ${y3} A ${innerR} ${innerR} 0 ${largeArc} 0 ${x4} ${y4} Z`;
const lx = cx + 82 * Math.cos(rad); segs.push({ cont, color: continentColors[cont], path, angle });
const ly = cy + 82 * Math.sin(rad);
segs.push({ cont, color: continentColors[cont], path, lx, ly, angle });
deg += angle; deg += angle;
} }
} }
@@ -61,247 +57,199 @@
}); });
</script> </script>
<div class="panel" class:collapsed> <div class="card">
<button class="collapse-btn" onclick={() => collapsed = !collapsed} data-tip={collapsed ? 'see statistics' : 'close statistics'}> <!-- count -->
{collapsed ? '◀' : '▶'} <div class="stat-block">
</button> <span class="big-num">{total}</span>
<span class="stat-sub">countries visited</span>
</div>
{#if !collapsed} <div class="vdivider"></div>
<div class="panel-content">
<h2 class="headline">your statistics</h2>
<span class="bar-label">visited countries</span> <!-- world % -->
<div class="total-bar-wrap"> <div class="stat-block">
<div class="total-bar-bg"> <span class="big-num accent">{pct}%</span>
<div class="total-bar-fill" style="width: {pct}%"></div> <span class="stat-sub">of the world</span>
</div>
<div class="vdivider"></div>
<!-- donut -->
<div class="donut-block">
<svg viewBox="0 0 100 100" class="donut-svg">
{#if segments.length > 0}
{#each segments as seg}
<g class="seg-group"
onmouseenter={() => hoveredSeg = seg}
onmouseleave={() => hoveredSeg = null}>
<path d={seg.path} fill={seg.color} />
</g>
{/each}
<circle cx="50" cy="50" r="22" fill="#fff" />
{:else}
<circle cx="50" cy="50" r="44" fill="#f1f5f9" />
<circle cx="50" cy="50" r="22" fill="#fff" />
{/if}
</svg>
<div class="donut-info">
<span class="section-label">by continent</span>
{#if hoveredSeg}
<div class="tooltip" style="--dot:{hoveredSeg.color}">
<span class="tt-name">{hoveredSeg.cont}</span>
<span class="tt-val">{counts[hoveredSeg.cont]} / {continentTotals[hoveredSeg.cont]}</span>
</div> </div>
<span class="total-bar-text">{total} / {grandTotal}</span> {:else}
</div> <span class="hint">hover a slice</span>
{/if}
<div class="divider"></div>
<span class="bar-label">by continent</span>
{#each CONTINENTS as continent}
{@const contTotal = continentTotals[continent]}
<div class="row">
<span class="dot" style="background: {continentColors[continent]}"></span>
<span class="label">{continent}</span>
<span class="value">{counts[continent]}<span class="total">/{contTotal}</span></span>
</div>
{/each}
<div class="donut-wrap">
{#if segments.length > 0}
<svg viewBox="0 0 180 180" class="donut-svg">
{#each segments as seg}
<g class="seg-group">
<path d={seg.path} fill={seg.color} />
<text x={seg.lx} y={seg.ly} text-anchor="middle" dominant-baseline="middle" class="donut-label" style="font-size: {seg.angle < 20 ? 12 : 15}px">{seg.cont}</text>
</g>
{/each}
<circle cx="90" cy="90" r="30" fill="var(--bg-raised)" />
</svg>
{:else}
<svg viewBox="0 0 180 180" class="donut-svg">
<circle cx="90" cy="90" r="65" fill="var(--border)" />
<circle cx="90" cy="90" r="30" fill="var(--bg-raised)" />
</svg>
{/if}
</div>
<div class="divider"></div>
<div class="disclaimer">Contains all UN countries, Kosovo, Hong Kong and Taiwan</div>
</div> </div>
{/if} </div>
<div class="vdivider"></div>
<!-- progress bar -->
<div class="bar-block">
<span class="section-label" style="margin-bottom:6px">world coverage</span>
<div class="bar-bg">
<div class="bar-fill" style="width:{pct}%"></div>
</div>
<span class="disclaimer">All UN countries · Kosovo · HK · Taiwan</span>
</div>
</div> </div>
<style> <style>
.panel { .card {
flex: 0 0 min(360px, 25vw); position: absolute;
background: var(--bg-raised); top: 16px;
border-left: 1px solid var(--border); left: 50%;
transform: translateX(-50%);
background: #fff;
border-radius: 16px;
box-shadow: 0 4px 20px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
border: 1px solid rgba(0,0,0,0.06);
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center;
gap: 0;
padding: 0 4px;
height: 110px;
z-index: 10;
font-family: var(--sans); font-family: var(--sans);
transition: flex-basis 0.25s ease; white-space: nowrap;
} }
.panel.collapsed { .stat-block {
flex: 0 0 28px; display: flex;
border-left: none; flex-direction: column;
align-items: center;
gap: 4px;
padding: 0 36px;
} }
.panel-content { .big-num {
flex: 1; font-size: 40px;
padding: 24px 28px; font-weight: 300;
overflow-y: auto; letter-spacing: -2px;
min-width: 0; color: var(--text-h);
}
.collapse-btn {
flex: 0 0 auto;
align-self: flex-start;
background: var(--accent-bg);
border: none;
border-radius: 0 8px 8px 0;
padding: 14px 5px;
cursor: pointer;
font-size: 16px;
line-height: 1; line-height: 1;
color: var(--accent);
transition: background 0.15s ease, padding 0.15s ease;
margin-top: 24px;
position: relative;
} }
.big-num.accent { color: var(--accent); }
.collapse-btn:hover { .stat-sub {
background: var(--lavender-bg);
padding-right: 8px;
}
.collapse-btn::after {
content: attr(data-tip);
position: absolute;
right: calc(100% + 8px);
top: 50%;
transform: translateY(-50%);
background: var(--text-h);
color: var(--bg-raised);
font-family: var(--sans);
font-size: 12px; font-size: 12px;
font-weight: 300; font-weight: 300;
padding: 6px 12px;
border-radius: 6px;
white-space: nowrap;
pointer-events: none;
opacity: 0;
transition: opacity 0.15s ease;
}
.collapse-btn:hover::after {
opacity: 1;
}
.headline {
font-family: var(--heading);
font-size: var(--text-sm);
font-weight: 400;
text-transform: uppercase;
letter-spacing: 0.1em;
color: var(--accent);
margin: 0 0 20px 0;
}
.bar-label {
font-family: var(--sans);
font-size: var(--text-xs);
font-weight: 400;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--text-sub); color: var(--text-sub);
display: block; letter-spacing: 0.03em;
margin-bottom: 8px;
} }
.total-bar-wrap { .vdivider {
display: flex; width: 1px;
align-items: center; height: 56px;
gap: 12px;
margin-bottom: 4px;
}
.total-bar-bg {
flex: 1;
height: 18px;
background: var(--accent-bg);
border-radius: 10px;
overflow: hidden;
}
.total-bar-fill {
height: 100%;
background: linear-gradient(90deg, var(--accent-dark), var(--lavender));
border-radius: 10px;
transition: width 0.3s ease;
min-width: 0;
}
.total-bar-text {
font-size: var(--text-sm);
font-weight: 400;
color: var(--text-h);
white-space: nowrap;
}
.divider {
height: 1px;
background: var(--border); background: var(--border);
margin: 16px 0;
}
.row {
display: flex;
align-items: center;
gap: 8px;
padding: 6px 0;
}
.dot {
width: 12px;
height: 12px;
border-radius: 50%;
flex-shrink: 0; flex-shrink: 0;
} }
.label { /* donut */
flex: 1; .donut-block {
font-size: var(--text-sm);
font-weight: 300;
color: var(--text);
}
.value {
font-size: var(--text-sm);
font-weight: 400;
color: var(--text-h);
}
.total {
font-weight: 400;
color: var(--text-sub);
font-size: var(--text-xs);
}
.donut-wrap {
display: flex; display: flex;
justify-content: center; flex-direction: row;
margin: 20px 0; align-items: center;
gap: 14px;
padding: 0 28px;
} }
.donut-svg { .donut-svg {
width: 160px; width: 72px;
height: 160px; height: 72px;
filter: drop-shadow(0 2px 8px rgba(99,102,241,0.15)); flex-shrink: 0;
}
.seg-group { cursor: pointer; }
.seg-group:hover path { opacity: 0.8; }
.donut-info {
display: flex;
flex-direction: column;
gap: 6px;
min-width: 130px;
} }
.donut-label { .tooltip {
fill: var(--text-h); display: flex;
font-family: var(--sans); align-items: center;
font-weight: 300; gap: 7px;
pointer-events: none; font-size: 13px;
opacity: 0;
transition: opacity 0.15s ease;
} }
.tooltip::before {
.seg-group:hover .donut-label { content: '';
opacity: 1; width: 8px;
height: 8px;
border-radius: 50%;
background: var(--dot);
flex-shrink: 0;
} }
.tt-name { font-weight: 400; color: var(--text-h); }
.tt-val { font-weight: 300; color: var(--text-sub); }
.disclaimer { .section-label {
font-size: var(--text-xs); font-size: 10px;
font-weight: 500;
letter-spacing: 0.14em;
text-transform: uppercase;
color: var(--text-sub); color: var(--text-sub);
line-height: 1.5; }
text-align: center;
.hint {
font-size: 12px;
color: var(--text-sub);
opacity: 0.45;
}
/* bar */
.bar-block {
display: flex;
flex-direction: column;
padding: 0 28px;
gap: 0;
min-width: 160px;
}
.bar-bg {
width: 100%;
height: 5px;
background: var(--bg-subtle);
border-radius: 4px;
overflow: hidden;
margin-bottom: 10px;
}
.bar-fill {
height: 100%;
background: linear-gradient(90deg, var(--accent), #a78bfa);
border-radius: 4px;
transition: width 0.3s ease;
min-width: 0;
}
.disclaimer {
font-size: 11px;
color: var(--text-sub);
opacity: 0.5;
letter-spacing: 0.02em;
} }
</style> </style>

View File

@@ -5,6 +5,8 @@
import worldData from 'world-atlas/countries-50m.json'; import worldData from 'world-atlas/countries-50m.json';
import { getSelected, toggle, setTotalCount } from '../layout/selection.svelte.js'; import { getSelected, toggle, setTotalCount } from '../layout/selection.svelte.js';
let { onCountryClick = (_name) => {} } = $props();
const TERRITORY_PARENT = { const TERRITORY_PARENT = {
'016': '840', '060': '826', '086': '826', '092': '826', '136': '826', '016': '840', '060': '826', '086': '826', '092': '826', '136': '826',
'184': '554', '234': '208', '238': '826', '239': '826', '248': '246', '184': '554', '234': '208', '238': '826', '239': '826', '248': '246',
@@ -60,6 +62,7 @@
.on('click', (event, d) => { .on('click', (event, d) => {
toggle(effId(d)); toggle(effId(d));
updateFill(d3.select(event.currentTarget)); updateFill(d3.select(event.currentTarget));
onCountryClick(d.properties.name);
}) })
.on('mouseenter', (event, d) => { .on('mouseenter', (event, d) => {
d3.select(event.currentTarget).attr('fill', getSelected().has(effId(d)) ? '#16a34a' : '#f0f6fa'); d3.select(event.currentTarget).attr('fill', getSelected().has(effId(d)) ? '#16a34a' : '#f0f6fa');

View File

@@ -1,7 +1,6 @@
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte' import { svelte } from '@sveltejs/vite-plugin-svelte'
// https://vite.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [svelte()], plugins: [svelte()],
}) })