public home page with community activity overview

This commit is contained in:
Vincent van der Wal
2026-07-22 11:19:09 +02:00
parent b17f56b194
commit addef8b78e
11 changed files with 198 additions and 93 deletions
+67 -52
View File
@@ -2,91 +2,98 @@
import Map from '$lib/components/Map.svelte';
import StatTile from '$lib/components/StatTile.svelte';
import ActivityItem from '$lib/components/ActivityItem.svelte';
import { fmtDistance, fmtDuration, fmtElevation } from '$lib/format';
import { fmtDistance, fmtElevation } from '$lib/format';
let { data } = $props();
</script>
<svelte:head>
<title>Dashboard · Streba</title>
<title>Streba</title>
</svelte:head>
<h1>Dashboard</h1>
<p class="page-sub">Every track you've recorded, in one place.</p>
{#if data.totals.count === 0}
<div class="card empty">
<p><strong>Welcome to Streba.</strong></p>
<p>Upload your first GPX track to get going, or start ticking off Alpine peaks right away.</p>
<div class="empty-actions">
<a class="btn" href="/upload">Upload a GPX file</a>
<a class="btn ghost" href="/peaks">Browse the peaks</a>
{#if data.user}
<h1>Dashboard</h1>
<p class="page-sub">What everyone on Streba has been up to.</p>
{:else}
<div class="hero">
<div>
<h1>The GPX analyser</h1>
<p class="page-sub">
Upload your tracks, analyse every climb, and bag Alpine peaks - together.
</p>
</div>
<div class="hero-actions">
<a class="btn" href="/signup">Sign up</a>
<a class="btn ghost" href="/login">Sign in</a>
</div>
</div>
{:else}
<div class="kpis">
<StatTile label="Activities" value={String(data.totals.count)} />
<StatTile label="Total distance" value={fmtDistance(data.totals.distance_m)} />
<StatTile label="Total ascent" value={fmtElevation(data.totals.elev_gain_m)} />
<StatTile label="Moving time" value={fmtDuration(data.totals.moving_s)} />
</div>
{/if}
<h2>Worldmap</h2>
<Map tracks={data.tracks} height="440px" />
<div class="kpis">
<StatTile label="Members" value={String(data.totals.users)} />
<StatTile label="Activities" value={String(data.totals.activities)} />
<StatTile label="Total distance" value={fmtDistance(data.totals.distance_m)} />
<StatTile label="Total ascent" value={fmtElevation(data.totals.elev_gain_m)} />
</div>
<div class="lower">
<section>
<h2>Recent activities</h2>
<h2>Worldmap</h2>
<Map tracks={data.tracks} height="440px" />
<div class="lower">
<section>
<h2>Recent activities</h2>
{#if data.activities.length === 0}
<div class="card empty">
<p>Nothing here yet - be the first to upload a track.</p>
{#if data.user}<a class="btn" href="/upload">Upload a GPX file</a>{/if}
</div>
{:else}
<div class="card list">
{#each data.activities.slice(0, 6) as activity (activity.id)}
{#each data.activities.slice(0, 8) as activity (activity.id)}
<ActivityItem {activity} />
{/each}
</div>
</section>
{/if}
</section>
{#if data.mine}
<section>
<h2>Peak bagging</h2>
<h2>Your peak bagging</h2>
<div class="card peak-progress">
<div class="meter-nums">
<span class="big">{data.peaksClimbed}</span>
<span class="of">peak{data.peaksClimbed === 1 ? '' : 's'} climbed</span>
<span class="big">{data.mine.peaksClimbed}</span>
<span class="of">peak{data.mine.peaksClimbed === 1 ? '' : 's'} climbed</span>
</div>
{#if data.highestAscent}
{#if data.mine.highestAscent}
<p class="highest">
Highest so far: <strong>{data.highestAscent.name}</strong>
({Math.round(data.highestAscent.elevation_m ?? 0).toLocaleString('en-US')} m)
Highest so far: <strong>{data.mine.highestAscent.name}</strong>
({Math.round(data.mine.highestAscent.elevation_m ?? 0).toLocaleString('en-US')} m)
</p>
{/if}
<a class="btn ghost" href="/peaks">Open the peak map</a>
</div>
</section>
</div>
{/if}
{/if}
</div>
<style>
.hero {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1.5rem;
flex-wrap: wrap;
}
.hero-actions {
display: flex;
gap: 0.6rem;
padding-top: 0.35rem;
}
.kpis {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 0.75rem;
margin-bottom: 0.5rem;
}
.empty {
padding: 2.5rem;
text-align: center;
}
.empty p {
margin: 0.25rem 0;
color: var(--text-secondary);
}
.empty p strong {
color: var(--text-primary);
font-size: 1.1rem;
}
.empty-actions {
display: flex;
gap: 0.75rem;
justify-content: center;
margin-top: 1.25rem;
}
.lower {
display: grid;
grid-template-columns: 3fr 2fr;
@@ -101,6 +108,14 @@
.list :global(.item:not(:last-child)) {
border-bottom: 1px solid var(--border);
}
.empty {
padding: 2rem;
text-align: center;
}
.empty p {
margin: 0 0 1rem;
color: var(--text-secondary);
}
.peak-progress {
padding: 1.15rem;
display: flex;