docent/web/src/routes/+page.svelte

206 lines
4.8 KiB
Svelte
Raw Normal View History

2026-05-05 09:33:51 -05:00
<script lang="ts">
2026-05-26 11:52:32 -05:00
import { exhibit, artists, type Artist } from '$lib/artists';
2026-05-05 09:33:51 -05:00
import { precacheState } from '$lib/precache.svelte';
2026-05-26 11:52:32 -05:00
import { fontsReady } from '$lib/fonts.svelte';
2026-05-05 09:33:51 -05:00
const pre = $derived(precacheState());
2026-05-26 11:52:32 -05:00
function artistYears(artist: Artist): string {
const years = new Set<string>();
for (const show of artist.shows) {
const m = show.caption.match(/\b(19|20)\d{2}\b/);
if (m) years.add(m[0]);
}
return [...years].sort().join(', ');
}
2026-05-05 09:33:51 -05:00
</script>
<header class="hero">
2026-05-26 11:52:32 -05:00
<div class="marquee-panel">
{#key fontsReady()}
<svg class="bulbs" width="100%" height="100%" aria-hidden="true"><rect pathLength="120" /></svg>
{/key}
<h1 class="title-marquee">{exhibit.title}</h1>
{#if exhibit.description}
{#each exhibit.description.split('\n').filter(Boolean) as line}
<p class="marquee-body">{line}</p>
{/each}
{/if}
</div>
2026-05-05 09:33:51 -05:00
</header>
2026-05-26 11:52:32 -05:00
{#if pre.state === 'running' || (pre.state === 'complete' && pre.failed > 0)}
2026-05-05 09:33:51 -05:00
<div class="precache" role="status" aria-live="polite">
2026-05-26 11:52:32 -05:00
{#if pre.state === 'running'}
<span class="dot" aria-hidden="true"></span>
<span class="text">
Caching exhibit for offline listening… {pre.done} / {pre.total}
{#if pre.failed > 0}({pre.failed} retrying){/if}
</span>
<div class="bar" aria-hidden="true">
<div class="bar-fill" style="width: {pre.total ? (pre.done / pre.total) * 100 : 0}%"></div>
</div>
{:else}
<span class="text">
{pre.total - pre.failed} of {pre.total} files cached. {pre.failed}
failed to download — they will stream over the network when played.
</span>
{/if}
2026-05-05 09:33:51 -05:00
</div>
{/if}
2026-05-26 11:52:32 -05:00
<main class="grid" aria-label="Artists">
{#each artists as artist (artist.id)}
{@const cover = artist.images[0]}
<a
class="tile"
href="/artist/{artist.id}"
data-sveltekit-preload-data="hover"
aria-label={artist.name}
>
2026-05-05 09:33:51 -05:00
<div class="tile-image">
2026-05-26 11:52:32 -05:00
{#if cover}
<img src={cover} alt="" loading="lazy" />
{:else}
<div class="tile-image-placeholder" aria-hidden="true"></div>
{/if}
2026-05-05 09:33:51 -05:00
</div>
<div class="tile-meta">
2026-05-26 11:52:32 -05:00
<span class="tile-name">{artist.name}</span>
<span class="tile-shows">{artistYears(artist)}</span>
2026-05-05 09:33:51 -05:00
</div>
</a>
{/each}
</main>
2026-05-26 11:52:32 -05:00
2026-05-05 09:33:51 -05:00
<style>
.hero {
2026-05-26 11:52:32 -05:00
padding: 1.5rem 1rem 1.5rem;
2026-05-05 09:33:51 -05:00
text-align: center;
}
.precache {
display: flex;
2026-05-26 11:52:32 -05:00
flex-wrap: wrap;
2026-05-05 09:33:51 -05:00
align-items: center;
gap: 0.6rem;
2026-05-26 11:52:32 -05:00
margin: 0 auto 0.75rem;
padding: 0.6rem 1rem;
2026-05-05 09:33:51 -05:00
max-width: 32rem;
font-size: 0.9rem;
2026-05-26 11:52:32 -05:00
color: var(--ink-on-callout);
background: var(--bg-callout);
2026-05-05 09:33:51 -05:00
border-radius: var(--radius);
box-shadow: var(--shadow);
}
2026-05-26 11:52:32 -05:00
.precache .text {
flex: 1 1 auto;
}
.precache .bar {
flex: 1 0 100%;
height: 4px;
background: rgba(255, 255, 255, 0.12);
border-radius: 2px;
overflow: hidden;
}
.precache .bar-fill {
height: 100%;
background: var(--highlight);
transition: width 0.2s linear;
}
2026-05-05 09:33:51 -05:00
.precache .dot {
width: 8px;
height: 8px;
border-radius: 50%;
2026-05-26 11:52:32 -05:00
background: var(--highlight);
2026-05-05 09:33:51 -05:00
animation: pulse 1.4s ease-in-out infinite;
flex-shrink: 0;
}
@keyframes pulse {
0%, 100% { opacity: 0.3; transform: scale(0.8); }
50% { opacity: 1; transform: scale(1.1); }
}
@media (prefers-reduced-motion: reduce) {
.precache .dot { animation: none; opacity: 0.7; }
}
2026-05-26 11:52:32 -05:00
.hero :global(.title-marquee) {
font-size: clamp(2.25rem, 9vw, 4rem);
2026-05-05 09:33:51 -05:00
}
.grid {
display: grid;
gap: 1rem;
padding: 1rem;
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
@media (min-width: 768px) {
.grid {
gap: 1.25rem;
padding: 1.25rem 2rem 3rem;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
}
.tile {
display: flex;
flex-direction: column;
gap: 0.75rem;
2026-05-26 11:52:32 -05:00
color: var(--ink);
2026-05-05 09:33:51 -05:00
border-radius: var(--radius-lg);
2026-05-26 11:52:32 -05:00
background: var(--bg-card);
2026-05-05 09:33:51 -05:00
box-shadow: var(--shadow);
overflow: hidden;
transition: transform 0.15s ease;
}
.tile:active {
transform: scale(0.98);
}
.tile-image {
2026-05-26 11:52:32 -05:00
position: relative;
2026-05-05 09:33:51 -05:00
aspect-ratio: 4 / 3;
background: var(--rule);
overflow: hidden;
}
.tile-image img {
width: 100%;
height: 100%;
object-fit: cover;
2026-05-26 11:52:32 -05:00
object-position: center top;
}
.tile-image-placeholder {
width: 100%;
height: 100%;
background:
repeating-linear-gradient(
135deg,
transparent 0,
transparent 18px,
rgba(75, 108, 100, 0.08) 18px,
rgba(75, 108, 100, 0.08) 19px
),
var(--rule);
2026-05-05 09:33:51 -05:00
}
.tile-meta {
display: flex;
2026-05-26 11:52:32 -05:00
flex-direction: column;
gap: 0.15rem;
2026-05-05 09:33:51 -05:00
padding: 0.25rem 1rem 1rem;
}
2026-05-26 11:52:32 -05:00
.tile-name {
font-family: var(--font-marquee);
font-weight: 400;
font-size: 1.35rem;
line-height: 1.05;
letter-spacing: 0.04em;
text-transform: uppercase;
color: #111111;
}
.tile-shows {
font-family: var(--font-marquee);
font-size: 0.9rem;
line-height: 1.1;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #111111;
2026-05-05 09:33:51 -05:00
font-variant-numeric: tabular-nums;
}
</style>