moved country, days to top of the card & changed position
of tags
This commit is contained in:
313
src/lib/JournalDetail.svelte
Normal file
313
src/lib/JournalDetail.svelte
Normal file
@@ -0,0 +1,313 @@
|
||||
<script>
|
||||
/** @type {{ entry: import('./stores/journalStore.js').JournalEntry, onBack: () => void }} */
|
||||
let { entry, onBack } = $props();
|
||||
|
||||
let photoIdx = $state(0);
|
||||
|
||||
function formatDate(/** @type {string} */ iso) {
|
||||
return new Date(iso).toLocaleDateString('en-US', {
|
||||
year: 'numeric', month: 'long', day: 'numeric',
|
||||
});
|
||||
}
|
||||
|
||||
function prev() {
|
||||
photoIdx = (photoIdx - 1 + entry.photos.length) % entry.photos.length;
|
||||
}
|
||||
function next() {
|
||||
photoIdx = (photoIdx + 1) % entry.photos.length;
|
||||
}
|
||||
</script>
|
||||
|
||||
<article class="detail-page">
|
||||
|
||||
<button class="back-btn" onclick={onBack} aria-label="Back to timeline">
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
||||
<path d="M10 3L5 8l5 5" stroke="currentColor" stroke-width="1.8"
|
||||
stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
Back
|
||||
</button>
|
||||
|
||||
{#if entry.photos.length > 0}
|
||||
<div class="hero-gallery">
|
||||
<img
|
||||
class="hero-img"
|
||||
src={entry.photos[photoIdx]}
|
||||
alt="{entry.title} — photo {photoIdx + 1}"
|
||||
loading="lazy"
|
||||
/>
|
||||
{#if entry.photos.length > 1}
|
||||
<button class="arr left" onclick={prev} aria-label="Previous photo">‹</button>
|
||||
<button class="arr right" onclick={next} aria-label="Next photo">›</button>
|
||||
<div class="thumb-strip">
|
||||
{#each entry.photos as photo, i}
|
||||
<button
|
||||
class="thumb"
|
||||
class:active={i === photoIdx}
|
||||
onclick={() => (photoIdx = i)}
|
||||
aria-label="Photo {i + 1}"
|
||||
>
|
||||
<img src={photo} alt="" />
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
<span class="photo-counter">{photoIdx + 1} / {entry.photos.length}</span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="detail-content">
|
||||
<div class="meta-row">
|
||||
<span class="badge loc-badge">📍 {entry.location.city}, {entry.location.country}</span>
|
||||
<span class="badge trip-badge trip-badge--{entry.tripType}">
|
||||
{entry.tripType === 'solo' ? '🧍 Solo' : '👥 With Friends'}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h1 class="detail-title">{entry.title}</h1>
|
||||
|
||||
<div class="stats-row">
|
||||
<div class="stat">
|
||||
<span class="stat-label">Date</span>
|
||||
<time class="stat-value" datetime={entry.date}>{formatDate(entry.date)}</time>
|
||||
</div>
|
||||
<div class="stat-divider"></div>
|
||||
<div class="stat">
|
||||
<span class="stat-label">Duration</span>
|
||||
<span class="stat-value">{entry.days} {entry.days === 1 ? 'day' : 'days'}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="section-divider" />
|
||||
<p class="detail-memo">{entry.memo}</p>
|
||||
<hr class="section-divider" />
|
||||
|
||||
<div class="song-row">
|
||||
<div class="song-icon-wrap" aria-hidden="true">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M9 18V5l12-2v13" stroke="currentColor" stroke-width="2"
|
||||
stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<circle cx="6" cy="18" r="3" stroke="currentColor" stroke-width="2"/>
|
||||
<circle cx="18" cy="16" r="3" stroke="currentColor" stroke-width="2"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="song-text">
|
||||
<span class="song-label">Soundtrack</span>
|
||||
<span class="song-name">{entry.song.title}</span>
|
||||
<span class="song-artist">{entry.song.artist}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<style>
|
||||
.detail-page {
|
||||
max-width: 680px;
|
||||
margin: 0 auto;
|
||||
padding: 32px 24px 80px;
|
||||
font-family: var(--sans, system-ui, sans-serif);
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--text, #6b6375);
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 6px 0;
|
||||
margin-bottom: 28px;
|
||||
transition: color 0.15s;
|
||||
}
|
||||
.back-btn:hover { color: var(--accent, #aa3bff); }
|
||||
|
||||
.hero-gallery {
|
||||
position: relative;
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
background: #000;
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
|
||||
.hero-img {
|
||||
width: 100%;
|
||||
height: 380px;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.arr {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: rgba(0,0,0,0.45);
|
||||
color: #fff;
|
||||
border: none;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.15s;
|
||||
z-index: 2;
|
||||
}
|
||||
.arr:hover { background: rgba(0,0,0,0.7); }
|
||||
.arr.left { left: 14px; }
|
||||
.arr.right { right: 14px; }
|
||||
|
||||
.photo-counter {
|
||||
position: absolute;
|
||||
top: 14px;
|
||||
right: 14px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: #fff;
|
||||
background: rgba(0,0,0,0.45);
|
||||
padding: 3px 10px;
|
||||
border-radius: 20px;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.thumb-strip {
|
||||
position: absolute;
|
||||
bottom: 12px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.thumb {
|
||||
width: 52px;
|
||||
height: 36px;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
border: 2px solid transparent;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
opacity: 0.65;
|
||||
background: none;
|
||||
transition: border-color 0.15s, opacity 0.15s;
|
||||
}
|
||||
.thumb.active { border-color: #fff; opacity: 1; }
|
||||
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
||||
|
||||
.detail-content { text-align: left; }
|
||||
|
||||
.meta-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.badge {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
padding: 4px 10px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.loc-badge {
|
||||
background: var(--accent-bg, rgba(170,59,255,0.08));
|
||||
color: var(--accent, #aa3bff);
|
||||
}
|
||||
|
||||
.trip-badge--solo { background: rgba(245,158,11,0.12); color: #b45309; }
|
||||
.trip-badge--friends { background: rgba(59,130,246,0.12); color: #1d4ed8; }
|
||||
|
||||
.detail-title {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: var(--text-h, #08060d);
|
||||
margin: 0 0 20px;
|
||||
letter-spacing: -0.6px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.stats-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.stat { display: flex; flex-direction: column; gap: 2px; }
|
||||
|
||||
.stat-label {
|
||||
font-size: 11px;
|
||||
letter-spacing: 1.5px;
|
||||
text-transform: uppercase;
|
||||
color: var(--text, #6b6375);
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--text-h, #08060d);
|
||||
}
|
||||
|
||||
.stat-divider {
|
||||
width: 1px;
|
||||
height: 32px;
|
||||
background: var(--border, #e5e4e7);
|
||||
}
|
||||
|
||||
.section-divider {
|
||||
border: none;
|
||||
border-top: 1px solid var(--border, #e5e4e7);
|
||||
margin: 24px 0;
|
||||
}
|
||||
|
||||
.detail-memo {
|
||||
font-size: 16px;
|
||||
line-height: 1.75;
|
||||
color: var(--text, #6b6375);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.song-row { display: flex; align-items: center; gap: 14px; }
|
||||
|
||||
.song-icon-wrap {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 50%;
|
||||
background: var(--accent-bg, rgba(170,59,255,0.08));
|
||||
color: var(--accent, #aa3bff);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.song-text { display: flex; flex-direction: column; gap: 2px; }
|
||||
|
||||
.song-label {
|
||||
font-size: 11px;
|
||||
letter-spacing: 1.5px;
|
||||
text-transform: uppercase;
|
||||
color: var(--text, #6b6375);
|
||||
}
|
||||
|
||||
.song-name {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--text-h, #08060d);
|
||||
}
|
||||
|
||||
.song-artist { font-size: 13px; color: var(--text, #6b6375); }
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.detail-page { padding: 24px 16px 60px; }
|
||||
.hero-img { height: 260px; }
|
||||
.detail-title { font-size: 22px; }
|
||||
.thumb { width: 40px; height: 28px; }
|
||||
}
|
||||
</style>
|
||||
@@ -1,15 +1,20 @@
|
||||
<script>
|
||||
import { get } from 'svelte/store';
|
||||
import { journals } from './stores/journalStore.js';
|
||||
import JournalDetail from './JournalDetail.svelte';
|
||||
|
||||
/** @type {'date-desc'|'date-asc'|'country-asc'|'country-desc'} */
|
||||
let sortKey = 'date-desc';
|
||||
/** @type {import('./stores/journalStore.js').JournalEntry|null} */
|
||||
let selected = $state(null);
|
||||
|
||||
/** @type {'vertical'|'horizontal'} */
|
||||
let layout = 'vertical';
|
||||
|
||||
// per-entry current photo index
|
||||
/** @type {Record<string, number>} */
|
||||
let photoIdx = {};
|
||||
let photoIdx = $state({});
|
||||
|
||||
// Store subscription
|
||||
let entries = $state(get(journals));
|
||||
$effect(() => {
|
||||
const unsub = journals.subscribe((v) => { entries = v; });
|
||||
return unsub;
|
||||
});
|
||||
|
||||
const sortOptions = [
|
||||
{ value: 'date-desc', label: 'Newest First' },
|
||||
@@ -18,265 +23,134 @@
|
||||
{ value: 'country-desc', label: 'Country Z → A' },
|
||||
];
|
||||
|
||||
/** @param {import('./stores/journalStore.js').JournalEntry[]} entries */
|
||||
function sorted(entries) {
|
||||
return [...entries].sort((a, b) => {
|
||||
switch (sortKey) {
|
||||
case 'date-asc': return a.date.localeCompare(b.date);
|
||||
case 'date-desc': return b.date.localeCompare(a.date);
|
||||
case 'country-asc':
|
||||
return a.location.country.localeCompare(b.location.country) || b.date.localeCompare(a.date);
|
||||
case 'country-desc':
|
||||
return b.location.country.localeCompare(a.location.country) || b.date.localeCompare(a.date);
|
||||
default: return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
let sortKey = $state('date-desc');
|
||||
|
||||
/** @param {string} iso */
|
||||
function formatDate(iso) {
|
||||
// Explicit $effect so sortKey changes always trigger a re-sort
|
||||
let sortedEntries = $state(/** @type {typeof entries} */([]));
|
||||
$effect(() => {
|
||||
const key = sortKey;
|
||||
sortedEntries = [...entries].sort((a, b) => {
|
||||
if (key === 'date-asc') return a.date.localeCompare(b.date);
|
||||
if (key === 'date-desc') return b.date.localeCompare(a.date);
|
||||
if (key === 'country-asc') return a.location.country.localeCompare(b.location.country) || b.date.localeCompare(a.date);
|
||||
if (key === 'country-desc') return b.location.country.localeCompare(a.location.country) || b.date.localeCompare(a.date);
|
||||
return 0;
|
||||
});
|
||||
});
|
||||
|
||||
function formatDate(/** @type {string} */ iso) {
|
||||
return new Date(iso).toLocaleDateString('en-US', {
|
||||
year: 'numeric', month: 'long', day: 'numeric',
|
||||
year: 'numeric', month: 'short', day: 'numeric',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} id
|
||||
* @param {number} total
|
||||
* @param {1|-1} dir
|
||||
*/
|
||||
function stepPhoto(id, total, dir) {
|
||||
function stepPhoto(/** @type {string} */ id, /** @type {number} */ total, /** @type {1|-1} */ dir, /** @type {Event} */ e) {
|
||||
e.stopPropagation();
|
||||
const cur = photoIdx[id] ?? 0;
|
||||
photoIdx = { ...photoIdx, [id]: (cur + dir + total) % total };
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} id
|
||||
* @param {number} i
|
||||
*/
|
||||
function setPhoto(id, i) {
|
||||
function setPhoto(/** @type {string} */ id, /** @type {number} */ i, /** @type {Event} */ e) {
|
||||
e.stopPropagation();
|
||||
photoIdx = { ...photoIdx, [id]: i };
|
||||
}
|
||||
|
||||
$: sortedEntries = sorted($journals);
|
||||
</script>
|
||||
|
||||
<section class="timeline-view">
|
||||
{#if selected}
|
||||
<JournalDetail entry={selected} onBack={() => (selected = null)} />
|
||||
{:else}
|
||||
<section class="timeline-view">
|
||||
|
||||
<!-- ── Toolbar ── -->
|
||||
<header class="toolbar">
|
||||
<div class="title-block">
|
||||
<p class="eyebrow">Travel Journal</p>
|
||||
<h1 class="page-title">My Journey</h1>
|
||||
</div>
|
||||
|
||||
<div class="controls">
|
||||
<!-- Sort -->
|
||||
<header class="toolbar">
|
||||
<div class="title-block">
|
||||
<p class="eyebrow">Travel Journal</p>
|
||||
<h1 class="page-title">My Journey</h1>
|
||||
</div>
|
||||
<div class="sort-control">
|
||||
<label for="sort-select">Sort</label>
|
||||
<select id="sort-select" bind:value={sortKey}>
|
||||
<select id="sort-select" onchange={(e) => (sortKey = e.currentTarget.value)}>
|
||||
{#each sortOptions as opt}
|
||||
<option value={opt.value}>{opt.label}</option>
|
||||
<option value={opt.value} selected={opt.value === sortKey}>{opt.label}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Layout toggle -->
|
||||
<div class="layout-toggle" role="group" aria-label="Timeline layout">
|
||||
<button
|
||||
class="toggle-btn"
|
||||
class:active={layout === 'vertical'}
|
||||
on:click={() => (layout = 'vertical')}
|
||||
aria-pressed={layout === 'vertical'}
|
||||
title="Vertical timeline"
|
||||
>
|
||||
<!-- vertical bars icon -->
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
||||
<rect x="1" y="1" width="14" height="2" rx="1" fill="currentColor"/>
|
||||
<rect x="1" y="5" width="14" height="2" rx="1" fill="currentColor"/>
|
||||
<rect x="1" y="9" width="14" height="2" rx="1" fill="currentColor"/>
|
||||
<rect x="1" y="13" width="14" height="2" rx="1" fill="currentColor"/>
|
||||
</svg>
|
||||
Vertical
|
||||
</button>
|
||||
<button
|
||||
class="toggle-btn"
|
||||
class:active={layout === 'horizontal'}
|
||||
on:click={() => (layout = 'horizontal')}
|
||||
aria-pressed={layout === 'horizontal'}
|
||||
title="Horizontal timeline"
|
||||
>
|
||||
<!-- horizontal bars icon -->
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
||||
<rect x="1" y="1" width="2" height="14" rx="1" fill="currentColor"/>
|
||||
<rect x="5" y="1" width="2" height="14" rx="1" fill="currentColor"/>
|
||||
<rect x="9" y="1" width="2" height="14" rx="1" fill="currentColor"/>
|
||||
<rect x="13" y="1" width="2" height="14" rx="1" fill="currentColor"/>
|
||||
</svg>
|
||||
Horizontal
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- ── Empty state ── -->
|
||||
{#if sortedEntries.length === 0}
|
||||
<p class="empty">No journal entries yet.</p>
|
||||
|
||||
<!-- ── Vertical layout ── -->
|
||||
{:else if layout === 'vertical'}
|
||||
<ol class="v-list">
|
||||
{#each sortedEntries as entry (entry.id)}
|
||||
{@const idx = photoIdx[entry.id] ?? 0}
|
||||
<li class="v-item">
|
||||
<div class="v-dot" aria-hidden="true"></div>
|
||||
<article class="entry-card">
|
||||
|
||||
<!-- Gallery -->
|
||||
{#if entry.photos.length > 0}
|
||||
<div class="gallery">
|
||||
<img
|
||||
class="gallery-main"
|
||||
src={entry.photos[idx]}
|
||||
alt="{entry.title} photo {idx + 1}"
|
||||
loading="lazy"
|
||||
/>
|
||||
{#if entry.photos.length > 1}
|
||||
<button
|
||||
class="gallery-arrow left"
|
||||
on:click={() => stepPhoto(entry.id, entry.photos.length, -1)}
|
||||
aria-label="Previous photo"
|
||||
>‹</button>
|
||||
<button
|
||||
class="gallery-arrow right"
|
||||
on:click={() => stepPhoto(entry.id, entry.photos.length, 1)}
|
||||
aria-label="Next photo"
|
||||
>›</button>
|
||||
<div class="gallery-dots">
|
||||
{#each entry.photos as _, i}
|
||||
<button
|
||||
class="gallery-pip"
|
||||
class:active={i === idx}
|
||||
on:click={() => setPhoto(entry.id, i)}
|
||||
aria-label="Photo {i + 1}"
|
||||
></button>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="entry-body">
|
||||
<div class="entry-meta">
|
||||
<time class="entry-date" datetime={entry.date}>{formatDate(entry.date)}</time>
|
||||
<span class="entry-loc">{entry.location.city}, {entry.location.country}</span>
|
||||
<span class="trip-badge trip-badge--{entry.tripType}">
|
||||
{entry.tripType === 'solo' ? '🧍 Solo' : '👥 With Friends'}
|
||||
</span>
|
||||
</div>
|
||||
<h2 class="entry-title">{entry.title}</h2>
|
||||
{#if entry.memo}
|
||||
<p class="entry-memo">{entry.memo}</p>
|
||||
{/if}
|
||||
<div class="entry-song">
|
||||
<svg class="song-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||
<path d="M9 18V5l12-2v13" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<circle cx="6" cy="18" r="3" stroke="currentColor" stroke-width="2"/>
|
||||
<circle cx="18" cy="16" r="3" stroke="currentColor" stroke-width="2"/>
|
||||
</svg>
|
||||
<span class="song-title">{entry.song.title}</span>
|
||||
<span class="song-sep">·</span>
|
||||
<span class="song-artist">{entry.song.artist}</span>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</li>
|
||||
{/each}
|
||||
</ol>
|
||||
|
||||
<!-- ── Horizontal layout ── -->
|
||||
{:else}
|
||||
<div class="h-scroll-wrapper">
|
||||
<div class="h-track-row" aria-hidden="true">
|
||||
<div class="h-line"></div>
|
||||
{#each sortedEntries as entry (entry.id)}
|
||||
<div class="h-dot"></div>
|
||||
{/each}
|
||||
</div>
|
||||
<ol class="h-list">
|
||||
{#if sortedEntries.length === 0}
|
||||
<p class="empty">No journal entries yet.</p>
|
||||
{:else}
|
||||
<ol class="v-list">
|
||||
{#each sortedEntries as entry (entry.id)}
|
||||
{@const idx = photoIdx[entry.id] ?? 0}
|
||||
<li class="h-item">
|
||||
<article class="entry-card h-card">
|
||||
<li class="v-item">
|
||||
<div class="v-dot" aria-hidden="true"></div>
|
||||
<div class="v-entry-wrap">
|
||||
<div class="above-card">
|
||||
<time class="above-date" datetime={entry.date}>{formatDate(entry.date)}</time>
|
||||
<span class="above-sep">·</span>
|
||||
<span class="above-loc">{entry.location.city}, {entry.location.country}</span>
|
||||
<span class="above-sep">·</span>
|
||||
<span class="above-days">{entry.days} {entry.days === 1 ? 'day' : 'days'}</span>
|
||||
</div>
|
||||
<div class="entry-card" role="button" tabindex="0"
|
||||
onclick={() => (selected = entry)}
|
||||
onkeydown={(e) => e.key === 'Enter' && (selected = entry)}>
|
||||
|
||||
<!-- Gallery -->
|
||||
{#if entry.photos.length > 0}
|
||||
<div class="gallery">
|
||||
<img
|
||||
class="gallery-main"
|
||||
src={entry.photos[idx]}
|
||||
alt="{entry.title} photo {idx + 1}"
|
||||
loading="lazy"
|
||||
/>
|
||||
{#if entry.photos.length > 1}
|
||||
<button
|
||||
class="gallery-arrow left"
|
||||
on:click={() => stepPhoto(entry.id, entry.photos.length, -1)}
|
||||
aria-label="Previous photo"
|
||||
>‹</button>
|
||||
<button
|
||||
class="gallery-arrow right"
|
||||
on:click={() => stepPhoto(entry.id, entry.photos.length, 1)}
|
||||
aria-label="Next photo"
|
||||
>›</button>
|
||||
<div class="gallery-dots">
|
||||
{#each entry.photos as _, i}
|
||||
<button
|
||||
class="gallery-pip"
|
||||
class:active={i === idx}
|
||||
on:click={() => setPhoto(entry.id, i)}
|
||||
aria-label="Photo {i + 1}"
|
||||
></button>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="entry-body">
|
||||
<div class="entry-meta">
|
||||
<time class="entry-date" datetime={entry.date}>{formatDate(entry.date)}</time>
|
||||
<span class="entry-loc">{entry.location.city}, {entry.location.country}</span>
|
||||
</div>
|
||||
<h2 class="entry-title">{entry.title}</h2>
|
||||
{#if entry.memo}
|
||||
<p class="entry-memo">{entry.memo}</p>
|
||||
{#if entry.photos.length > 0}
|
||||
<div class="gallery">
|
||||
<img class="gallery-main" src={entry.photos[idx]}
|
||||
alt="{entry.title} photo {idx + 1}" loading="lazy" />
|
||||
{#if entry.photos.length > 1}
|
||||
<button class="gallery-arrow left"
|
||||
onclick={(e) => stepPhoto(entry.id, entry.photos.length, -1, e)}
|
||||
aria-label="Previous photo">‹</button>
|
||||
<button class="gallery-arrow right"
|
||||
onclick={(e) => stepPhoto(entry.id, entry.photos.length, 1, e)}
|
||||
aria-label="Next photo">›</button>
|
||||
<div class="gallery-dots">
|
||||
{#each entry.photos as _, i}
|
||||
<button class="gallery-pip" class:active={i === idx}
|
||||
onclick={(e) => setPhoto(entry.id, i, e)}
|
||||
aria-label="Photo {i + 1}"></button>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="entry-song">
|
||||
<svg class="song-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||
<path d="M9 18V5l12-2v13" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<circle cx="6" cy="18" r="3" stroke="currentColor" stroke-width="2"/>
|
||||
<circle cx="18" cy="16" r="3" stroke="currentColor" stroke-width="2"/>
|
||||
</svg>
|
||||
<span class="song-title">{entry.song.title}</span>
|
||||
<span class="song-sep">·</span>
|
||||
<span class="song-artist">{entry.song.artist}</span>
|
||||
|
||||
<div class="entry-body">
|
||||
<h2 class="entry-title">{entry.title}</h2>
|
||||
{#if entry.memo}
|
||||
<p class="entry-memo">{entry.memo}</p>
|
||||
{/if}
|
||||
<div class="entry-song">
|
||||
<svg class="song-icon" width="13" height="13" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M9 18V5l12-2v13" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<circle cx="6" cy="18" r="3" stroke="currentColor" stroke-width="2"/>
|
||||
<circle cx="18" cy="16" r="3" stroke="currentColor" stroke-width="2"/>
|
||||
</svg>
|
||||
<span class="song-title">{entry.song.title}</span>
|
||||
<span class="song-sep">·</span>
|
||||
<span class="song-artist">{entry.song.artist}</span>
|
||||
<span class="trip-badge trip-badge--{entry.tripType}">
|
||||
{entry.tripType === 'solo' ? 'Solo' : 'With Friends'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</li>
|
||||
{/each}
|
||||
</ol>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<footer class="page-footer">
|
||||
{sortedEntries.length} {sortedEntries.length === 1 ? 'entry' : 'entries'}
|
||||
</footer>
|
||||
</section>
|
||||
<footer class="page-footer">
|
||||
{sortedEntries.length} {sortedEntries.length === 1 ? 'entry' : 'entries'}
|
||||
</footer>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
/* ── Base ───────────────────────────────────────────────── */
|
||||
.timeline-view {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
@@ -284,7 +158,7 @@
|
||||
font-family: var(--sans, system-ui, sans-serif);
|
||||
}
|
||||
|
||||
/* ── Toolbar ────────────────────────────────────────────── */
|
||||
/* Toolbar */
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
@@ -312,24 +186,8 @@
|
||||
letter-spacing: -0.8px;
|
||||
}
|
||||
|
||||
.controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* Sort */
|
||||
.sort-control {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.sort-control label {
|
||||
font-size: 13px;
|
||||
color: var(--text, #6b6375);
|
||||
}
|
||||
.sort-control { display: flex; align-items: center; gap: 8px; }
|
||||
.sort-control label { font-size: 13px; color: var(--text, #6b6375); }
|
||||
|
||||
select {
|
||||
font-size: 13px;
|
||||
@@ -343,105 +201,68 @@
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6375' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 10px center;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
select:focus { outline: 2px solid var(--accent, #aa3bff); outline-offset: 2px; }
|
||||
|
||||
select:focus {
|
||||
outline: 2px solid var(--accent, #aa3bff);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* Layout toggle */
|
||||
.layout-toggle {
|
||||
display: flex;
|
||||
border: 1px solid var(--border, #e5e4e7);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.toggle-btn {
|
||||
/* Above-card */
|
||||
.above-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 7px 12px;
|
||||
font-size: 13px;
|
||||
color: var(--text, #6b6375);
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.above-date { font-size: 12px; font-weight: 500; color: var(--text-h, #08060d); }
|
||||
.above-loc, .above-days { font-size: 12px; color: var(--text, #6b6375); }
|
||||
.above-sep { font-size: 11px; color: var(--border, #c8c6cc); user-select: none; }
|
||||
|
||||
.toggle-btn:first-child {
|
||||
border-right: 1px solid var(--border, #e5e4e7);
|
||||
}
|
||||
|
||||
.toggle-btn.active {
|
||||
background: var(--accent-bg, rgba(170,59,255,0.08));
|
||||
color: var(--accent, #aa3bff);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.toggle-btn:hover:not(.active) {
|
||||
background: var(--code-bg, #f4f3ec);
|
||||
}
|
||||
|
||||
/* ── Shared card ────────────────────────────────────────── */
|
||||
/* Card */
|
||||
.entry-card {
|
||||
display: block;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid var(--border, #e5e4e7);
|
||||
border-radius: 14px;
|
||||
overflow: hidden;
|
||||
background: var(--bg, #fff);
|
||||
transition: box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.entry-card:hover {
|
||||
box-shadow: 0 6px 24px rgba(0,0,0,0.08);
|
||||
}
|
||||
|
||||
.entry-body {
|
||||
padding: 16px 20px 20px;
|
||||
cursor: pointer;
|
||||
transition: box-shadow 0.2s, transform 0.15s;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.entry-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 6px;
|
||||
.entry-card:hover {
|
||||
box-shadow: 0 6px 24px rgba(0,0,0,0.1);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.entry-date {
|
||||
font-size: 12px;
|
||||
color: var(--text, #6b6375);
|
||||
}
|
||||
.entry-body { padding: 14px 18px 18px; }
|
||||
|
||||
.entry-loc {
|
||||
font-size: 12px;
|
||||
color: var(--accent, #aa3bff);
|
||||
.entry-song .trip-badge { margin-left: auto; flex-shrink: 0; }
|
||||
|
||||
.trip-badge {
|
||||
display: inline-block;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
background: var(--accent-bg, rgba(170,59,255,0.08));
|
||||
padding: 2px 8px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
.trip-badge--solo { background: rgba(245,158,11,0.12); color: #b45309; }
|
||||
.trip-badge--friends { background: rgba(59,130,246,0.12); color: #1d4ed8; }
|
||||
|
||||
.entry-title {
|
||||
font-size: 17px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--text-h, #08060d);
|
||||
margin: 0 0 8px;
|
||||
letter-spacing: -0.3px;
|
||||
margin: 0 0 6px;
|
||||
letter-spacing: -0.2px;
|
||||
}
|
||||
|
||||
.entry-memo {
|
||||
font-size: 14px;
|
||||
line-height: 1.65;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
color: var(--text, #6b6375);
|
||||
margin: 0 0 12px;
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
/* Song row */
|
||||
.entry-song {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -451,217 +272,61 @@
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid var(--border, #e5e4e7);
|
||||
}
|
||||
.song-icon { flex-shrink: 0; color: var(--accent, #aa3bff); }
|
||||
.song-title { font-weight: 500; color: var(--text-h, #08060d); }
|
||||
.song-sep { opacity: 0.35; }
|
||||
|
||||
.song-icon {
|
||||
flex-shrink: 0;
|
||||
color: var(--accent, #aa3bff);
|
||||
}
|
||||
|
||||
.song-title {
|
||||
font-weight: 500;
|
||||
color: var(--text-h, #08060d);
|
||||
}
|
||||
|
||||
.song-sep {
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
/* Trip type badge */
|
||||
.trip-badge {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
padding: 2px 8px;
|
||||
border-radius: 20px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.trip-badge--solo {
|
||||
background: rgba(245, 158, 11, 0.12);
|
||||
color: #b45309;
|
||||
}
|
||||
|
||||
.trip-badge--friends {
|
||||
background: rgba(59, 130, 246, 0.12);
|
||||
color: #1d4ed8;
|
||||
}
|
||||
|
||||
/* ── Gallery ────────────────────────────────────────────── */
|
||||
.gallery {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
.gallery-main {
|
||||
width: 100%;
|
||||
height: 220px;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
/* Gallery */
|
||||
.gallery { position: relative; overflow: hidden; background: #000; }
|
||||
.gallery-main { width: 100%; height: 220px; object-fit: cover; display: block; }
|
||||
|
||||
.gallery-arrow {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: rgba(0,0,0,0.45);
|
||||
color: #fff;
|
||||
border: none;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
font-size: 20px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.15s;
|
||||
z-index: 2;
|
||||
position: absolute; top: 50%; transform: translateY(-50%);
|
||||
background: rgba(0,0,0,0.45); color: #fff;
|
||||
border: none; width: 32px; height: 32px; border-radius: 50%;
|
||||
font-size: 20px; cursor: pointer;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
transition: background 0.15s; z-index: 2;
|
||||
}
|
||||
|
||||
.gallery-arrow:hover {
|
||||
background: rgba(0,0,0,0.7);
|
||||
}
|
||||
|
||||
.gallery-arrow:hover { background: rgba(0,0,0,0.7); }
|
||||
.gallery-arrow.left { left: 10px; }
|
||||
.gallery-arrow.right { right: 10px; }
|
||||
|
||||
.gallery-dots {
|
||||
position: absolute;
|
||||
bottom: 8px;
|
||||
left: 50%;
|
||||
position: absolute; bottom: 8px; left: 50%;
|
||||
transform: translateX(-50%);
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
z-index: 2;
|
||||
display: flex; gap: 5px; z-index: 2;
|
||||
}
|
||||
|
||||
.gallery-pip {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
background: rgba(255,255,255,0.5);
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
width: 6px; height: 6px; border-radius: 50%;
|
||||
border: none; background: rgba(255,255,255,0.5);
|
||||
cursor: pointer; padding: 0;
|
||||
transition: background 0.15s, transform 0.15s;
|
||||
}
|
||||
.gallery-pip.active { background: #fff; transform: scale(1.3); }
|
||||
|
||||
.gallery-pip.active {
|
||||
background: #fff;
|
||||
transform: scale(1.3);
|
||||
}
|
||||
|
||||
/* ── Vertical timeline ──────────────────────────────────── */
|
||||
.v-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Vertical timeline */
|
||||
.v-list { list-style: none; padding: 0; margin: 0; position: relative; }
|
||||
.v-list::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 11px;
|
||||
bottom: 11px;
|
||||
width: 2px;
|
||||
background: var(--border, #e5e4e7);
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
.v-item {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
align-items: flex-start;
|
||||
padding-bottom: 32px;
|
||||
position: absolute; left: 10px; top: 6px; bottom: 6px;
|
||||
width: 2px; background: var(--border, #e5e4e7); border-radius: 1px;
|
||||
}
|
||||
|
||||
.v-item { display: flex; gap: 24px; align-items: flex-start; padding-bottom: 36px; }
|
||||
.v-item:last-child { padding-bottom: 0; }
|
||||
|
||||
.v-dot {
|
||||
flex-shrink: 0;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
|
||||
background: var(--accent, #aa3bff);
|
||||
border: 3px solid var(--bg, #fff);
|
||||
box-shadow: 0 0 0 2px var(--accent, #aa3bff);
|
||||
margin-top: 8px;
|
||||
z-index: 1;
|
||||
margin-top: 28px; z-index: 1;
|
||||
}
|
||||
|
||||
.v-item .entry-card { flex: 1; }
|
||||
.v-entry-wrap { flex: 1; display: flex; flex-direction: column; }
|
||||
|
||||
/* ── Horizontal timeline ────────────────────────────────── */
|
||||
.h-scroll-wrapper {
|
||||
overflow-x: auto;
|
||||
padding-bottom: 12px;
|
||||
/* hide scrollbar on webkit but keep functional */
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--border, #e5e4e7) transparent;
|
||||
}
|
||||
|
||||
/* Track row: line + dots overlay */
|
||||
.h-track-row {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
/* match card widths + gaps */
|
||||
min-width: max-content;
|
||||
padding: 0 16px;
|
||||
margin-bottom: -11px; /* overlap with card top */
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.h-line {
|
||||
position: absolute;
|
||||
left: 16px;
|
||||
right: 16px;
|
||||
top: 50%;
|
||||
height: 2px;
|
||||
background: var(--border, #e5e4e7);
|
||||
border-radius: 1px;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
.h-dot {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 50%;
|
||||
background: var(--accent, #aa3bff);
|
||||
border: 3px solid var(--bg, #fff);
|
||||
box-shadow: 0 0 0 2px var(--accent, #aa3bff);
|
||||
flex-shrink: 0;
|
||||
z-index: 1;
|
||||
/* center each dot over its card (card width 240 + gap 24) */
|
||||
margin-right: calc(240px + 24px - 22px);
|
||||
}
|
||||
|
||||
.h-dot:last-child { margin-right: 0; }
|
||||
|
||||
.h-list {
|
||||
list-style: none;
|
||||
padding: 12px 16px 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
min-width: max-content;
|
||||
}
|
||||
|
||||
.h-item { flex-shrink: 0; }
|
||||
|
||||
.h-card {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.h-card .gallery-main {
|
||||
height: 180px;
|
||||
}
|
||||
|
||||
/* ── Footer ─────────────────────────────────────────────── */
|
||||
/* Footer */
|
||||
.page-footer {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
@@ -671,13 +336,8 @@
|
||||
border-top: 1px solid var(--border, #e5e4e7);
|
||||
}
|
||||
|
||||
.empty {
|
||||
text-align: center;
|
||||
color: var(--text, #6b6375);
|
||||
padding: 80px 0;
|
||||
}
|
||||
.empty { text-align: center; color: var(--text, #6b6375); padding: 80px 0; }
|
||||
|
||||
/* ── Responsive ─────────────────────────────────────────── */
|
||||
@media (max-width: 600px) {
|
||||
.timeline-view { padding: 32px 16px 48px; }
|
||||
.page-title { font-size: 26px; }
|
||||
|
||||
@@ -9,6 +9,7 @@ import { writable } from 'svelte/store';
|
||||
* photos: string[],
|
||||
* song: { title: string, artist: string },
|
||||
* tripType: 'solo' | 'friends',
|
||||
* days: number,
|
||||
* memo: string
|
||||
* }} JournalEntry
|
||||
*/
|
||||
@@ -27,6 +28,7 @@ const mockEntries = [
|
||||
],
|
||||
song: { title: 'Tokyo', artist: 'Imagine Dragons' },
|
||||
tripType: 'solo',
|
||||
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.',
|
||||
},
|
||||
{
|
||||
@@ -40,6 +42,7 @@ const mockEntries = [
|
||||
],
|
||||
song: { title: 'Spirited Away Suite', artist: 'Joe Hisaishi' },
|
||||
tripType: 'friends',
|
||||
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.',
|
||||
},
|
||||
{
|
||||
@@ -54,6 +57,7 @@ const mockEntries = [
|
||||
],
|
||||
song: { title: 'La Vie en Rose', artist: 'Édith Piaf' },
|
||||
tripType: 'solo',
|
||||
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.',
|
||||
},
|
||||
{
|
||||
@@ -67,6 +71,7 @@ const mockEntries = [
|
||||
],
|
||||
song: { title: 'Spain', artist: 'Chick Corea' },
|
||||
tripType: 'friends',
|
||||
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.',
|
||||
},
|
||||
{
|
||||
@@ -81,6 +86,7 @@ const mockEntries = [
|
||||
],
|
||||
song: { title: 'New York, New York', artist: 'Frank Sinatra' },
|
||||
tripType: 'friends',
|
||||
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.',
|
||||
},
|
||||
{
|
||||
@@ -94,25 +100,19 @@ const mockEntries = [
|
||||
],
|
||||
song: { title: 'Elephant', artist: 'Tame Impala' },
|
||||
tripType: 'solo',
|
||||
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.',
|
||||
},
|
||||
];
|
||||
|
||||
export const journals = writable(mockEntries);
|
||||
|
||||
/**
|
||||
* @param {Omit<JournalEntry, 'id'>} entry
|
||||
*/
|
||||
/** @param {Omit<JournalEntry, 'id'>} entry */
|
||||
export function addJournal(entry) {
|
||||
journals.update((entries) => [
|
||||
...entries,
|
||||
{ ...entry, id: crypto.randomUUID() },
|
||||
]);
|
||||
journals.update((entries) => [...entries, { ...entry, id: crypto.randomUUID() }]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} id
|
||||
*/
|
||||
/** @param {string} id */
|
||||
export function removeJournal(id) {
|
||||
journals.update((entries) => entries.filter((e) => e.id !== id));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user